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

A handler for a URL scheme. More...

#import <ObjFW/OFURLHandler.h>

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

Instance Methods

(instancetype) - initWithScheme:
 Initializes the handler for the specified scheme. More...
 
(OFStream *) - openItemAtURL:mode:
 Opens the item at the specified URL. More...
 
(of_file_attributes_t- attributesOfItemAtURL:
 Returns the attributes for the item at the specified URL. More...
 
(void) - setAttributes:ofItemAtURL:
 Sets the attributes for the item at the specified URL. More...
 
(bool) - fileExistsAtURL:
 Checks whether a file exists at the specified URL. More...
 
(bool) - directoryExistsAtURL:
 Checks whether a directory exists at the specified URL. More...
 
(void) - createDirectoryAtURL:
 Creates a directory at the specified URL. More...
 
(OFArray *) - contentsOfDirectoryAtURL:
 Returns an array with the items in the specified directory. More...
 
(void) - removeItemAtURL:
 Removes the item at the specified URL. More...
 
(void) - linkItemAtURL:toURL:
 Creates a hard link for the specified item. More...
 
(void) - createSymbolicLinkAtURL:withDestinationPath:
 Creates a symbolic link for an item. More...
 
(bool) - copyItemAtURL:toURL:
 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. More...
 
(bool) - moveItemAtURL:toURL:
 Tries to efficiently move an item. If a move would only be possible by copying the source and deleting it, it returns false. 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

(bool) + registerClass:forScheme:
 Registers the specified class as the handler for the specified scheme. More...
 
(nullable) + handlerForURL:
 Returns the handler for the specified URL. More...
 
- 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

OFStringscheme
 The scheme this OFURLHandler handles.
 
- 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 handler for a URL scheme.

Method Documentation

◆ 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

◆ 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

◆ copyItemAtURL:toURL:

- (bool) copyItemAtURL: (OFURL *)  source
toURL: (OFURL *)  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 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
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!

◆ createDirectoryAtURL:

- (void) createDirectoryAtURL: (OFURL *)  URL

Creates a directory at the specified URL.

Parameters
URLThe URL of the directory to create

◆ 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

◆ 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

◆ 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

◆ handlerForURL:

+ (id) handlerForURL: (OFURL *)  URL

Returns the handler for the specified URL.

Returns
The handler for the specified URL.

◆ initWithScheme:

- (instancetype) initWithScheme: (OFString *)  scheme

Initializes the handler for the specified scheme.

Parameters
schemeThe scheme to initialize for
Returns
An initialized URL handler

◆ 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

◆ moveItemAtURL:toURL:

- (bool) moveItemAtURL: (OFURL *)  source
toURL: (OFURL *)  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 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, 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!

◆ openItemAtURL:mode:

- (OFStream *) openItemAtURL: (OFURL *)  URL
mode: (OFString *)  mode 

Opens the item at the specified URL.

Parameters
URLThe URL 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.

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

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