One Logo Pool Ball
Foundation · IOS API REFERENCE

FileManager

class · SDK 27.1

class FileManager

Members (64)

get

default

TypeScript
static get default(): FileManager
Swift declaration
class var `default`: FileManager { get }
method · iOS 4.0+

url

TypeScript
urlForInAppropriateForCreate(directory: FileManager_SearchPathDirectory, domain: FileManager_SearchPathDomainMask, url: (string) | null, shouldCreate: boolean): string
Swift declaration
func url(for directory: FileManager.SearchPathDirectory, in domain: FileManager.SearchPathDomainMask, appropriateFor url: URL?, create shouldCreate: Bool) throws -> URL
method · iOS 5.0+

url

TypeScript
urlForPublishingUbiquitousItemAtExpiration(url: string): { $ret: string; $out: { "outDate": (NSDate) | null } }
Swift declaration
func url(forPublishingUbiquitousItemAt url: URL, expiration outDate: AutoreleasingUnsafeMutablePointer<NSDate?>?) throws -> URL

Omit the output parameters from the call. The result contains $ret and $out, with outDate inside $out.

method · iOS 5.0+

url

TypeScript
urlForUbiquityContainerIdentifier(containerIdentifier?: (string) | null): (string) | null
Swift declaration
func url(forUbiquityContainerIdentifier containerIdentifier: String?) -> URL?
method · iOS 4.0+

urls

TypeScript
urls(directory: FileManager_SearchPathDirectory, domainMask: FileManager_SearchPathDomainMask): Array<string>
Swift declaration
func urls(for directory: FileManager.SearchPathDirectory, in domainMask: FileManager.SearchPathDomainMask) -> [URL]
method · iOS 2.0+

attributesOfFileSystem

TypeScript
attributesOfFileSystem(path: string): NativeMap<FileAttributeKey, unknown>
Swift declaration
func attributesOfFileSystem(forPath path: String) throws -> [FileAttributeKey : Any]
method · iOS 2.0+

attributesOfItem

TypeScript
attributesOfItem(path: string): NativeMap<FileAttributeKey, unknown>
Swift declaration
func attributesOfItem(atPath path: String) throws -> [FileAttributeKey : Any]
method

changeCurrentDirectoryPath

TypeScript
changeCurrentDirectoryPath(path: string): boolean
Swift declaration
func changeCurrentDirectoryPath(_ path: String) -> Bool
method

componentsToDisplay

TypeScript
componentsToDisplay(path: string): (Array<string>) | null
Swift declaration
func componentsToDisplay(forPath path: String) -> [String]?
method · iOS 7.0+

containerURL

TypeScript
containerURL(groupIdentifier: string): (string) | null
Swift declaration
func containerURL(forSecurityApplicationGroupIdentifier groupIdentifier: String) -> URL?
method

contents

TypeScript
contents(path: string): (ArrayBuffer) | null
Swift declaration
func contents(atPath path: String) -> Data?
method

contentsEqual

TypeScript
contentsEqual(path1: string, path2: string): boolean
Swift declaration
func contentsEqual(atPath path1: String, andPath path2: String) -> Bool
method · iOS 2.0+

contentsOfDirectory

TypeScript
contentsOfDirectoryAtPath(path: string): Array<string>
Swift declaration
func contentsOfDirectory(atPath path: String) throws -> [String]
method · iOS 4.0+

contentsOfDirectory

TypeScript
contentsOfDirectoryAtIncludingPropertiesForKeysOptions(url: string, keys?: (Array<URLResourceKey>) | null, mask?: FileManager_DirectoryEnumerationOptions): Array<string>
Swift declaration
func contentsOfDirectory(at url: URL, includingPropertiesForKeys keys: [URLResourceKey]?, options mask: FileManager.DirectoryEnumerationOptions = []) throws -> [URL]
method · iOS 2.0+

copyItem

TypeScript
copyItemAtPathToPath(srcPath: string, dstPath: string): void
Swift declaration
func copyItem(atPath srcPath: String, toPath dstPath: String) throws
method · iOS 4.0+

copyItem

TypeScript
copyItemAtTo(srcURL: string, dstURL: string): void
Swift declaration
func copyItem(at srcURL: URL, to dstURL: URL) throws
method · iOS 2.0+

createDirectory

TypeScript
createDirectoryAtPathWithIntermediateDirectoriesAttributes(path: string, createIntermediates: boolean, attributes?: (NativeMap<FileAttributeKey, unknown>) | null): void
Swift declaration
func createDirectory(atPath path: String, withIntermediateDirectories createIntermediates: Bool, attributes: [FileAttributeKey : Any]? = nil) throws
method · iOS 5.0+

createDirectory

TypeScript
createDirectoryAtWithIntermediateDirectoriesAttributes(url: string, createIntermediates: boolean, attributes?: (NativeMap<FileAttributeKey, unknown>) | null): void
Swift declaration
func createDirectory(at url: URL, withIntermediateDirectories createIntermediates: Bool, attributes: [FileAttributeKey : Any]? = nil) throws
method

createFile

TypeScript
createFile(path: string, data?: (ArrayBuffer) | null, attr?: (NativeMap<FileAttributeKey, unknown>) | null): boolean
Swift declaration
func createFile(atPath path: String, contents data: Data?, attributes attr: [FileAttributeKey : Any]? = nil) -> Bool
method · iOS 2.0+

createSymbolicLink

TypeScript
createSymbolicLinkAtPathWithDestinationPath(path: string, destPath: string): void
Swift declaration
func createSymbolicLink(atPath path: String, withDestinationPath destPath: String) throws
method · iOS 5.0+

createSymbolicLink

TypeScript
createSymbolicLinkAtWithDestinationURL(url: string, destURL: string): void
Swift declaration
func createSymbolicLink(at url: URL, withDestinationURL destURL: URL) throws
method · iOS 2.0+

destinationOfSymbolicLink

TypeScript
destinationOfSymbolicLink(path: string): string
Swift declaration
func destinationOfSymbolicLink(atPath path: String) throws -> String
method

displayName

TypeScript
displayName(path: string): string
Swift declaration
func displayName(atPath path: String) -> String
method

enumerator

TypeScript
enumeratorAtPath(path: string): (FileManager_DirectoryEnumerator) | null
Swift declaration
func enumerator(atPath path: String) -> FileManager.DirectoryEnumerator?
method · iOS 5.0+

evictUbiquitousItem

TypeScript
evictUbiquitousItem(url: string): void
Swift declaration
func evictUbiquitousItem(at url: URL) throws
method · iOS 26.0+

fetchLatestRemoteVersionOfItem

TypeScript
fetchLatestRemoteVersionOfItem(url: string, completionHandler: ((arg0: (NSFileVersion) | null, arg1: (NativeError) | null) => void)): void
Swift declaration
func fetchLatestRemoteVersionOfItem(at url: URL) async throws -> NSFileVersion
method

fileExists

TypeScript
fileExistsAtPath(path: string): boolean
Swift declaration
func fileExists(atPath path: String) -> Bool
method

fileExists

TypeScript
fileExistsAtPathIsDirectory(path: string): { $ret: boolean; $out: { "isDirectory": boolean } }
Swift declaration
func fileExists(atPath path: String, isDirectory: UnsafeMutablePointer<ObjCBool>?) -> Bool

Omit the output parameters from the call. The result contains $ret and $out, with isDirectory inside $out.

method

fileSystemRepresentation

TypeScript
fileSystemRepresentation(path: string): SDKHandle
Swift declaration
func fileSystemRepresentation(withPath path: String) -> UnsafePointer<CChar>
method · iOS 11.0+

getFileProviderServicesForItem

TypeScript
getFileProviderServicesForItem(url: string, completionHandler: ((arg0: (NativeMap<NSFileProviderServiceName, NSFileProviderService>) | null, arg1: (NativeError) | null) => void)): void
Swift declaration
func fileProviderServicesForItem(at url: URL) async throws -> [NSFileProviderServiceName : NSFileProviderService]
method · iOS 8.0+

getRelationship

TypeScript
getRelationshipOfInToItemAt(outRelationship: SDKHandle, directory: FileManager_SearchPathDirectory, domainMask: FileManager_SearchPathDomainMask, url: string): void
Swift declaration
func getRelationship(_ outRelationship: UnsafeMutablePointer<FileManager.URLRelationship>, of directory: FileManager.SearchPathDirectory, in domainMask: FileManager.SearchPathDomainMask, toItemAt url: URL) throws
method · iOS 8.0+

getRelationship

TypeScript
getRelationshipOfDirectoryAtToItemAt(outRelationship: SDKHandle, directoryURL: string, otherURL: string): void
Swift declaration
func getRelationship(_ outRelationship: UnsafeMutablePointer<FileManager.URLRelationship>, ofDirectoryAt directoryURL: URL, toItemAt otherURL: URL) throws
init

init

TypeScript
static init(): FileManager
Swift declaration
init()
method

isDeletableFile

TypeScript
isDeletableFile(path: string): boolean
Swift declaration
func isDeletableFile(atPath path: String) -> Bool
method

isExecutableFile

TypeScript
isExecutableFile(path: string): boolean
Swift declaration
func isExecutableFile(atPath path: String) -> Bool
method

isReadableFile

TypeScript
isReadableFile(path: string): boolean
Swift declaration
func isReadableFile(atPath path: String) -> Bool
method · iOS 5.0+

isUbiquitousItem

TypeScript
isUbiquitousItem(url: string): boolean
Swift declaration
func isUbiquitousItem(at url: URL) -> Bool
method

isWritableFile

TypeScript
isWritableFile(path: string): boolean
Swift declaration
func isWritableFile(atPath path: String) -> Bool
method · iOS 2.0+

linkItem

TypeScript
linkItemAtPathToPath(srcPath: string, dstPath: string): void
Swift declaration
func linkItem(atPath srcPath: String, toPath dstPath: String) throws
method · iOS 4.0+

linkItem

TypeScript
linkItemAtTo(srcURL: string, dstURL: string): void
Swift declaration
func linkItem(at srcURL: URL, to dstURL: URL) throws
method · iOS 4.0+

mountedVolumeURLs

TypeScript
mountedVolumeURLs(propertyKeys?: (Array<URLResourceKey>) | null, options?: FileManager_VolumeEnumerationOptions): (Array<string>) | null
Swift declaration
func mountedVolumeURLs(includingResourceValuesForKeys propertyKeys: [URLResourceKey]?, options: FileManager.VolumeEnumerationOptions = []) -> [URL]?
method · iOS 2.0+

moveItem

TypeScript
moveItemAtPathToPath(srcPath: string, dstPath: string): void
Swift declaration
func moveItem(atPath srcPath: String, toPath dstPath: String) throws
method · iOS 4.0+

moveItem

TypeScript
moveItemAtTo(srcURL: string, dstURL: string): void
Swift declaration
func moveItem(at srcURL: URL, to dstURL: URL) throws
method · iOS 26.0+

pauseSyncForUbiquitousItem

TypeScript
pauseSyncForUbiquitousItem(url: string, completionHandler: ((arg0: (NativeError) | null) => void)): void
Swift declaration
func pauseSyncForUbiquitousItem(at url: URL) async throws
method · iOS 2.0+

removeItem

TypeScript
removeItemAtPath(path: string): void
Swift declaration
func removeItem(atPath path: String) throws
method · iOS 4.0+

removeItem

TypeScript
removeItemAt(URL: string): void
Swift declaration
func removeItem(at URL: URL) throws
method · iOS 4.0+

replaceItem

TypeScript
replaceItem(originalItemURL: string, newItemURL: string, backupItemName?: (string) | null, options?: FileManager_ItemReplacementOptions): { $ret: null; $out: { "resultingURL": (NSURL) | null } }
Swift declaration
func replaceItem(at originalItemURL: URL, withItemAt newItemURL: URL, backupItemName: String?, options: FileManager.ItemReplacementOptions = [], resultingItemURL resultingURL: AutoreleasingUnsafeMutablePointer<NSURL?>?) throws

Omit the output parameters from the call. The result contains $ret and $out, with resultingURL inside $out.

method · iOS 26.0+

resumeSyncForUbiquitousItem

TypeScript
resumeSyncForUbiquitousItem(url: string, behavior: NSFileManagerResumeSyncBehavior, completionHandler: ((arg0: (NativeError) | null) => void)): void
Swift declaration
func resumeSyncForUbiquitousItem(at url: URL, with behavior: NSFileManagerResumeSyncBehavior) async throws
method · iOS 2.0+

setAttributes

TypeScript
setAttributes(attributes: NativeMap<FileAttributeKey, unknown>, path: string): void
Swift declaration
func setAttributes(_ attributes: [FileAttributeKey : Any], ofItemAtPath path: String) throws
method · iOS 5.0+

setUbiquitous

TypeScript
setUbiquitous(flag: boolean, url: string, destinationURL: string): void
Swift declaration
func setUbiquitous(_ flag: Bool, itemAt url: URL, destinationURL: URL) throws
method · iOS 5.0+

startDownloadingUbiquitousItem

TypeScript
startDownloadingUbiquitousItem(url: string): void
Swift declaration
func startDownloadingUbiquitousItem(at url: URL) throws
method

string

TypeScript
string(str: SDKHandle, len: number): string
Swift declaration
func string(withFileSystemRepresentation str: UnsafePointer<CChar>, length len: Int) -> String
method

subpaths

TypeScript
subpaths(path: string): (Array<string>) | null
Swift declaration
func subpaths(atPath path: String) -> [String]?
method · iOS 2.0+

subpathsOfDirectory

TypeScript
subpathsOfDirectory(path: string): Array<string>
Swift declaration
func subpathsOfDirectory(atPath path: String) throws -> [String]
method · iOS 11.0+

trashItem

TypeScript
trashItem(url: string): { $ret: null; $out: { "outResultingURL": (NSURL) | null } }
Swift declaration
func trashItem(at url: URL, resultingItemURL outResultingURL: AutoreleasingUnsafeMutablePointer<NSURL?>?) throws

Omit the output parameters from the call. The result contains $ret and $out, with outResultingURL inside $out.

method · iOS 26.0+

uploadLocalVersionOfUbiquitousItem

TypeScript
uploadLocalVersionOfUbiquitousItem(url: string, conflictResolutionPolicy: NSFileManagerUploadLocalVersionConflictPolicy, completionHandler: ((arg0: (NSFileVersion) | null, arg1: (NativeError) | null) => void)): void
Swift declaration
func uploadLocalVersionOfUbiquitousItem(at url: URL, withConflictResolutionPolicy conflictResolutionPolicy: NSFileManagerUploadLocalVersionConflictPolicy) async throws -> NSFileVersion
get

currentDirectoryPath

TypeScript
get currentDirectoryPath(): string
Swift declaration
var currentDirectoryPath: String { get }
get · iOS 2.0+

delegate

TypeScript
get delegate(): (SDKHandle) | null
Swift declaration
unowned(unsafe) var delegate: (any FileManagerDelegate)? { get set }
set · iOS 2.0+

delegate

TypeScript
set delegate(value: (Implements<FileManagerDelegate> | SDKHandle) | null)
Swift declaration
unowned(unsafe) var delegate: (any FileManagerDelegate)? { get set }
get · iOS 10.0+

temporaryDirectory

TypeScript
get temporaryDirectory(): string
Swift declaration
var temporaryDirectory: URL { get }
get · iOS 6.0+

ubiquityIdentityToken

TypeScript
get ubiquityIdentityToken(): ((SDKHandle) & (SDKHandle) & (SDKHandle)) | null
Swift declaration
@NSCopying var ubiquityIdentityToken: (any NSCoding & NSCopying & NSObjectProtocol)? { get }
method · iOS 8.0+

enumerator

TypeScript
enumeratorAtIncludingPropertiesForKeysOptions(url: string, keys?: (Array<URLResourceKey>) | null, mask?: FileManager_DirectoryEnumerationOptions): (FileManager_DirectoryEnumerator) | null
Swift declaration
@nonobjc func enumerator(at url: URL, includingPropertiesForKeys keys: [URLResourceKey]?, options mask: FileManager.DirectoryEnumerationOptions = [], errorHandler handler: ((URL, any Error) -> Bool)? = nil) -> FileManager.DirectoryEnumerator?

Returns a directory enumerator object that can be used to perform a deep enumeration of the directory at the specified URL. Because the enumeration is deep — that is, it lists the contents of all subdirectories — this enumerator object is useful for performing actions that involve large file-system subtrees. If the method is passed a directory on which another file system is mounted (a mount point), it traverses the mount point. This method does not resolve symbolic links or mount points encountered in the enumeration process, nor does it recurse through them if they point to a directory. The ``FileManager/DirectoryEnumerator`` class has methods for skipping descendants of the existing path and for returning the number of levels deep the current object is in the directory hierarchy being enumerated (where the directory passed to this method is considered to be level 0). - Parameters: - url: The location of the directory for which you want an enumeration. This URL must not be a symbolic link that points to the desired directory. - keys: An array of keys that identify the properties that you want pre-fetched for each item in the enumeration. You may specify `nil`. - mask: Options for the enumeration. - handler: An optional error handler block for the file manager to call when an error occurs. The handler block should return `true` if you want the enumeration to continue or `false` if you want it to stop. - Returns: A directory enumerator object that enumerates the contents of the directory at `url`. If `url` is a filename, the method returns an enumerator object that enumerates no files — the first call to `nextObject()` returns `nil`.

method · iOS 8.0+

replaceItemAt

TypeScript
replaceItemAt(originalItemURL: string, newItemURL: string, backupItemName?: (string) | null, options?: FileManager_ItemReplacementOptions): (string) | null
Swift declaration
func replaceItemAt(_ originalItemURL: URL, withItemAt newItemURL: URL, backupItemName: String? = nil, options: FileManager.ItemReplacementOptions = []) throws -> URL?

Replaces the contents of the item at the specified URL in a manner that ensures no data loss occurs. By default, the creation date, permissions, Finder label and color, and Spotlight comments of the original item are preserved on the new item. You can configure which metadata is preserved using the `options` parameter. This method works only when the `originalItemURL` and `newItemURL` parameters are located on the same volume. Attempting to call this method by passing parameters that have locations on different volumes results in an error. - Parameters: - originalItemURL: The item containing the content you want to replace. - newItemURL: The item containing the new content for `originalItemURL`. It is recommended that you put this item in a temporary directory as provided by the OS. - backupItemName: If provided, the name used to create a backup of the original item. The backup is placed in the same directory as the original item. - options: The options to use during the replacement. Typically, you pass ``FileManager/ItemReplacementOptions/usingNewMetadataOnly``. - Returns: The URL of the new item. If no new file system object is required, the URL object may be the same passed to `originalItemURL`.

method · iOS 8.0+

replaceItemAtURL

TypeScript
replaceItemAtURL(originalItemURL: NSURL, newItemURL: NSURL, backupItemName?: (string) | null, options?: FileManager_ItemReplacementOptions): (NSURL) | null
Swift declaration
func replaceItemAtURL(originalItemURL: NSURL, withItemAtURL newItemURL: NSURL, backupItemName: String? = nil, options: FileManager.ItemReplacementOptions = []) throws -> NSURL?

Replaces the contents of the item at the specified URL in a manner that ensures no data loss occurs. @DeprecationSummary { Use ``replaceItemAt(_:withItemAt:backupItemName:options:)-4210g`` instead. } - Parameters: - originalItemURL: The item containing the content you want to replace. - newItemURL: The item containing the new content for `originalItemURL`. - backupItemName: If provided, the name used to create a backup of the original item. - options: The options to use during the replacement. - Returns: The URL of the new item, or `nil`.

Skipped declarations

No declarations were skipped in this snapshot.

All Foundation types →