Secure File System. More...
#import <GDFileManager.h>
This class is a subclass of the native NSFileManager
class, for access to the BlackBerry Dynamics secure file system.
The secure file system is part of the BlackBerry Dynamics Secure Storage feature.
For applications, the BlackBerry Dynamics secure file system behaves like the default file system, with the following differences.
Every operating system has a maximum supported length for the names of files and directories. For example, iOS 11 supports a maximum length of 255 bytes, given by the NAME_MAX
constant. The encrypted form of the name of a directory or file will typically be longer than the plaintext, and it is the encrypted form that must be within the limits supported by the operating system. This means that names in the secure file system have a shorter effective maximum supported length. It isn't possible to give a simple maximum but the following should be expected.
Encryption and decryption is transparent to the application code:
The encryption method used by the BlackBerry Dynamics runtime generally requires that the user has entered a security password, from which an encryption key is derived.
This class is a subclass of the native NSFileManager
class. It should be easy to replace references to NSFileManager
with references to GDFile
Manager
, in order to convert application code that utilizes the native file system into code that utilizes the secure file system.
The differences between this class and NSFileManager
are:
containerURLForSecurityApplicationGroupIdentifier:
function returns the same value as the base class would for an invalid group identifier.temporaryDirectory
property mustn't be used to create paths.getFileProviderServicesForItemAtURL:completionHandler:
interface always fails.NSURL
values for locations within the secure file system can only be utilized by BlackBerry Dynamics programming interfaces, see below.NSString
values for paths within the secure file system can only be utilized by BlackBerry Dynamics programming interfaces, see below.GDFil
eManager
error domain, or could be general NS
error codes.The NSURL
values returned by functions in this class can only be used to access files and directories by BlackBerry Dynamics programming interfaces. They cannot be used by native interfaces, such as NSInputStream
nor stringWithContentsOfURL:
for example.
The NSString
values for paths returned by functions in this class can only be used to access files and directories by BlackBerry Dynamics programming interfaces. They cannot be used by native interfaces, such as stringByResolvingSymlinksInPath
, nor dataWithContentsOfFile:
for example.
To read and write files in the secure store, use functions in this class or in one of the other BlackBerry Dynamics programming interfaces. For example:
GDFileHandle
class.Don't use file-reading and -writing functions in the native NS
classes to access files in the secure store.
Best practice for building paths for use with this class is as follows. First use an NSSearchPathDirectory
value to generate a path prefix, for example by calling the NSSearchPathForDirectoriesInDomains:
function. Then append to the prefix, for example by calling the NSString
stringByAppendingPath:
function or the NSURL
URLByAppendingPathComponent
function.
The functions in this API utilize NSError
in a conventional way. Function calls accept as a parameter the location of a pointer to NSError
, i.e. a pointer to a pointer, with type NSError**
. The location may be nil
. If the location isn't nil
, and an error occurs, the BlackBerry Dynamics runtime overwrites the pointer at the specified location with the address of an object that describes the error that occurred.
The documentation of this class includes descriptions for functions and other elements of the programming interface that:
Elements of the base class that are overriden, but have the same semantics, are listed in the documentation of this class, but not described further. Elements of the base class that aren't overriden are not listed. See the documentation of the base class, NSFileManager
, for full descriptions.
The following code snippets illustrate some common tasks.
The following code snippets illustrate simple conversion of a function that uses the native file system to use the secure files system instead.
The second function in the snippet is the original; the third is the converted version. The changed line is flagged with a comment. The first function in the snippet is a utility that is used by both the original and the converted function, with no changes.
Class Methods | |
(GDFileManager *) | + defaultManager |
(nullable GDCReadStream *) | + getReadStream:error: |
Open a file that is in the secure store, for reading. More... | |
(nullable GDCWriteStream *) | + getWriteStream:appendmode:error: |
Open a file in the secure store, for writing. More... | |
(nullable NSString *) | + getAbsoluteEncryptedPath: |
Get the absolute encrypted path of a file within the secure store. More... | |
(nullable NSString *) | + pathForCFromManagerPath: |
Convert a path for use with the BlackBerry Dynamics POSIX-level C language programming interface. More... | |
(nullable NSString *) | + pathForManagerFromCPath: |
Convert a path from the BlackBerry Dynamics POSIX-level C language programming interface. More... | |
(BOOL) | + exportLogFileToDocumentsFolder: |
Dump BlackBerry Dynamics logs out to an accessible folder (deprecated). More... | |
Properties | |
id< NSObject, NSCopying, NSSecureCoding > | ubiquityIdentityToken |
Not available. More... | |
NSURL * | temporaryDirectory |
Not available. More... | |
+ (GDFileManager *) defaultManager |
+ (nullable GDCReadStream*) getReadStream: | (NSString *) | filePath | |
error: | (NSError **) | error | |
Call this function to open a file in the secure store for reading. Files in the secure store are encrypted on the device; this function provides access to decrypted data.
filePath | NSString of the path, within the secure store, that represents the file to be opened. |
error | For returning an NSError object if an error occurs. If nil , no object will be returned. |
GDCReadStream
object from which the file's data can be read, or a null pointer if the file could not be opened. + (nullable GDCWriteStream*) getWriteStream: | (NSString *) | filePath | |
appendmode: | (BOOL) | flag | |
error: | (NSError **) | error | |
Call this function to create a new file in the secure store, or to open an existing file for writing. Files in the secure store are encrypted on the device; data written to the stream returned by this function will be encrypted, transparently to the application.
If a file already exists at the specified path, the file can either be appended to, or overwritten.
filePath | NSString of the path, within the secure store, that represents the file to be opened. |
flag | Selects the action to take if a file already exists at the path. YES to append to the file, or NO to overwrite. |
error | For returning an NSError object if an error occurs. If nil , no object will be returned. |
GDCWriteStream
object to which data can be written, or a null pointer if the file could not be opened. + (nullable NSString*) getAbsoluteEncryptedPath: | (NSString *) | filePath |
This function returns the encrypted path for a file or directory within the secure store. The principal usage for this function is to provide a path that is compatible with the SQL ATTACH command.
filePath | NSString of the path, within the secure store, that represents the item for which the encrypted path is required. |
NSString
containing the encrypted path. + (nullable NSString*) pathForCFromManagerPath: | (NSString *) | filePath |
Call this function to convert a path so that it can be used with the BlackBerry Dynamics POSIX-level C language programming interface.
Paths used with this class, GDFile
Manager
, have a different root to the file access functions in the POSIX-level C programming interface. This is because this class is an NSFileManager
subclass. This function maps a path with the GDFile
Manager
root to a path with the POSIX-level root.
The pathForManagerFromCPath:
and pathForCFromManagerPath:
, functions facilitate inter-operation of the programming interfaces. For example, a file could be created with POSIX-level C functions, then read back with functions in this class.
filePath | NSString containing a path for use with this class. |
NSString
containing the converted path. + (nullable NSString*) pathForManagerFromCPath: | (NSString *) | filePath |
Call this function to convert a path from the BlackBerry Dynamics POSIX-level C programming interface.
Paths used with this class, GDFile
Manager
, have a different root to the file access functions in the POSIX-level C programming interface. This is because this class is an NSFileManager
subclass. This function maps a path with the POSIX-level root to a path with the GDFile
Manager
root.
The pathForManagerFromCPath:
and pathForCFromManagerPath:
, functions facilitate inter-operation of the programming interfaces. For example, a file could be created with POSIX-level C functions, then read back with functions in this class.
filePath | NSString containing a path for use with the POSIX-level C programming interface. |
NSString
containing the converted path.+ (BOOL) exportLogFileToDocumentsFolder: | (NSError **) | error |
Call this function to create a dump of BlackBerry Dynamics activity logs. The logs will be dumped to a file that is outside the secure store, in the Documents folder. The file will not be encrypted.
error | For returning an NSError object if an error occurs. If nil , no object will be returned. |
The log file can be copied from the device in the normal way, and sent to BlackBerry to assist in support analysis.
- (nullable NSURL *) URLForDirectory: | (NSSearchPathDirectory) | directory | |
inDomain: | (NSSearchPathDomainMask) | domain | |
appropriateForURL: | (nullable NSURL *) | url | |
create: | (BOOL) | shouldCreate | |
error: | (NSError **) | error | |
- (NSArray<NSURL *> *) URLsForDirectory: | (NSSearchPathDirectory) | directory | |
inDomains: | (NSSearchPathDomainMask) | domainMask | |
- (nullable NSURL *) containerURLForSecurityApplicationGroupIdentifier: | (NSString *) | groupIdentifier |
This element of the base class interface isn't available in this subclass. See under Usage, above.
nil
always. - (nullable NSArray<NSURL*>*) contentsOfDirectoryAtURL: | (NSURL *) | url | |
includingPropertiesForKeys: | (nullable NSArray< GD_NSURLResourceKey > *) | keys | |
options: | (NSDirectoryEnumerationOptions) | mask | |
error: | (NSError **) | error | |
- (nullable NSArray<NSString*>*) contentsOfDirectoryAtPath: | (NSString *) | path | |
error: | (NSError **) | error | |
- (nullable NSDirectoryEnumerator<NSURL *> *) enumeratorAtURL: | (NSURL *) | url | |
includingPropertiesForKeys: | (nullable NSArray< GD_NSURLResourceKey > *) | keys | |
options: | (NSDirectoryEnumerationOptions) | mask | |
errorHandler: | (nullable BOOL(^)(NSURL *url, NSError *error)) | handler | |
- (nullable NSDirectoryEnumerator<NSString *> *) enumeratorAtPath: | (NSString *) | path |
- (nullable NSArray<NSString*> *) subpathsOfDirectoryAtPath: | (NSString *) | pathRaw | |
error: | (NSError **) | error | |
- (nullable NSArray<NSString*> *) subpathsAtPath: | (NSString *) | path |
- (BOOL) createDirectoryAtURL: | (NSURL *) | url | |
withIntermediateDirectories: | (BOOL) | createIntermediates | |
attributes: | (nullable NSDictionary< NSString *, id > *) | attributes | |
error: | (NSError **) | error | |
- (BOOL) createDirectoryAtPath: | (NSString *) | path | |
withIntermediateDirectories: | (BOOL) | createIntermediates | |
attributes: | (nullable NSDictionary< NSString *, id > *) | attributes | |
error: | (NSError **) | error | |
- (BOOL) createFileAtPath: | (NSString *) | path | |
contents: | (nullable NSData *) | contents | |
attributes: | (nullable NSDictionary< NSString *, id > *) | attributes | |
- (BOOL) removeItemAtURL: | (NSURL *) | URL | |
error: | (NSError **) | error | |
- (BOOL) removeItemAtPath: | (NSString *) | filePath | |
error: | (NSError **) | error | |
- (BOOL) replaceItemAtURL: | (NSURL *) | originalItemURL | |
withItemAtURL: | (NSURL *) | newItemURL | |
backupItemName: | (nullable NSString *) | backupItemName | |
options: | (NSFileManagerItemReplacementOptions) | options | |
resultingItemURL: | (NSURL *_Nullable *_Nullable) | resultingURL | |
error: | (NSError **) | error | |
- (BOOL) copyItemAtURL: | (NSURL *) | srcURL | |
toURL: | (NSURL *) | dstURL | |
error: | (NSError **) | error | |
- (BOOL) copyItemAtPath: | (NSString *) | srcPath | |
toPath: | (NSString *) | dstPath | |
error: | (NSError **) | error | |
- (BOOL) moveItemAtURL: | (NSURL *) | srcURL | |
toURL: | (NSURL *) | dstURL | |
error: | (NSError **) | error | |
- (BOOL) moveItemAtPath: | (NSString *) | srcPath | |
toPath: | (NSString *) | dstPath | |
error: | (NSError **) | error | |
- (nullable NSURL *) URLForUbiquityContainerIdentifier: | (nullable NSString *) | containerIdentifier |
This element of the base class interface isn't available in this subclass. See under Usage, above.
nil
always. - (BOOL) isUbiquitousItemAtURL: | (NSURL *) | url |
This element of the base class interface isn't available in this subclass. See under Usage, above.
NO
always. - (BOOL) setUbiquitous: | (BOOL) | flag | |
itemAtURL: | (NSURL *) | url | |
destinationURL: | (NSURL *) | destinationURL | |
error: | (NSError **) | error | |
This element of the base class interface isn't available in this subclass. See under Usage, above.
NO
always. Sets GDFileManagerErrorICloudNotSupported
if an error
location is specified. - (BOOL) startDownloadingUbiquitousItemAtURL: | (NSURL *) | url | |
error: | (NSError **) | error | |
This element of the base class interface isn't available in this subclass. See under Usage, above.
NO
always. Sets GDFileManagerErrorICloudNotSupported
if an error
location is specified. - (BOOL) evictUbiquitousItemAtURL: | (NSURL *) | url | |
error: | (NSError **) | error | |
This element of the base class interface isn't available in this subclass. See under Usage, above.
NO
always. Sets GDFileManagerErrorICloudNotSupported
if an error
location is specified. - (nullable NSURL *) URLForPublishingUbiquitousItemAtURL: | (NSURL *) | url | |
expirationDate: | (NSDate *_Nullable *_Nullable) | outDate | |
error: | (NSError **) | error | |
This element of the base class interface isn't available in this subclass. See under Usage, above.
nil
always. Sets GDFileManagerErrorICloudNotSupported
if an error
location is specified. - (void) getFileProviderServicesForItemAtURL: | (NSURL *) | url | |
completionHandler: | (void(^)(NSDictionary< NSFileProviderServiceName, NSFileProviderService * > *services, NSError *error)) | completionHandler | |
This element of the base class interface isn't available in this subclass. See under Usage, above.
Calling this function in the subclass causes the specified completion handler to be invoked as follows. The services
parameter will receive nil
. The error
parameter will receive an NSError
object with the GDFileManagerErrorNotSupported
code. The invocation will be on a background thread.
- (BOOL) createSymbolicLinkAtURL: | (NSURL *) | url | |
withDestinationURL: | (NSURL *) | destURL | |
error: | (NSError **) | error | |
- (BOOL) createSymbolicLinkAtPath: | (NSString *) | path | |
withDestinationPath: | (NSString *) | destPath | |
error: | (NSError **) | error | |
- (BOOL) linkItemAtURL: | (NSURL *) | srcURL | |
toURL: | (NSURL *) | dstURL | |
error: | (NSError **) | error | |
- (BOOL) linkItemAtPath: | (NSString *) | srcPath | |
toPath: | (NSString *) | dstPath | |
error: | (NSError **) | error | |
- (nullable NSString *) destinationOfSymbolicLinkAtPath: | (NSString *) | path | |
error: | (NSError **) | error | |
- (BOOL) fileExistsAtPath: | (NSString *) | path |
- (BOOL) fileExistsAtPath: | (NSString *) | path | |
isDirectory: | (nullable BOOL *) | isDirectory | |
- (BOOL) isReadableFileAtPath: | (NSString *) | path |
- (BOOL) isWritableFileAtPath: | (NSString *) | path |
- (BOOL) isExecutableFileAtPath: | (NSString *) | path |
- (BOOL) isDeletableFileAtPath: | (NSString *) | path |
- (nullable NSDictionary<GD_NSFileAttributeKey, id> *) attributesOfItemAtPath: | (NSString *) | path | |
error: | (NSError **) | error | |
- (nullable NSDictionary<GD_NSFileAttributeKey, id> *) attributesOfFileSystemForPath: | (NSString *) | path | |
error: | (NSError **) | error | |
- (BOOL) setAttributes: | (NSDictionary< GD_NSFileAttributeKey, id > *) | attributes | |
ofItemAtPath: | (NSString *) | path | |
error: | (NSError **) | error | |
- (nullable NSData *) contentsAtPath: | (NSString *) | path |
- (BOOL) contentsEqualAtPath: | (NSString *) | path1 | |
andPath: | (NSString *) | path2 | |
- (const char *) fileSystemRepresentationWithPath: | (NSString *) | NS_RETURNS_INNER_POINTER |
- (NSString *) stringWithFileSystemRepresentation: | (const char *) | string | |
length: | (NSUInteger) | len | |
- (BOOL) changeCurrentDirectoryPath: | (NSString *) | path |
- (NSString *) currentDirectoryPath |
- (BOOL) changeFileAttributes: | (NSDictionary *) | attributes | |
atPath: | (NSString *) | path | |
- (nullable NSDictionary *) fileAttributesAtPath: | (NSString *) | path | |
traverseLink: | (BOOL) | flag | |
- (nullable NSDictionary *) fileSystemAttributesAtPath: | (NSString *) | path |
- (nullable NSArray *) directoryContentsAtPath: | (NSString *) | path |
- (BOOL) createDirectoryAtPath: | (NSString *) | path | |
attributes: | (NSDictionary *) | attributes | |
- (BOOL) createSymbolicLinkAtPath: | (NSString *) | path | |
pathContent: | (NSString *) | otherPath | |
- (nullable NSString *) pathContentOfSymbolicLinkAtPath: | (NSString *) | path |
|
readatomiccopy |
This element of the base class interface isn't available in this subclass. See under Usage, above.
nil
always.
|
readatomiccopy |
This element of the base class interface isn't available in this subclass. See under Usage, above.