ObjFW
|
A class which provides management for files, e.g. reading contents of directories, deleting files, renaming files, etc. More...
#include <ObjFW/OFFileManager.h>
Instance Methods | |
(OFFileAttributes) | - attributesOfItemAtPath: |
Returns the attributes for the item at the specified path. | |
(OFFileAttributes) | - attributesOfItemAtIRI: |
Returns the attributes for the item at the specified IRI. | |
(void) | - setAttributes:ofItemAtPath: |
Sets the attributes for the item at the specified path. | |
(void) | - setAttributes:ofItemAtIRI: |
Sets the attributes for the item at the specified IRI. | |
(bool) | - fileExistsAtPath: |
Checks whether a file exists at the specified path. | |
(bool) | - fileExistsAtIRI: |
Checks whether a file exists at the specified IRI. | |
(bool) | - directoryExistsAtPath: |
Checks whether a directory exists at the specified path. | |
(bool) | - directoryExistsAtIRI: |
Checks whether a directory exists at the specified IRI. | |
(void) | - createDirectoryAtPath: |
Creates a directory at the specified path. | |
(void) | - createDirectoryAtPath:createParents: |
Creates a directory at the specified path. | |
(void) | - createDirectoryAtIRI: |
Creates a directory at the specified IRI. | |
(void) | - createDirectoryAtIRI:createParents: |
Creates a directory at the specified IRI. | |
(OFArray *) | - contentsOfDirectoryAtPath: |
Returns an array with the items in the specified directory. | |
(OFArray *) | - contentsOfDirectoryAtIRI: |
Returns an array with the IRIs of the items in the specified directory. | |
(OFArray *) | - subpathsOfDirectoryAtPath: |
Returns an array with all subpaths of the specified directory. | |
(void) | - changeCurrentDirectoryPath: |
Changes the current working directory. | |
(void) | - changeCurrentDirectoryIRI: |
Changes the current working directory. | |
(void) | - copyItemAtPath:toPath: |
Copies a file, directory or symbolic link (if supported by the OS). | |
(void) | - copyItemAtIRI:toIRI: |
Copies a file, directory or symbolic link (if supported by the OS). | |
(void) | - moveItemAtPath:toPath: |
Moves an item. | |
(void) | - moveItemAtIRI:toIRI: |
Moves an item. | |
(void) | - removeItemAtPath: |
Removes the item at the specified path. | |
(void) | - removeItemAtIRI: |
Removes the item at the specified IRI. | |
(void) | - linkItemAtPath:toPath: |
Creates a hard link for the specified item. | |
(void) | - linkItemAtIRI:toIRI: |
Creates a hard link for the specified item. | |
(void) | - createSymbolicLinkAtPath:withDestinationPath: |
Creates a symbolic link for an item. | |
(void) | - createSymbolicLinkAtIRI:withDestinationPath: |
Creates a symbolic link for an item. | |
(OFData *) | - extendedAttributeDataForName:ofItemAtPath: |
Returns the extended attribute data for the specified name of the item at the specified path. | |
(OFData *) | - extendedAttributeDataForName:ofItemAtIRI: |
Returns the extended attribute data for the specified name of the item at the specified IRI. | |
(void) | - setExtendedAttributeData:forName:ofItemAtPath: |
Sets the extended attribute data for the specified name of the item at the specified path. | |
(void) | - setExtendedAttributeData:forName:ofItemAtIRI: |
Sets the extended attribute data for the specified name of the item at the specified IRI. | |
(void) | - removeExtendedAttributeForName:ofItemAtPath: |
Removes the extended attribute for the specified name of the item at the specified path. | |
(void) | - removeExtendedAttributeForName:ofItemAtIRI: |
Removes the extended attribute for the specified name of the item at the specified IRI. | |
![]() | |
(instancetype) | - init |
Initializes an already allocated object. | |
(nullable OFMethodSignature *) | - methodSignatureForSelector: |
Returns the method signature for the specified selector. | |
(void) | - dealloc |
Deallocates the object. | |
(void) | - performSelector:afterDelay: |
Performs the specified selector after the specified delay. | |
(void) | - performSelector:withObject:afterDelay: |
Performs the specified selector with the specified object after the specified delay. | |
(void) | - performSelector:withObject:withObject:afterDelay: |
Performs the specified selector with the specified objects after the specified delay. | |
(void) | - performSelector:withObject:withObject:withObject:afterDelay: |
Performs the specified selector with the specified objects after the specified delay. | |
(void) | - performSelector:withObject:withObject:withObject:withObject:afterDelay: |
Performs the specified selector with the specified objects after the specified delay. | |
(void) | - performSelector:onThread:waitUntilDone: |
Performs the specified selector on the specified thread. | |
(void) | - performSelector:onThread:withObject:waitUntilDone: |
Performs the specified selector on the specified thread with the specified object. | |
(void) | - performSelector:onThread:withObject:withObject:waitUntilDone: |
Performs the specified selector on the specified thread with the specified objects. | |
(void) | - performSelector:onThread:withObject:withObject:withObject:waitUntilDone: |
Performs the specified selector on the specified thread with the specified objects. | |
(void) | - performSelector:onThread:withObject:withObject:withObject:withObject:waitUntilDone: |
Performs the specified selector on the specified thread with the specified objects. | |
(void) | - performSelectorOnMainThread:waitUntilDone: |
Performs the specified selector on the main thread. | |
(void) | - performSelectorOnMainThread:withObject:waitUntilDone: |
Performs the specified selector on the main thread with the specified object. | |
(void) | - performSelectorOnMainThread:withObject:withObject:waitUntilDone: |
Performs the specified selector on the main thread with the specified objects. | |
(void) | - performSelectorOnMainThread:withObject:withObject:withObject:waitUntilDone: |
Performs the specified selector on the main thread with the specified objects. | |
(void) | - performSelectorOnMainThread:withObject:withObject:withObject:withObject:waitUntilDone: |
Performs the specified selector on the main thread with the specified objects. | |
(void) | - performSelector:onThread:afterDelay: |
Performs the specified selector on the specified thread after the specified delay. | |
(void) | - performSelector:onThread:withObject:afterDelay: |
Performs the specified selector on the specified thread with the specified object after the specified delay. | |
(void) | - performSelector:onThread:withObject:withObject:afterDelay: |
Performs the specified selector on the specified thread with the specified objects after the specified delay. | |
(void) | - performSelector:onThread:withObject:withObject:withObject:afterDelay: |
Performs the specified selector on the specified thread with the specified objects after the specified delay. | |
(void) | - performSelector:onThread:withObject:withObject:withObject:withObject:afterDelay: |
Performs the specified selector on the specified thread with the specified objects after the specified delay. | |
(nullable id) | - forwardingTargetForSelector: |
This method is called when resolveClassMethod: or resolveInstanceMethod: returned false. It should return a target to which the message should be forwarded. | |
(void) | - doesNotRecognizeSelector: |
Handles messages which are not understood by the receiver. | |
![]() | |
(unsigned long) | - hash |
Returns a hash for the object. | |
(unsigned int) | - retainCount |
Returns the retain count. | |
(bool) | - isProxy |
Returns whether the object is a proxy object. | |
(bool) | - isKindOfClass: |
Returns a boolean whether the object is of the specified kind. | |
(bool) | - isMemberOfClass: |
Returns a boolean whether the object is a member of the specified class. | |
(bool) | - respondsToSelector: |
Returns a boolean whether the object responds to the specified selector. | |
(nullable IMP) | - methodForSelector: |
Returns the implementation for the specified selector. | |
(nullable id) | - performSelector: |
Performs the specified selector. | |
(nullable id) | - performSelector:withObject: |
Performs the specified selector with the specified object. | |
(nullable id) | - performSelector:withObject:withObject: |
Performs the specified selector with the specified objects. | |
(nullable id) | - performSelector:withObject:withObject:withObject: |
Performs the specified selector with the specified objects. | |
(nullable id) | - performSelector:withObject:withObject:withObject:withObject: |
Performs the specified selector with the specified objects. | |
(bool) | - isEqual: |
Checks two objects for equality. | |
(instancetype) | - retain |
Increases the retain count. | |
(void) | - release |
Decreases the retain count. | |
(instancetype) | - autorelease |
Adds the object to the topmost autorelease pool of the thread's autorelease pool stack. | |
(instancetype) | - self |
Returns the receiver. | |
(bool) | - allowsWeakReference |
Returns whether the object allows a weak reference. | |
(bool) | - retainWeakReference |
Retain a weak reference to this object. | |
Class Methods | |
(OFFileManager *) | + defaultManager |
Returns the default file manager. | |
![]() | |
(void) | + load |
A method which is called once when the class is loaded into the runtime. | |
(void) | + unload |
A method which is called when the class is unloaded from the runtime. | |
(void) | + initialize |
A method which is called the moment before the first call to the class is being made. | |
(instancetype) | + alloc |
Allocates memory for an instance of the class and sets up the memory pool for the object. | |
(Class) | + class |
Returns the class. | |
(OFString *) | + className |
Returns the name of the class as a string. | |
(bool) | + isSubclassOfClass: |
Returns a boolean whether the class is a subclass of the specified class. | |
(nullable Class) | + superclass |
Returns the superclass of the class. | |
(bool) | + instancesRespondToSelector: |
Checks whether instances of the class respond to a given selector. | |
(bool) | + conformsToProtocol: |
Checks whether the class conforms to a given protocol. | |
(nullable IMP) | + instanceMethodForSelector: |
Returns the implementation of the instance method for the specified selector. | |
(nullable OFMethodSignature *) | + instanceMethodSignatureForSelector: |
Returns the method signature of the instance method for the specified selector. | |
(OFString *) | + description |
Returns a description for the class, which is usually the class name. | |
(nullable IMP) | + replaceClassMethod:withMethodFromClass: |
Replaces a class method with a class method from another class. | |
(nullable IMP) | + replaceInstanceMethod:withMethodFromClass: |
Replaces an instance method with an instance method from another class. | |
(void) | + inheritMethodsFromClass: |
Adds all methods from the specified class to the class that is the receiver. | |
(bool) | + resolveClassMethod: |
Try to resolve the specified class method. | |
(bool) | + resolveInstanceMethod: |
Try to resolve the specified instance method. | |
(id) | + copy |
Returns the class. | |
Properties | |
OFString * | currentDirectoryPath |
The path of the current working directory. | |
OFIRI * | currentDirectoryIRI |
The IRI of the current working directory. | |
![]() | |
OFString * | className |
The name of the object's class. | |
OFString * | description |
A description for the object. | |
A class which provides management for files, e.g. reading contents of directories, deleting files, renaming files, etc.
- (OFFileAttributes) attributesOfItemAtIRI: | (OFIRI *) | IRI |
Returns the attributes for the item at the specified IRI.
IRI | The IRI to return the attributes for |
OFGetItemAttributesFailedException | Failed to get the attributes of the item |
OFUnsupportedProtocolException | No handler is registered for the IRI's scheme |
- (OFFileAttributes) attributesOfItemAtPath: | (OFString *) | path |
Returns the attributes for the item at the specified path.
path | The path to return the attributes for |
OFGetItemAttributesFailedException | Failed to get the attributes of the item |
- (void) changeCurrentDirectoryIRI: | (OFIRI *) | IRI |
Changes the current working directory.
IRI | The new directory to change to |
OFChangeCurrentDirectoryFailedException | Changing the current working directory failed |
- (void) changeCurrentDirectoryPath: | (OFString *) | path |
Changes the current working directory.
path | The new directory to change to |
OFChangeCurrentDirectoryFailedException | Changing the current working directory failed |
Returns an array with the IRIs of the items in the specified directory.
.
and ..
are not part of the returned array.IRI | The IRI to the directory whose items should be returned |
OFOpenItemFailedException | Opening the directory failed |
OFReadFailedException | Reading from the directory failed |
OFUnsupportedProtocolException | No handler is registered for the IRI's scheme |
Returns an array with the items in the specified directory.
.
and ..
are not part of the returned array.path | The path to the directory whose items should be returned |
OFOpenItemFailedException | Opening the directory failed |
OFReadFailedException | Reading from the directory failed |
Copies a file, directory or symbolic link (if supported by the OS).
The destination IRI must have a full path, which means it must include the name of the item.
If an item already exists, the copy operation fails. This is also the case if a directory is copied and an item already exists in the destination directory.
source | The file, directory or symbolic link to copy |
destination | The destination IRI |
OFCopyItemFailedException | Copying failed |
OFCreateDirectoryFailedException | Creating a destination directory failed |
OFUnsupportedProtocolException | No handler is registered for either of the IRI's scheme |
Copies a file, directory or symbolic link (if supported by the OS).
The destination path must be a full path, which means it must include the name of the item.
If an item already exists, the copy operation fails. This is also the case if a directory is copied and an item already exists in the destination directory.
source | The file, directory or symbolic link to copy |
destination | The destination path |
OFCopyItemFailedException | Copying failed |
OFCreateDirectoryFailedException | Creating a destination directory failed |
- (void) createDirectoryAtIRI: | (OFIRI *) | IRI |
Creates a directory at the specified IRI.
IRI | The IRI of the directory to create |
OFCreateDirectoryFailedException | Creating the directory failed |
OFUnsupportedProtocolException | No handler is registered for the IRI's scheme |
- (void) createDirectoryAtIRI: | (OFIRI *) | IRI | |
createParents: | (bool) | createParents | |
Creates a directory at the specified IRI.
IRI | The IRI of the directory to create |
createParents | Whether to create the parents of the directory |
OFCreateDirectoryFailedException | Creating the directory or one of its parents failed |
OFUnsupportedProtocolException | No handler is registered for the IRI's scheme |
- (void) createDirectoryAtPath: | (OFString *) | path |
Creates a directory at the specified path.
path | The path of the directory to create |
OFCreateDirectoryFailedException | Creating the directory failed |
- (void) createDirectoryAtPath: | (OFString *) | path | |
createParents: | (bool) | createParents | |
Creates a directory at the specified path.
path | The path of the directory to create |
createParents | Whether to create the parents of the directory |
OFCreateDirectoryFailedException | Creating the directory or one of its parents failed |
Creates a symbolic link for an item.
The destination IRI must have a full path, which means it must include the name of the item.
This method is not available for all IRIs.
IRI | The IRI to the item which should symbolically link to the target |
target | The target of the symbolic link |
OFOFCreateSymbolicLinkFailedException | Creating a symbolic link failed |
OFUnsupportedProtocolException | No handler is registered for the IRI's scheme |
Creates a symbolic link for an item.
The destination path must be a full path, which means it must include the name of the item.
This method is not available on some systems.
path | The path to the item which should symbolically link to the target |
target | The target of the symbolic link |
OFCreateSymbolicLinkFailedException | Creating the symbolic link failed |
OFNotImplementedException | Symbolic links are not implemented for the specified IRI |
- (bool) directoryExistsAtIRI: | (OFIRI *) | IRI |
Checks whether a directory exists at the specified IRI.
IRI | The IRI to check |
OFUnsupportedProtocolException | No handler is registered for the IRI's scheme |
- (bool) directoryExistsAtPath: | (OFString *) | path |
Checks whether a directory exists at the specified path.
path | The path to check |
Returns the extended attribute data for the specified name of the item at the specified IRI.
This method is not available for all IRIs.
name | The name of the extended attribute |
IRI | The IRI of the item to return the extended attribute from |
OFGetItemAttributesFailedException | Getting the extended attribute failed |
OFUnsupportedProtocolException | No handler is registered for the IRI's scheme |
OFNotImplementedException | Getting extended attributes is not implemented for the specified item |
Returns the extended attribute data for the specified name of the item at the specified path.
This method is not available on some systems.
name | The name of the extended attribute |
path | The path of the item to return the extended attribute from |
OFGetItemAttributesFailedException | Getting the extended attribute failed |
OFNotImplementedException | Getting extended attributes is not implemented for the specified item |
- (bool) fileExistsAtIRI: | (OFIRI *) | IRI |
Checks whether a file exists at the specified IRI.
IRI | The IRI to check |
OFUnsupportedProtocolException | No handler is registered for the IRI's scheme |
- (bool) fileExistsAtPath: | (OFString *) | path |
Checks whether a file exists at the specified path.
path | The path to check |
Creates a hard link for the specified item.
The destination IRI must have a full path, which means it must include the name of the item.
This method is not available for all IRIs.
source | The IRI to the item for which a link should be created |
destination | The IRI to the item which should link to the source |
OFLinkItemFailedException | Linking the item failed |
OFUnsupportedProtocolException | No handler is registered for the IRI's scheme |
OFNotImplementedException | Hardlinks are not implemented for the specified IRI |
Creates a hard link for the specified item.
The destination path must be a full path, which means it must include the name of the item.
This method is not available on some systems.
source | The path to the item for which a link should be created |
destination | The path to the item which should link to the source |
OFLinkItemFailedException | Linking the item failed |
OFNotImplementedException | Hardlinks are not implemented for the specified IRI |
Moves an item.
The destination IRI must have a full path, which means it must include the name of the item.
If the destination is on a different logical device or uses a different scheme, the source will be copied to the destination using copyItemAtIRI:toIRI: and the source removed using removeItemAtIRI:.
source | The item to rename |
destination | The new name for the item |
OFMoveItemFailedException | Moving failed |
OFCopyItemFailedException | Copying (to move between different devices) failed |
OFRemoveItemFailedException | Removing the source after copying to the destination (to move between different devices) failed |
OFCreateDirectoryFailedException | Creating a destination directory failed |
OFUnsupportedProtocolException | No handler is registered for either of the IRI's scheme |
Moves an item.
The destination path must be a full path, which means it must include the name of the item.
If the destination is on a different logical device, the source will be copied to the destination using copyItemAtPath:toPath: and the source removed using removeItemAtPath:.
source | The item to rename |
destination | The new name for the item |
OFMoveItemFailedException | Moving failed |
OFCopyItemFailedException | Copying (to move between different devices) failed |
OFRemoveItemFailedException | Removing the source after copying to the destination (to move between different devices) failed |
OFCreateDirectoryFailedException | Creating a destination directory failed |
Removes the extended attribute for the specified name of the item at the specified IRI.
This method is not available for all IRIs.
name | The name of the extended attribute to remove |
IRI | The IRI of the item to remove the extended attribute from |
OFSetItemAttributesFailedException | Removing the extended attribute failed |
OFUnsupportedProtocolException | No handler is registered for the IRI's scheme |
OFNotImplementedException | Removing extended attributes is not implemented for the specified item |
Removes the extended attribute for the specified name of the item at the specified path.
This method is not available on some systems.
name | The name of the extended attribute to remove |
path | The path of the item to remove the extended attribute from |
OFSetItemAttributesFailedException | Removing the extended attribute failed |
OFNotImplementedException | Removing extended attributes is not implemented for the specified item |
- (void) removeItemAtIRI: | (OFIRI *) | IRI |
Removes the item at the specified IRI.
If the item at the specified IRI is a directory, it is removed recursively.
IRI | The IRI to the item which should be removed |
OFRemoveItemFailedException | Removing the item failed |
OFUnsupportedProtocolException | No handler is registered for the IRI's scheme |
- (void) removeItemAtPath: | (OFString *) | path |
Removes the item at the specified path.
If the item at the specified path is a directory, it is removed recursively.
path | The path to the item which should be removed |
OFRemoveItemFailedException | Removing the item failed |
- (void) setAttributes: | (OFFileAttributes) | attributes | |
ofItemAtIRI: | (OFIRI *) | IRI | |
Sets the attributes for the item at the specified IRI.
All attributes not part of the dictionary are left unchanged.
attributes | The attributes to set for the specified IRI |
IRI | The IRI of the item to set the attributes for |
OFSetItemAttributesFailedException | Failed to set the attributes of the item |
OFUnsupportedProtocolException | No handler is registered for the IRI's scheme |
OFNotImplementedException | Setting one or more of the specified attributes is not implemented for the specified item |
- (void) setAttributes: | (OFFileAttributes) | attributes | |
ofItemAtPath: | (OFString *) | path | |
Sets the attributes for the item at the specified path.
All attributes not part of the dictionary are left unchanged.
attributes | The attributes to set for the specified path |
path | The path of the item to set the attributes for |
OFSetItemAttributesFailedException | Failed to set the attributes of the item |
OFNotImplementedException | Setting one or more of the specified attributes is not implemented for the specified item |
- (void) setExtendedAttributeData: | (OFData *) | data | |
forName: | (OFString *) | name | |
ofItemAtIRI: | (OFIRI *) | IRI | |
Sets the extended attribute data for the specified name of the item at the specified IRI.
This method is not available for all IRIs.
data | The data for the extended attribute |
name | The name of the extended attribute |
IRI | The IRI of the item to set the extended attribute on |
OFSetItemAttributesFailedException | Setting the extended attribute failed |
OFUnsupportedProtocolException | No handler is registered for the IRI's scheme |
OFNotImplementedException | Setting extended attributes is not implemented for the specified item |
- (void) setExtendedAttributeData: | (OFData *) | data | |
forName: | (OFString *) | name | |
ofItemAtPath: | (OFString *) | path | |
Sets the extended attribute data for the specified name of the item at the specified path.
This method is not available on some systems.
data | The data for the extended attribute |
name | The name of the extended attribute |
path | The path of the item to set the extended attribute on |
OFSetItemAttributesFailedException | Setting the extended attribute failed |
OFNotImplementedException | Setting extended attributes is not implemented for the specified item |
Returns an array with all subpaths of the specified directory.
.
and ..
(of the directory itself or any subdirectory) are not part of the returned array.path | The path to the directory whose subpaths should be returned |
|
readnonatomicassign |
The IRI of the current working directory.
OFGetCurrentDirectoryFailedException | Couldn't get current directory |
|
readnonatomicassign |
The path of the current working directory.
OFGetCurrentDirectoryFailedException | Couldn't get current directory |