|
Sparkle
2.0.0
A software update framework for macOS
|
#import <SUFileManager.h>
Instance Methods | |
| (instancetype) | - init |
| (NSURL *_Nullable) | - makeTemporaryDirectoryWithPreferredName:appropriateForDirectoryURL:error: |
| (BOOL) | - makeDirectoryAtURL:error: |
| (BOOL) | - moveItemAtURL:toURL:error: |
| (BOOL) | - replaceItemAtURL:withItemAtURL:error: |
| (BOOL) | - copyItemAtURL:toURL:error: |
| (BOOL) | - removeItemAtURL:error: |
| (BOOL) | - changeOwnerAndGroupOfItemAtRootURL:toMatchURL:error: |
| (BOOL) | - updateModificationAndAccessTimeOfItemAtURL:error: |
| (BOOL) | - updateAccessTimeOfItemAtRootURL:error: |
| (BOOL) | - releaseItemFromQuarantineAtRootURL:error: |
A class used for performing file operations more suitable than NSFileManager for performing installation work. All operations on this class may be used on thread other than the main thread. This class provides just basic file operations and stays away from including much application-level logic.
| - (BOOL) changeOwnerAndGroupOfItemAtRootURL: | (NSURL *) | targetURL | |
| toMatchURL: | (NSURL *) | matchURL | |
| error: | (NSError **) | error | |
Changes the owner and group IDs of an item at a specified target URL to match another URL
| targetURL | A URL pointing to the target item whose owner and group IDs to alter. This will be applied recursively if the item is a directory. The item at this URL must exist. |
| matchURL | A URL pointing to the item whose owner and group IDs will be used for changing on the targetURL. The item at this URL must exist. |
| error | If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL. |
If the owner and group IDs match on the root items of targetURL and matchURL, this method stops and assumes that nothing needs to be done. Otherwise this method recursively changes the IDs if the target is a directory. If an item in the directory is encountered that is unable to be changed, then this method stops and returns NO. While this method will try to change the group ID, being unable to change the group ID does not result in a failure if the owner ID can be changed or matched.
This is not an atomic operation.
| - (BOOL) copyItemAtURL: | (NSURL *) | sourceURL | |
| toURL: | (NSURL *) | destinationURL | |
| error: | (NSError **) | error | |
Copies an item from a source to a destination
| sourceURL | A URL pointing to the item to move. The item at this URL must exist. |
| destinationURL | A URL pointing to the destination the item will be moved at. An item must not already exist at this URL. |
| error | If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL. |
This is not an atomic operation.
| - (instancetype) init |
Initializes a new file manager
| - (BOOL) makeDirectoryAtURL: | (NSURL *) | targetURL | |
| error: | (NSError **) | error | |
Creates a directory at the target URL
| targetURL | A URL pointing to the directory to create. The item at this URL must not exist, and the parent directory of this URL must already exist. |
| error | If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL. |
This is an atomic operation.
| - (NSURL *) makeTemporaryDirectoryWithPreferredName: | (NSString *) | preferredName | |
| appropriateForDirectoryURL: | (NSURL *) | appropriateURL | |
| error: | (NSError * __autoreleasing *) | error | |
Creates a temporary directory on the same volume as a provided URL
| preferredName | A name that may be used when creating the temporary directory. Note that in the uncothirdStageErrormmon case this name is used, the temporary directory will be created inside the directory pointed by appropriateURL |
| appropriateURL | A URL to a directory that resides on the volume that the temporary directory will be created on. In the uncommon case, the temporary directory may be created inside this directory. |
| error | If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL. |
When moving an item from a source to a destination, it is desirable to create a temporary intermediate destination on the same volume as the destination to ensure that the item will be moved, and not copied, from the intermediate point to the final destination. This ensures file atomicity.
| - (BOOL) moveItemAtURL: | (NSURL *) | sourceURL | |
| toURL: | (NSURL *) | destinationURL | |
| error: | (NSError **) | error | |
Moves an item from a source to a destination
| sourceURL | A URL pointing to the item to move. The item at this URL must exist. |
| destinationURL | A URL pointing to the destination the item will be moved at. An item must not already exist at this URL. |
| error | If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL. |
If sourceURL and destinationURL reside on the same volume, this operation will be an atomic move operation. Otherwise this will be equivalent to a copy & remove which will be a nonatomic operation.
| - (BOOL) releaseItemFromQuarantineAtRootURL: | (NSURL *) | rootURL | |
| error: | (NSError **) | error | |
Releases Apple's quarantine extended attribute from the item at the specified root URL
| rootURL | A URL pointing to the item to release from Apple's quarantine. This will be applied recursively if the item is a directory. The item at this URL must exist. |
| error | If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL. |
This method removes quarantine attributes from an item, ideally an application, so that when the user launches a new application themselves, they don't have to witness the system dialog alerting them that they downloaded an application from the internet and asking if they want to continue. Note that this may not exactly mimic the system behavior when a user opens an application for the first time (i.e, the xattr isn't deleted), but this should be sufficient enough for our purposes.
This method may return NO even if some items do get released from quarantine if the target URL is pointing to a directory. Thus if an item cannot be released from quarantine, this method still continues on to the next enumerated item.
This is not an atomic operation.
| - (BOOL) removeItemAtURL: | (NSURL *) | url | |
| error: | (NSError **) | error | |
Removes an item at a URL
| url | A URL pointing to the item to remove. The item at this URL must exist. |
| error | If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL. |
This is not an atomic operation.
| - (BOOL) replaceItemAtURL: | (NSURL *) | originalItemURL | |
| withItemAtURL: | (NSURL *) | newItemURL | |
| error: | (10.13) | __OSX_AVAILABLE | |
Replaces an original item with a new item atomically.
| originalItemURL | A URL pointing to the original item to replace. The item at this URL must exist. |
| newItemURL | A URL pointing to the new item that will replace the original item. |
| error | If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL. |
originalItemURL and newItemURL must reside on the same volume. If the operation succeeds, this will be be an atomic operation. Otherwise on failure you may need to re-try using move operations. This operation will fail on non-apfs volumes or volumes that don't support rename swapping. Both originalItemURL and newItemURL must exist.
| - (BOOL) updateAccessTimeOfItemAtRootURL: | (NSURL *) | targetURL | |
| error: | (NSError * __autoreleasing *) | error | |
Updates the access time of an item at a specified root URL to the current time
| targetURL | A URL pointing to the target item whose access time to update to the current time. This will be applied recursively if the item is a directory. The item at this URL must exist. |
| error | If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL. |
This method updates the access time of an item to the current time, ideal for letting the system know not to remove a file or directory when placing it at a temporary directory.
This is not an atomic operation.
| - (BOOL) updateModificationAndAccessTimeOfItemAtURL: | (NSURL *) | targetURL | |
| error: | (NSError **) | error | |
Updates the modification and access time of an item at a specified target URL to the current time
| targetURL | A URL pointing to the target item whose modification and access time to update. The item at this URL must exist. |
| error | If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL. |
This method updates the modification and access time of an item to the current time, ideal for letting the system know we installed a new file or application.
This is not an atomic operation.