ObjFW
Instance Methods | Class Methods | Properties | List of all members
OFFileManager Class Reference

A class which provides management for files, e.g. reading contents of directories, deleting files, renaming files, etc. More...

#import <ObjFW/OFFileManager.h>

Inheritance diagram for OFFileManager:
Inheritance graph
[legend]
Collaboration diagram for OFFileManager:
Collaboration graph
[legend]

Instance Methods

(of_file_attributes_t- attributesOfItemAtPath:
 Returns the attributes for the item at the specified path. More...
 
(of_file_attributes_t- attributesOfItemAtURL:
 Returns the attributes for the item at the specified URL. More...
 
(void) - setAttributes:ofItemAtPath:
 Sets the attributes for the item at the specified path. More...
 
(void) - setAttributes:ofItemAtURL:
 Sets the attributes for the item at the specified URL. More...
 
(bool) - fileExistsAtPath:
 Checks whether a file exists at the specified path. More...
 
(bool) - fileExistsAtURL:
 Checks whether a file exists at the specified URL. More...
 
(bool) - directoryExistsAtPath:
 Checks whether a directory exists at the specified path. More...
 
(bool) - directoryExistsAtURL:
 Checks whether a directory exists at the specified URL. More...
 
(void) - createDirectoryAtPath:
 Creates a directory at the specified path. More...
 
(void) - createDirectoryAtPath:createParents:
 Creates a directory at the specified path. More...
 
(void) - createDirectoryAtURL:
 Creates a directory at the specified URL. More...
 
(void) - createDirectoryAtURL:createParents:
 Creates a directory at the specified URL. More...
 
(OFArray *) - contentsOfDirectoryAtPath:
 Returns an array with the items in the specified directory. More...
 
(OFArray *) - contentsOfDirectoryAtURL:
 Returns an array with the items in the specified directory. More...
 
(void) - changeCurrentDirectoryPath:
 Changes the current working directory. More...
 
(void) - changeCurrentDirectoryURL:
 Changes the current working directory. More...
 
(void) - copyItemAtPath:toPath:
 Copies a file, directory or symbolic link (if supported by the OS). More...
 
(void) - copyItemAtURL:toURL:
 Copies a file, directory or symbolic link (if supported by the OS). More...
 
(void) - moveItemAtPath:toPath:
 Moves an item. More...
 
(void) - moveItemAtURL:toURL:
 Moves an item. More...
 
(void) - removeItemAtPath:
 Removes the item at the specified path. More...
 
(void) - removeItemAtURL:
 Removes the item at the specified URL. More...
 
(void) - linkItemAtPath:toPath:
 Creates a hard link for the specified item. More...
 
(void) - linkItemAtURL:toURL:
 Creates a hard link for the specified item. More...
 
(void) - createSymbolicLinkAtPath:withDestinationPath:
 Creates a symbolic link for an item. More...
 
(void) - createSymbolicLinkAtURL:withDestinationPath:
 Creates a symbolic link for an item. More...
 
- Instance Methods inherited from OFObject
(instancetype) - init
 Initializes an already allocated object. More...
 
(nullable OFMethodSignature *) - methodSignatureForSelector:
 Returns the method signature for the specified selector. More...
 
(void) - dealloc
 Deallocates the object. More...
 
(void) - performSelector:afterDelay:
 Performs the specified selector after the specified delay. More...
 
(void) - performSelector:withObject:afterDelay:
 Performs the specified selector with the specified object after the specified delay. More...
 
(void) - performSelector:withObject:withObject:afterDelay:
 Performs the specified selector with the specified objects after the specified delay. More...
 
(void) - performSelector:withObject:withObject:withObject:afterDelay:
 Performs the specified selector with the specified objects after the specified delay. More...
 
(void) - performSelector:withObject:withObject:withObject:withObject:afterDelay:
 Performs the specified selector with the specified objects after the specified delay. More...
 
(void) - performSelector:onThread:waitUntilDone:
 Performs the specified selector on the specified thread. More...
 
(void) - performSelector:onThread:withObject:waitUntilDone:
 Performs the specified selector on the specified thread with the specified object. More...
 
(void) - performSelector:onThread:withObject:withObject:waitUntilDone:
 Performs the specified selector on the specified thread with the specified objects. More...
 
(void) - performSelector:onThread:withObject:withObject:withObject:waitUntilDone:
 Performs the specified selector on the specified thread with the specified objects. More...
 
(void) - performSelector:onThread:withObject:withObject:withObject:withObject:waitUntilDone:
 Performs the specified selector on the specified thread with the specified objects. More...
 
(void) - performSelectorOnMainThread:waitUntilDone:
 Performs the specified selector on the main thread. More...
 
(void) - performSelectorOnMainThread:withObject:waitUntilDone:
 Performs the specified selector on the main thread with the specified object. More...
 
(void) - performSelectorOnMainThread:withObject:withObject:waitUntilDone:
 Performs the specified selector on the main thread with the specified objects. More...
 
(void) - performSelectorOnMainThread:withObject:withObject:withObject:waitUntilDone:
 Performs the specified selector on the main thread with the specified objects. More...
 
(void) - performSelectorOnMainThread:withObject:withObject:withObject:withObject:waitUntilDone:
 Performs the specified selector on the main thread with the specified objects. More...
 
(void) - performSelector:onThread:afterDelay:
 Performs the specified selector on the specified thread after the specified delay. More...
 
(void) - performSelector:onThread:withObject:afterDelay:
 Performs the specified selector on the specified thread with the specified object after the specified delay. More...
 
(void) - performSelector:onThread:withObject:withObject:afterDelay:
 Performs the specified selector on the specified thread with the specified objects after the specified delay. More...
 
(void) - performSelector:onThread:withObject:withObject:withObject:afterDelay:
 Performs the specified selector on the specified thread with the specified objects after the specified delay. More...
 
(void) - performSelector:onThread:withObject:withObject:withObject:withObject:afterDelay:
 Performs the specified selector on the specified thread with the specified objects after the specified delay. More...
 
(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. More...
 
(void) - doesNotRecognizeSelector:
 Handles messages which are not understood by the receiver. More...
 
- Instance Methods inherited from <OFObject>
(unsigned long) - hash
 Returns a 32 bit hash for the object. More...
 
(unsigned int) - retainCount
 Returns the retain count. More...
 
(bool) - isProxy
 Returns whether the object is a proxy object. More...
 
(bool) - allowsWeakReference
 Returns whether the object allows weak references. More...
 
(bool) - isKindOfClass:
 Returns a boolean whether the object of the specified kind. More...
 
(bool) - isMemberOfClass:
 Returns a boolean whether the object is a member of the specified class. More...
 
(bool) - respondsToSelector:
 Returns a boolean whether the object responds to the specified selector. More...
 
(nullable IMP- methodForSelector:
 Returns the implementation for the specified selector. More...
 
(nullable id- performSelector:
 Performs the specified selector. More...
 
(nullable id- performSelector:withObject:
 Performs the specified selector with the specified object. More...
 
(nullable id- performSelector:withObject:withObject:
 Performs the specified selector with the specified objects. More...
 
(nullable id- performSelector:withObject:withObject:withObject:
 Performs the specified selector with the specified objects. More...
 
(nullable id- performSelector:withObject:withObject:withObject:withObject:
 Performs the specified selector with the specified objects. More...
 
(bool) - isEqual:
 Checks two objects for equality. More...
 
(instancetype) - retain
 Increases the retain count. More...
 
(void) - release
 Decreases the retain count. More...
 
(instancetype) - autorelease
 Adds the object to the topmost autorelease pool of the thread's autorelease pool stack. More...
 
(instancetype) - self
 Returns the receiver. More...
 
(bool) - retainWeakReference
 Retain a weak reference to this object. More...
 

Class Methods

(OFFileManager *) + defaultManager
 Returns the default file manager.
 
- Class Methods inherited from OFObject
(void) + load
 A method which is called once when the class is loaded into the runtime. More...
 
(void) + unload
 A method which is called when the class is unloaded from the runtime. More...
 
(void) + initialize
 A method which is called the moment before the first call to the class is being made. More...
 
(instancetype) + alloc
 Allocates memory for an instance of the class and sets up the memory pool for the object. More...
 
(instancetype) + new
 Calls alloc on self and then init on the returned object. More...
 
(Class+ class
 Returns the class. More...
 
(OFString *) + className
 Returns the name of the class as a string. More...
 
(bool) + isSubclassOfClass:
 Returns a boolean whether the class is a subclass of the specified class. More...
 
(nullable Class+ superclass
 Returns the superclass of the class. More...
 
(bool) + instancesRespondToSelector:
 Checks whether instances of the class respond to a given selector. More...
 
(bool) + conformsToProtocol:
 Checks whether the class conforms to a given protocol. More...
 
(nullable IMP+ instanceMethodForSelector:
 Returns the implementation of the instance method for the specified selector. More...
 
(nullable OFMethodSignature *) + instanceMethodSignatureForSelector:
 Returns the method signature of the instance method for the specified selector. More...
 
(OFString *) + description
 Returns a description for the class, which is usually the class name. More...
 
(nullable IMP+ replaceClassMethod:withMethodFromClass:
 Replaces a class method with a class method from another class. More...
 
(nullable IMP+ replaceInstanceMethod:withMethodFromClass:
 Replaces an instance method with an instance method from another class. More...
 
(void) + inheritMethodsFromClass:
 Adds all methods from the specified class to the class that is the receiver. More...
 
(bool) + resolveClassMethod:
 Try to resolve the specified class method. More...
 
(bool) + resolveInstanceMethod:
 Try to resolve the specified instance method. More...
 
(id+ copy
 Returns the class. More...
 

Properties

OFStringcurrentDirectoryPath
 The path of the current working directory.
 
OFURLcurrentDirectoryURL
 The URL of the current working directory.
 
- Properties inherited from OFObject
OFStringclassName
 The name of the object's class.
 
OFStringdescription
 A description for the object. More...
 
OFStringstringBySerializing
 The object serialized as a string.
 

Detailed Description

A class which provides management for files, e.g. reading contents of directories, deleting files, renaming files, etc.

Method Documentation

◆ attributesOfItemAtPath:

- (of_file_attributes_t) attributesOfItemAtPath: (OFString *)  path

Returns the attributes for the item at the specified path.

Parameters
pathThe path to return the attributes for
Returns
A dictionary of attributes for the specified path, with the keys of type of_file_attribute_key_t

◆ attributesOfItemAtURL:

- (of_file_attributes_t) attributesOfItemAtURL: (OFURL *)  URL

Returns the attributes for the item at the specified URL.

Parameters
URLThe URL to return the attributes for
Returns
A dictionary of attributes for the specified URL, with the keys of type of_file_attribute_key_t

◆ changeCurrentDirectoryPath:

- (void) changeCurrentDirectoryPath: (OFString *)  path

Changes the current working directory.

Parameters
pathThe new directory to change to

◆ changeCurrentDirectoryURL:

- (void) changeCurrentDirectoryURL: (OFURL *)  URL

Changes the current working directory.

Parameters
URLThe new directory to change to

◆ contentsOfDirectoryAtPath:

- (OFArray *) contentsOfDirectoryAtPath: (OFString *)  path

Returns an array with the items in the specified directory.

Note
. and .. are not part of the returned array.
Parameters
pathThe path to the directory whose items should be returned
Returns
An array of OFString with the items in the specified directory

◆ contentsOfDirectoryAtURL:

- (OFArray *) contentsOfDirectoryAtURL: (OFURL *)  URL

Returns an array with the items in the specified directory.

Note
. and .. are not part of the returned array.
Parameters
URLThe URL to the directory whose items should be returned
Returns
An array of OFString with the items in the specified directory

◆ copyItemAtPath:toPath:

- (void) copyItemAtPath: (OFString *)  source
toPath: (OFString *)  destination 

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.

Parameters
sourceThe file, directory or symbolic link to copy
destinationThe destination path

◆ copyItemAtURL:toURL:

- (void) copyItemAtURL: (OFURL *)  source
toURL: (OFURL *)  destination 

Copies a file, directory or symbolic link (if supported by the OS).

The destination URL 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.

Parameters
sourceThe file, directory or symbolic link to copy
destinationThe destination URL

◆ createDirectoryAtPath:

- (void) createDirectoryAtPath: (OFString *)  path

Creates a directory at the specified path.

Parameters
pathThe path of the directory to create

◆ createDirectoryAtPath:createParents:

- (void) createDirectoryAtPath: (OFString *)  path
createParents: (bool)  createParents 

Creates a directory at the specified path.

Parameters
pathThe path of the directory to create
createParentsWhether to create the parents of the directory

◆ createDirectoryAtURL:

- (void) createDirectoryAtURL: (OFURL *)  URL

Creates a directory at the specified URL.

Parameters
URLThe URL of the directory to create

◆ createDirectoryAtURL:createParents:

- (void) createDirectoryAtURL: (OFURL *)  URL
createParents: (bool)  createParents 

Creates a directory at the specified URL.

Parameters
URLThe URL of the directory to create
createParentsWhether to create the parents of the directory

◆ createSymbolicLinkAtPath:withDestinationPath:

- (void) createSymbolicLinkAtPath: (OFString *)  path
withDestinationPath: (OFString *)  target 

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.

Note
On Windows, this requires at least Windows Vista and administrator privileges!
Parameters
pathThe path to the item which should symbolically link to the target
targetThe target of the symbolic link

◆ createSymbolicLinkAtURL:withDestinationPath:

- (void) createSymbolicLinkAtURL: (OFURL *)  URL
withDestinationPath: (OFString *)  target 

Creates a symbolic link for an item.

The destination uRL must have a full path, which means it must include the name of the item.

This method is not available for all URLs.

Note
On Windows, this requires at least Windows Vista and administrator privileges!
Parameters
URLThe URL to the item which should symbolically link to the target
targetThe target of the symbolic link

◆ directoryExistsAtPath:

- (bool) directoryExistsAtPath: (OFString *)  path

Checks whether a directory exists at the specified path.

Parameters
pathThe path to check
Returns
A boolean whether there is a directory at the specified path

◆ directoryExistsAtURL:

- (bool) directoryExistsAtURL: (OFURL *)  URL

Checks whether a directory exists at the specified URL.

Parameters
URLThe URL to check
Returns
A boolean whether there is a directory at the specified URL

◆ fileExistsAtPath:

- (bool) fileExistsAtPath: (OFString *)  path

Checks whether a file exists at the specified path.

Parameters
pathThe path to check
Returns
A boolean whether there is a file at the specified path

◆ fileExistsAtURL:

- (bool) fileExistsAtURL: (OFURL *)  URL

Checks whether a file exists at the specified URL.

Parameters
URLThe URL to check
Returns
A boolean whether there is a file at the specified URL

◆ linkItemAtPath:toPath:

- (void) linkItemAtPath: (OFString *)  source
toPath: (OFString *)  destination 

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.

Parameters
sourceThe path to the item for which a link should be created
destinationThe path to the item which should link to the source

◆ linkItemAtURL:toURL:

- (void) linkItemAtURL: (OFURL *)  source
toURL: (OFURL *)  destination 

Creates a hard link for the specified item.

The destination URL must have a full path, which means it must include the name of the item.

This method is not available for all URLs.

Parameters
sourceThe URL to the item for which a link should be created
destinationThe URL to the item which should link to the source

◆ moveItemAtPath:toPath:

- (void) moveItemAtPath: (OFString *)  source
toPath: (OFString *)  destination 

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:.

Parameters
sourceThe item to rename
destinationThe new name for the item

◆ moveItemAtURL:toURL:

- (void) moveItemAtURL: (OFURL *)  source
toURL: (OFURL *)  destination 

Moves an item.

The destination URL 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 copyItemAtURL:toURL: and the source removed using removeItemAtURL:.

Parameters
sourceThe item to rename
destinationThe new name for the item

◆ removeItemAtPath:

- (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.

Parameters
pathThe path to the item which should be removed

◆ removeItemAtURL:

- (void) removeItemAtURL: (OFURL *)  URL

Removes the item at the specified URL.

If the item at the specified URL is a directory, it is removed recursively.

Parameters
URLThe URL to the item which should be removed

◆ setAttributes:ofItemAtPath:

- (void) setAttributes: (of_file_attributes_t attributes
ofItemAtPath: (OFString *)  path 

Sets the attributes for the item at the specified path.

All attributes not part of the dictionary are left unchanged.

Parameters
attributesThe attributes to set for the specified path
pathThe path of the item to set the attributes for

◆ setAttributes:ofItemAtURL:

- (void) setAttributes: (of_file_attributes_t attributes
ofItemAtURL: (OFURL *)  URL 

Sets the attributes for the item at the specified URL.

All attributes not part of the dictionary are left unchanged.

Parameters
attributesThe attributes to set for the specified URL
URLThe URL of the item to set the attributes for

The documentation for this class was generated from the following files: