Platforms to show: All Mac Windows Linux Cross-Platform
Back to NSFileManagerMBS class.
NSFileManagerMBS.fileManagerWithAuthorization(authorization as NSWorkspaceAuthorizationMBS) as NSFileManagerMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 19.3 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop only |
Returns nil in case of errors.
This method returns an NSFileManagerMBS instance that can perform file system operations previously allowed by the user via NSWorkspaceMBS.requestAuthorization. Each NSWorkspaceAuthorizationMBS you receive requires creating a new NSFileManagerMBS instance using this method.
Only the following NSFileManagerMBS methods currently take advantage of an authorization:
- createSymbolicLink (NSWorkspaceAuthorizationTypeCreateSymbolicLink)
- setAttributes (NSWorkspaceAuthorizationTypeSetAttributes)
- replaceItem (NSWorkspaceAuthorizationTypeReplaceFile)
Note that an NSWorkspaceAuthorizationTypeSetAttributes authorization only enables setAttributes to modify the following attributes:
- NSFileOwnerAccountID
- NSFileGroupOwnerAccountID
- NSFilePosixPermissions
Also note that for replaceItem, the backupItemName and options parameters will be ignored.
These methods may also fail with any of the following errors:
- NSWorkspaceAuthorizationInvalidError: The provided NSWorkspaceAuthorization expired or is invalid.
- NSFileWriteUnknownError: The application failed to communicate with a helper process, or a file system error occurred.
- NSFileWriteNoPermissionError: The operation failed for any other reason, including the user denying access to the resource, or access to a resource is denied by system policy.
All other NSFileManager methods invoked on this instance will behave normally.
The app using this may need code signature with com.apple.developer.security.privileged-file-operations entitlement for the sandboxed application and may need to be in applications folder.
Some examples using this method:
NSFileManagerMBS.lastPathComponent(pathOrURL as string) as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.1 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Available in Mac OS X v10.6 and later.
NSFileManagerMBS.NSFileAppendOnly as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates whether the file is read-only.
The corresponding value is a number containing a Boolean value.
Available in Mac OS X v10.2 and later.
NSFileManagerMBS.NSFileBusy as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates whether the file is busy.
The corresponding value is a number containing a Boolean value.
Available in Mac OS X v10.4 and later.
NSFileManagerMBS.NSFileCreationDate as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates the file's creation date.
The corresponding value is a date.
Available in Mac OS X v10.2 and later.
NSFileManagerMBS.NSFileDeviceIdentifier as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates the identifier for the device on which the file resides.
The corresponding value is a number containing an Int32.
Available in Mac OS X v10.0 and later.
NSFileManagerMBS.NSFileExtensionHidden as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates whether the file's extension is hidden.
The corresponding value is a number containing a Boolean value.
Available in Mac OS X v10.1 and later.
NSFileManagerMBS.NSFileGroupOwnerAccountID as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates the file's group ID.
The corresponding value is a number containing an Int32.
Available in Mac OS X v10.2 and later.
NSFileManagerMBS.NSFileGroupOwnerAccountName as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates the group name of the file's owner.
The corresponding value is a string.
Available in Mac OS X v10.0 and later.
NSFileManagerMBS.NSFileHFSCreatorCode as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates the file's HFS creator code.
The corresponding value is a number containing an Int32. See "HFS File Types" for possible values.
Available in Mac OS X v10.1 and later.
NSFileManagerMBS.NSFileHFSTypeCode as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates the file's HFS type code.
The corresponding value is a number containing an Int32. See "HFS File Types" for possible values.
Available in Mac OS X v10.1 and later.
NSFileManagerMBS.NSFileImmutable as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates whether the file is mutable.
The corresponding value is a number containing a Boolean value.
Available in Mac OS X v10.2 and later.
NSFileManagerMBS.NSFileManagerUnmountDissentingProcessIdentifierErrorKey as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 18.5 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
NSFileManagerMBS.NSFileModificationDate as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates the file's last modified date.
The corresponding value is a date.
Available in Mac OS X v10.0 and later.
NSFileManagerMBS.NSFileOwnerAccountID as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates the file's owner's account ID.
The corresponding value is a number containing an Int32.
Available in Mac OS X v10.2 and later.
NSFileManagerMBS.NSFileOwnerAccountName as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates the name of the file's owner.
The corresponding value is a string.
Available in Mac OS X v10.0 and later.
NSFileManagerMBS.NSFilePosixPermissions as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates the file's Posix permissions.
The corresponding value is a number.
Available in Mac OS X v10.0 and later.
NSFileManagerMBS.NSFileReferenceCount as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates the file's reference count.
The corresponding value is a number containing an Int32.
The number specifies the number of hard links to a file.
Available in Mac OS X v10.0 and later.
NSFileManagerMBS.NSFileSize as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates the file's size in bytes.
The corresponding value is a number containing an Int64.
Important If the file has a resource fork, the returned value does not include the size of the resource fork.
NSFileManagerMBS.NSFileSystemFileNumber as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates the file's filesystem file number.
The corresponding value is a number containing an Int32. The value corresponds to the value of st_ino, as returned by stat(2).
Available in Mac OS X v10.0 and later.
NSFileManagerMBS.NSFileSystemFreeNodes as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file system attribute dictionary dictionary whose value indicates the number of free nodes in the file system.
The corresponding value is a number that specifies the number of free nodes in the file system.
Available in Mac OS X v10.0 and later.
NSFileManagerMBS.NSFileSystemFreeSize as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file system attribute dictionary whose value indicates the amount of free space on the file system.
The corresponding value is a number that specifies the amount of free space on the file system in bytes. The value is determined by statfs().
Available in Mac OS X v10.0 and later.
NSFileManagerMBS.NSFileSystemNodes as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file system attribute dictionary whose value indicates the number of nodes in the file system.
The corresponding value is a number that specifies the number of nodes in the file system.
Available in Mac OS X v10.0 and later.
NSFileManagerMBS.NSFileSystemNumber as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file system attribute dictionary dictionary whose value indicates the filesystem number of the file system.
The corresponding value is a number that specifies the filesystem number of the file system. The value corresponds to the value of st_dev, as returned by stat(2).
Available in Mac OS X v10.0 and later.
NSFileManagerMBS.NSFileSystemSize as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file system attribute dictionary whose value indicates the size of the file system.
The corresponding value is a number that specifies the size of the file system in bytes. The value is determined by statfs().
Available in Mac OS X v10.0 and later.
NSFileManagerMBS.NSFileType as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The key in a file attribute dictionary whose value indicates the file's type.
The corresponding value is a string (see NSFileType* shared methods for possible values).
Available in Mac OS X v10.0 and later.
NSFileManagerMBS.NSFileTypeBlockSpecial as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Block special file (e.g. hard disk)
NSFileManagerMBS.NSFileTypeCharacterSpecial as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Character special file
NSFileManagerMBS.NSFileTypeDirectory as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Directory
NSFileManagerMBS.NSFileTypeRegular as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Regular file
NSFileManagerMBS.NSFileTypeSocket as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Socket (a socket visible in file system as a file)
NSFileManagerMBS.NSFileTypeSymbolicLink as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Symbolic link
NSFileManagerMBS.NSFileTypeUnknown as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.3 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Unknown
NSFileManagerMBS.NSUbiquityIdentityDidChangeNotification as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 18.5 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The system generates this notification when the user logs into or out of an iCloud account or enables or disables the syncing of documents and data. This notification is your cue to update caches and any interface elements displaying iCloud–related content. For example, hide all references to iCloud files when the user logs out of iCloud.
When your app receives this notification, get the new token from the NSURLRelationship property. The value of that token is nil if the user disabled iCloud or logged out. There is no userInfo dictionary.
NSFileManagerMBS.pathExtension(pathOrURL as string) as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 12.1 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Available in Mac OS X v10.6 and later.
NSFileManagerMBS.stringByAbbreviatingWithTildeInPath(path as string) as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 16.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
A new string based on the current string object. If the new string specifies a file in the current home directory, the home directory portion of the path is replaced with a tilde (~) character. If the string does not specify a file in the current home directory, this method returns a new string object whose path is unchanged from the path in the current string.
Note that this method only works with file paths. It does not work for string representations of URLs.
For sandboxed apps in OS X, the current home directory is not the same as the user’s home directory. For a sandboxed app, the home directory is the app’s home directory. So if you specified a path of /Users/<current_user>/file.txt for a sandboxed app, the returned path would be unchanged from the original. However, if you specified the same path for an app not in a sandbox, this method would replace the /Users/<current_user> portion of the path with a tilde.
NSFileManagerMBS.stringByAppendingPathComponent(path as string, Component as string) as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 16.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The following table illustrates the effect of this method on a variety of different paths, assuming that aString is supplied as “scratch.tiff”:
Receiver’s String Value | Resulting String |
“/tmp” | “/tmp/scratch.tiff” |
“/tmp/” | “/tmp/scratch.tiff” |
“/” | “/scratch.tiff” |
“” (an empty string) | “scratch.tiff” |
Note that this method only works with file paths (not, for example, string representations of URLs).
NSFileManagerMBS.stringByAppendingPathExtension(path as string, Extension as string) as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 16.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The following table illustrates the effect of this method on a variety of different paths, assuming that ext is supplied as "tiff":
Receiver’s String Value | Resulting String |
“/tmp/scratch.old” | “/tmp/scratch.old.tiff” |
“/tmp/scratch.” | “/tmp/scratch..tiff” |
“/tmp/” | “/tmp.tiff” |
“scratch” | “scratch.tiff” |
Note that adding an extension to "/tmp/" causes the result to be "/tmp.tiff" instead of "/tmp/.tiff". This difference is because a file named ".tiff" is not considered to have an extension, so the string is appended to the last nonempty path component.
Note that this method only works with file paths (not, for example, string representations of URLs).
Special Considerations
Prior to OS X v10.9 this method did not allow you to append file extensions to filenames starting with the tilde character (~).
NSFileManagerMBS.stringByDeletingLastPathComponent(path as string) as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | iCloud | MBS MacCocoa Plugin | 16.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
A new string made by deleting the last path component from the receiver, along with any final path separator. If the receiver represents the root path it is returned unaltered.
The following table illustrates the effect of this method on a variety of different paths:
Receiver’s String Value | Resulting String |
“/tmp/scratch.tiff” | “/tmp” |
“/tmp/lock/” | “/tmp” |
“/tmp/” | “/” |
“/tmp” | “/” |
“/” | “/” |
“scratch.tiff” | “” (an empty string) |
Note that this method only works with file paths (not, for example, string representations of URLs).
The items on this page are in the following plugins: MBS MacCocoa Plugin.