Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSURLMBS class.

NSURLMBS.fileURLWithFileSystemRepresentation(path as string, isDirectory as boolean, relativeToURL as NSURLMBS) as NSURLMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacBase Plugin 15.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Initializes a newly created URL referencing the local file or directory at the file system representation of the path.

File system representation is a string with canonical UTF-8 encoding.

NSURLMBS.fileURLWithPath(path as string) as NSURLMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacBase Plugin 15.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Builds a file URL with given file path.

Better to use fileURLWithPath with directory parameter if you know if the path is a directory vs non-directory, as it saves an i/o.

See also:

NSURLMBS.fileURLWithPath(path as string, isDirectory as boolean) as NSURLMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacBase Plugin 15.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Builds a file URL based on a given file path.

See also:

NSURLMBS.fileURLWithPathComponents(components() as string) as NSURLMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacBase Plugin 15.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Builds an URL based on given components.

NSURLMBS.mountedVolumeURLs(SkipHidden as boolean = true) as NSURLMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacBase Plugin 15.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Queries array of all NSURLs for mounted volumes.

if SkipHidden is true, hidden volumes are skipped.
Returns nil in case of error.

Some examples using this method:

NSURLMBS.URLsResourceValuesForKeys(URLs() as NSURLMBS, keys() as string, targetDelegate as URLsResourceValuesForKeysDelegateMBS, tag as Variant = nil, PrecacheIcons as boolean = false)

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacBase Plugin 15.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Queries several URLs for values.

Similar to resourceValuesForKeys, this method will start a preemptive thread and queries values for all URLs on all keys in background. Once done it calls the delegate on main thread.
For icons, you can set PrecacheIcons to true. In that case plugin will draw icon on the preemptive thread, so icon data is really loaded from disk. When you than draw on main thread, it's really quick.

the delegate is declared like this:
URLsResourceValuesForKeysDelegateMBS(URLs() as NSURLMBS, keys() as String, Values() as Dictionary, Errors() as NSErrorMBS, tag as Variant)

Some examples using this method:

NSURLMBS.URLWithHandle(Handle as Integer) as NSURLMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacBase Plugin 16.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a new URL object based on a handle value.

Will retain the reference.

NSURLMBS.URLWithItem(Item as FolderItem) as NSURLMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacBase Plugin 15.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates an URL based on folderItem.
Example
Var f as FolderItem = GetFolderItem("/Volumes/Ablage1", FolderItem.PathTypeNative)
Var n as NSURLMBS = NSURLMBS.URLWithItem(f)
MsgBox n.absoluteString

NSURLMBS.URLWithString(URL as string) as NSURLMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacBase Plugin 15.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates and returns an NSURL object initialized with a provided URL string.

See also:

NSURLMBS.URLWithString(URL as string, baseURL as NSURLMBS) as NSURLMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacBase Plugin 15.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates and returns an NSURL object initialized with a base URL and a relative string.

This method allows you to create a URL relative to a base path or URL. For example, if you have the URL for a folder on disk and the name of a file within that folder, you can construct a URL for the file by providing the folder’s URL as the base path (with a trailing slash) and the filename as the string part.

This method expects URLString to contain only characters that are allowed in a properly formed URL. All other characters must be properly percent escaped. Any percent-escaped characters are interpreted using UTF-8 encoding.

See also:

The items on this page are in the following plugins: MBS MacBase Plugin.


The biggest plugin in space...