ObjFW
Loading...
Searching...
No Matches
OFIRIHandler Class Reference

A handler for an IRI scheme. More...

#include <ObjFW/ObjFW.h>

Inheritance diagram for OFIRIHandler:
OFObject <OFObject>

Instance Methods

(instancetype) - initWithScheme:
 Initializes the handler for the specified scheme.
 
(OFStream *) - openItemAtIRI:mode:
 Opens the item at the specified IRI.
 
(OFFileAttributes- attributesOfItemAtIRI:
 Returns the attributes for the item at the specified IRI.
 
(void) - setAttributes:ofItemAtIRI:
 Sets the attributes for the item at the specified IRI.
 
(bool) - fileExistsAtIRI:
 Checks whether a file exists at the specified IRI.
 
(bool) - directoryExistsAtIRI:
 Checks whether a directory exists at the specified IRI.
 
(void) - createDirectoryAtIRI:
 Creates a directory at the specified IRI.
 
(OFArray *) - contentsOfDirectoryAtIRI:
 Returns an array with the IRIs of the items in the specified directory.
 
(void) - removeItemAtIRI:
 Removes the item at the specified IRI.
 
(void) - linkItemAtIRI:toIRI:
 Creates a hard link for the specified item.
 
(void) - createSymbolicLinkAtIRI:withDestinationPath:
 Creates a symbolic link for an item.
 
(bool) - copyItemAtIRI:toIRI:
 Tries to efficiently copy an item. If a copy would only be possible by reading the entire item and then writing it, it returns false.
 
(bool) - moveItemAtIRI:toIRI:
 Tries to efficiently move an item. If a move would only be possible by copying the source and deleting it, it returns false.
 
(OFData *) - extendedAttributeDataForName:ofItemAtIRI:
 Returns the extended attribute data for the specified name of the item at the specified IRI.
 
(void) - getExtendedAttributeData:andType:forName:ofItemAtIRI:
 Gets the extended attribute data and type for the specified name of the item at the specified IRI.
 
(void) - setExtendedAttributeData:forName:ofItemAtIRI:
 Sets the extended attribute data for the specified name of the item at the specified IRI.
 
(void) - setExtendedAttributeData:andType:forName:ofItemAtIRI:
 Sets the extended attribute data and type for the specified name of the item at the specified IRI.
 
(void) - removeExtendedAttributeForName:ofItemAtIRI:
 Removes the extended attribute for the specified name of the item at the specified IRI.
 
- Instance Methods inherited from OFObject
(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.
 
- Instance Methods inherited from <OFObject>
(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

(bool) + registerClass:forScheme:
 Registers the specified class as the handler for the specified scheme.
 
(OFIRIHandler *) + handlerForIRI:
 Returns the handler for the specified IRI.
 
(OFStream *) + openItemAtIRI:mode:
 Opens the item at the specified IRI.
 
- Class Methods inherited from OFObject
(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

OFStringscheme
 The scheme this OFIRIHandler handles.
 
- Properties inherited from OFObject
OFStringclassName
 The name of the object's class.
 
OFStringdescription
 A description for the object.
 

Detailed Description

A handler for an IRI scheme.

Method Documentation

◆ attributesOfItemAtIRI:

- (OFFileAttributes) attributesOfItemAtIRI: (OFIRI *) IRI

Returns the attributes for the item at the specified IRI.

Parameters
IRIThe IRI to return the attributes for
Returns
A dictionary of attributes for the specified IRI, with the keys of type OFFileAttributeKey
Exceptions
OFGetItemAttributesFailedExceptionFailed to get the attributes of the item
OFUnsupportedProtocolExceptionThe handler cannot handle the IRI's scheme

◆ contentsOfDirectoryAtIRI:

- (OFArray *) contentsOfDirectoryAtIRI: (OFIRI *) IRI

Returns an array with the IRIs of the items in the specified directory.

Note
. and .. are not part of the returned array.
Parameters
IRIThe IRI to the directory whose items should be returned
Returns
An array with the IRIs of the items in the specified directory
Exceptions
OFOpenItemFailedExceptionOpening the directory failed
OFReadFailedExceptionReading from the directory failed
OFUnsupportedProtocolExceptionThe handler cannot handle the IRI's scheme

◆ copyItemAtIRI:toIRI:

- (bool) copyItemAtIRI: (OFIRI *) source
toIRI: (OFIRI *) destination 

Tries to efficiently copy an item. If a copy would only be possible by reading the entire item and then writing it, it returns false.

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.

Parameters
sourceThe file, directory or symbolic link to copy
destinationThe destination IRI
Returns
True if an efficient copy was performed, false if an efficient copy was not possible. Note that errors while performing a copy are reported via exceptions and not by returning false!
Exceptions
OFCopyItemFailedExceptionCopying failed
OFUnsupportedProtocolExceptionThe handler cannot handle the IRI's scheme

◆ createDirectoryAtIRI:

- (void) createDirectoryAtIRI: (OFIRI *) IRI

Creates a directory at the specified IRI.

Parameters
IRIThe IRI of the directory to create
Exceptions
OFCreateDirectoryFailedExceptionCreating the directory failed
OFUnsupportedProtocolExceptionThe handler cannot handle the IRI's scheme

◆ createSymbolicLinkAtIRI:withDestinationPath:

- (void) createSymbolicLinkAtIRI: (OFIRI *) IRI
withDestinationPath: (OFString *) target 

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.

Note
On Windows, this requires at least Windows Vista and administrator privileges!
Parameters
IRIThe IRI to the item which should symbolically link to the target
targetThe target of the symbolic link
Exceptions
OFCreateSymbolicLinkFailedCreating a symbolic link failed
OFUnsupportedProtocolExceptionThe handler cannot handle the IRI's scheme

◆ directoryExistsAtIRI:

- (bool) directoryExistsAtIRI: (OFIRI *) IRI

Checks whether a directory exists at the specified IRI.

Parameters
IRIThe IRI to check
Returns
A boolean whether there is a directory at the specified IRI
Exceptions
OFUnsupportedProtocolExceptionThe handler cannot handle the IRI's scheme

◆ extendedAttributeDataForName:ofItemAtIRI:

- (OFData *) extendedAttributeDataForName: (OFString *) name
ofItemAtIRI: (OFIRI *) IRI 

Returns the extended attribute data for the specified name of the item at the specified IRI.

Deprecated
Use getExtendedAttributeData:andType:forName:ofItemAtIRI: instead.

This method is not available for all IRIs.

Parameters
nameThe name of the extended attribute
IRIThe IRI of the item to return the extended attribute from
Returns
The extended attribute data for the specified name of the item at the specified IRI
Exceptions
OFGetItemAttributesFailedExceptionGetting the extended attribute failed
OFUnsupportedProtocolExceptionThe handler cannot handle the IRI's scheme
OFNotImplementedExceptionGetting extended attributes is not implemented for the specified item

◆ fileExistsAtIRI:

- (bool) fileExistsAtIRI: (OFIRI *) IRI

Checks whether a file exists at the specified IRI.

Parameters
IRIThe IRI to check
Returns
A boolean whether there is a file at the specified IRI
Exceptions
OFUnsupportedProtocolExceptionThe handler cannot handle the IRI's scheme

◆ getExtendedAttributeData:andType:forName:ofItemAtIRI:

- (void) getExtendedAttributeData: (OFData * *) data
andType: (id *) type
forName: (OFString *) name
ofItemAtIRI: (OFIRI *) IRI 

Gets the extended attribute data and type for the specified name of the item at the specified IRI.

This method is not available for all IRIs.

Parameters
dataA pointer to OFData * that gets set to the data of the extended attribute
typeA pointer to id that gets set to the type of the extended attribute, if not NULL. Gets set to nil if the extended attribute has no type. The type of the type depends on the IRI handler.
nameThe name of the extended attribute
IRIThe IRI of the item to return the extended attribute from
Exceptions
OFGetItemAttributesFailedExceptionGetting the extended attribute failed
OFUnsupportedProtocolExceptionThe handler cannot handle the IRI's scheme
OFNotImplementedExceptionGetting extended attributes is not implemented for the specified item

◆ handlerForIRI:

+ (OFIRIHandler *) handlerForIRI: (OFIRI *) IRI

Returns the handler for the specified IRI.

Returns
The handler for the specified IRI.
Exceptions
OFUnsupportedProtocolExceptionThe specified IRI is not supported

◆ initWithScheme:

- (instancetype) initWithScheme: (OFString *) scheme

Initializes the handler for the specified scheme.

Parameters
schemeThe scheme to initialize for
Returns
An initialized IRI handler

◆ linkItemAtIRI:toIRI:

- (void) linkItemAtIRI: (OFIRI *) source
toIRI: (OFIRI *) destination 

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.

Parameters
sourceThe IRI to the item for which a link should be created
destinationThe IRI to the item which should link to the source
Exceptions
OFLinkItemFailedExceptionLinking the item failed
OFUnsupportedProtocolExceptionThe handler cannot handle the scheme of one of the IRIs
OFNotImplementedExceptionHardlinks are not implemented for the specified IRI

◆ moveItemAtIRI:toIRI:

- (bool) moveItemAtIRI: (OFIRI *) source
toIRI: (OFIRI *) destination 

Tries to efficiently move an item. If a move would only be possible by copying the source and deleting it, it returns false.

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, an efficient move is not possible and false is returned.

Parameters
sourceThe item to rename
destinationThe new name for the item
Returns
True if an efficient move was performed, false if an efficient move was not possible. Note that errors while performing a move are reported via exceptions and not by returning false!
Exceptions
OFMoveItemFailedExceptionMoving failed
OFUnsupportedProtocolExceptionThe handler cannot handle the IRI's scheme

◆ openItemAtIRI:mode: [1/2]

+ (OFStream *) openItemAtIRI: (OFIRI *) IRI
mode: (OFString *) mode 

Opens the item at the specified IRI.

Parameters
IRIThe IRI of the item which should be opened
modeThe mode in which the file should be opened.
Possible modes are:
Mode Description
r Read-only
r+ Read-write
w Write-only, create or truncate
wx Write-only, create or fail, exclusive
w+ Read-write, create or truncate
w+x Read-write, create or fail, exclusive
a Write-only, create or append
a+ Read-write, create or append

The handler is allowed to not implement all modes and is also allowed to implement additional, scheme-specific modes.
Returns
The opened stream if it was successfully opened
Exceptions
OFOpenItemFailedExceptionOpening the item failed
OFUnsupportedProtocolExceptionThe specified IRI is not supported

◆ openItemAtIRI:mode: [2/2]

- (OFStream *) openItemAtIRI: (OFIRI *) IRI
mode: (OFString *) mode 

Opens the item at the specified IRI.

Parameters
IRIThe IRI of the item which should be opened
modeThe mode in which the file should be opened.
Possible modes are:
Mode Description
r Read-only
r+ Read-write
w Write-only, create or truncate
wx Write-only, create or fail, exclusive
w+ Read-write, create or truncate
w+x Read-write, create or fail, exclusive
a Write-only, create or append
a+ Read-write, create or append

The handler is allowed to not implement all modes and is also allowed to implement additional, scheme-specific modes.
Returns
The opened stream if it was successfully opened
Exceptions
OFOpenItemFailedExceptionOpening the item failed
OFUnsupportedProtocolExceptionThe specified IRI is not supported by the handler

◆ registerClass:forScheme:

+ (bool) registerClass: (Class) class_
forScheme: (OFString *) scheme 

Registers the specified class as the handler for the specified scheme.

If the same class is specified for two schemes, one instance of it is created per scheme.

Parameters
class_The class to register as the handler for the specified scheme
schemeThe scheme for which to register the handler
Returns
Whether the class was successfully registered. If a handler for the same scheme is already registered, registration fails.

◆ removeExtendedAttributeForName:ofItemAtIRI:

- (void) removeExtendedAttributeForName: (OFString *) name
ofItemAtIRI: (OFIRI *) IRI 

Removes the extended attribute for the specified name of the item at the specified IRI.

This method is not available for all IRIs.

Parameters
nameThe name of the extended attribute to remove
IRIThe IRI of the item to remove the extended attribute from
Exceptions
OFSetItemAttributesFailedExceptionRemoving the extended attribute failed
OFUnsupportedProtocolExceptionThe handler cannot handle the IRI's scheme
OFNotImplementedExceptionRemoving extended attributes is not implemented for the specified item

◆ removeItemAtIRI:

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

Parameters
IRIThe IRI to the item which should be removed
Exceptions
OFRemoveItemFailedExceptionRemoving the item failed
OFUnsupportedProtocolExceptionThe handler cannot handle the IRI's scheme

◆ setAttributes:ofItemAtIRI:

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

Parameters
attributesThe attributes to set for the specified IRI
IRIThe IRI of the item to set the attributes for @throw OFSetItemAttributesFailedException Failed to set the attributes of the item
Exceptions
OFUnsupportedProtocolExceptionThe handler cannot handle the IRI's scheme
OFNotImplementedExceptionSetting one or more of the specified attributes is not implemented for the specified item

◆ setExtendedAttributeData:andType:forName:ofItemAtIRI:

- (void) setExtendedAttributeData: (OFData *) data
andType: (nullable id) type
forName: (OFString *) name
ofItemAtIRI: (OFIRI *) IRI 

Sets the extended attribute data and type for the specified name of the item at the specified IRI.

This method is not available for all IRIs. Not all IRIs support a non-nil type.

Parameters
dataThe data for the extended attribute
typeThe type for the extended attribute. nil does not mean to keep the existing type, but to set it to no type. The type of the type depends on the IRI handler.
nameThe name of the extended attribute
IRIThe IRI of the item to set the extended attribute on
Exceptions
OFSetItemAttributesFailedExceptionSetting the extended attribute failed
OFUnsupportedProtocolExceptionThe handler cannot handle the IRI's scheme
OFNotImplementedExceptionSetting extended attributes is not implemented for the specified item or a type was specified and typed extended attributes are not supported

◆ setExtendedAttributeData:forName:ofItemAtIRI:

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

Deprecated
Use setExtendedAttributeData:andType:forName:ofItemAtIRI: instead.

This method is not available for all IRIs.

Parameters
dataThe data for the extended attribute
nameThe name of the extended attribute
IRIThe IRI of the item to set the extended attribute on
Exceptions
OFSetItemAttributesFailedExceptionSetting the extended attribute failed
OFUnsupportedProtocolExceptionThe handler cannot handle the IRI's scheme
OFNotImplementedExceptionSetting extended attributes is not implemented for the specified item

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