• BlackBerry Dynamics
  • Runtime library for iOS applications
  • 10.2.0.83
GDFileManager.h
Go to the documentation of this file.
1 /*
2  * (c) 2018 BlackBerry Limited. All rights reserved.
3  */
4 
5 #import <Foundation/Foundation.h>
6 #import "GDCReadStream.h"
7 #import "GDCWriteStream.h"
8 
9 /* \cond DOXYGEN_IGNORE */
10 #if __has_extension(attribute_deprecated_with_message)
11 # define DEPRECATED_IN_NSFILEMANAGER __attribute__((deprecated("Deprecated in NSFileManager. Do not use.")))
12 #else
13 # define DEPRECATED_IN_NSFILEMANAGER __attribute__((deprecated))
14 #endif
15 /* \endcond */
16 
17 /* \cond DOXYGEN_IGNORE */
18 #if __has_extension(attribute_unavailable_with_message)
19 # define UNAVAILABLE_IN_GDFILEMANAGER __attribute__((unavailable("Unavailable in GDFileManager. Do not use.")))
20 #else
21 # define UNAVAILABLE_IN_GDFILEMANAGER __attribute__((deprecated))
22 #endif
23 /* \endcond */
24 
25 #if (defined(__MAC_10_12) && defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12)\
26  || (defined(__IPHONE_10_0) && defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0)
27 # define GD_NSFileAttributeKey NSFileAttributeKey
28 # define GD_NSURLResourceKey NSURLResourceKey
29 #else
30 # define GD_NSFileAttributeKey NSString *
31 # define GD_NSURLResourceKey NSString *
32 #endif
33 
43 NS_ASSUME_NONNULL_BEGIN
44 
47 extern NSString* const GDFileManagerErrorDomain;
48 
49 typedef NS_ENUM(NSInteger, GDFileManagerErrorType)
50 {
54 
59 
63 
67 
71 
76 
80 
84 
88 
92 
96 
100 };
101 
307 @interface GDFileManager : NSFileManager <NSStreamDelegate>
308 {
309 
310 }
311 
312 + (GDFileManager *)defaultManager;
313 
328 + (nullable GDCReadStream*) getReadStream:(NSString*)filePath error:(NSError** ) error;
329 
351 + (nullable GDCWriteStream*) getWriteStream:(NSString*)filePath appendmode:(BOOL) flag error:(NSError**) error;
352 
364 + (nullable NSString*)getAbsoluteEncryptedPath:(NSString*)filePath;
365 
388 + (nullable NSString*)pathForCFromManagerPath: (NSString*) filePath;
389 
414 + (nullable NSString*)pathForManagerFromCPath: (NSString*) filePath;
415 
416 /* \cond DOXYGEN_IGNORE */
417 #if __has_extension(attribute_deprecated_with_message)
418 # define DEPRECATE_EXP_LOGFILE_TO_DOC_FOLDER __attribute__((deprecated("Will be removed.")))
419 #else
420 # define DEPRECATE_EXP_LOGFILE_TO_DOC_FOLDER __attribute__((deprecated))
421 #endif
422 /* \endcond */
423 
441 + (BOOL)exportLogFileToDocumentsFolder:(NSError**)error DEPRECATE_EXP_LOGFILE_TO_DOC_FOLDER;
442 
443 // Working with directories.
444 
445 - (nullable NSURL *)URLForDirectory:(NSSearchPathDirectory)directory inDomain:(NSSearchPathDomainMask)domain appropriateForURL:(nullable NSURL *)url create:(BOOL)shouldCreate error:(NSError **)error;
446 
447 - (NSArray<NSURL *> *)URLsForDirectory:(NSSearchPathDirectory)directory inDomains:(NSSearchPathDomainMask)domainMask;
448 
456 - (nullable NSURL *)containerURLForSecurityApplicationGroupIdentifier:(NSString *)groupIdentifier;
457 
458 - (nullable NSArray<NSURL*>*)contentsOfDirectoryAtURL:(NSURL *)url includingPropertiesForKeys:(nullable NSArray<GD_NSURLResourceKey>*)keys options:(NSDirectoryEnumerationOptions)mask error:(NSError **)error;
459 
460 - (nullable NSArray<NSString*>*)contentsOfDirectoryAtPath:(NSString *)path error:(NSError **)error;
461 
462 - (nullable NSDirectoryEnumerator<NSURL *> *)enumeratorAtURL:(NSURL *)url includingPropertiesForKeys:(nullable NSArray<GD_NSURLResourceKey> *)keys options:(NSDirectoryEnumerationOptions)mask errorHandler:(nullable BOOL (^)(NSURL * url, NSError * error))handler;
463 
464 - (nullable NSDirectoryEnumerator<NSString *> *)enumeratorAtPath:(NSString *)path;
465 
466 - (nullable NSArray<NSString*> *)subpathsOfDirectoryAtPath:( NSString *)pathRaw error:(NSError **)error;
467 
468 - (nullable NSArray<NSString*> *)subpathsAtPath:( NSString *)path;
469 
470 // Creating and deleting items.
471 
472 - (BOOL)createDirectoryAtURL:( NSURL *)url withIntermediateDirectories:(BOOL)createIntermediates attributes:(nullable NSDictionary<NSString*, id>*)attributes error:(NSError **)error;
473 
474 - (BOOL)createDirectoryAtPath:( NSString*)path withIntermediateDirectories:(BOOL) createIntermediates attributes:(nullable NSDictionary<NSString*, id>*)attributes error:(NSError **)error;
475 
476 - (BOOL)createFileAtPath:( NSString *)path contents:(nullable NSData *)contents attributes:(nullable NSDictionary<NSString*, id>*)attributes;
477 
478 - (BOOL)removeItemAtURL:( NSURL *)URL error:(NSError **)error;
479 
480 - (BOOL)removeItemAtPath:( NSString*)filePath error:(NSError **)error;
481 
482 - (BOOL)replaceItemAtURL:( NSURL *)originalItemURL withItemAtURL:( NSURL *)newItemURL backupItemName:(nullable NSString *)backupItemName options:(NSFileManagerItemReplacementOptions)options resultingItemURL:(NSURL * _Nullable * _Nullable)resultingURL error:(NSError **)error;
483 
484 // Moving and copying items.
485 
486 - (BOOL)copyItemAtURL:( NSURL *)srcURL toURL:( NSURL *)dstURL error:(NSError **)error;
487 
488 - (BOOL)copyItemAtPath:( NSString *)srcPath toPath:( NSString *)dstPath error:(NSError **)error;
489 
490 - (BOOL)moveItemAtURL:( NSURL *)srcURL toURL:( NSURL *)dstURL error:(NSError **)error;
491 
492 - (BOOL)moveItemAtPath:( NSString*)srcPath toPath:( NSString*)dstPath error:(NSError **)error;
493 
494 
495 #if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
496 //Getting home directory details.
497 
507 #if defined(__MAC_10_12)
508 - (nullable NSURL *)homeDirectoryForUser:(NSString *)userName GD_API_AVAILABLE(macosx(10.12)) GD_API_UNAVAILABLE(ios, watchos, tvos);
509 #endif
510 #endif
511 
512 // Unavailable API elements.
513 // iCloud - unsupported
514 
522 @property(nullable, readonly, copy, atomic) id<NSObject, NSCopying, NSSecureCoding> ubiquityIdentityToken;
523 
531 - (nullable NSURL *)URLForUbiquityContainerIdentifier:(nullable NSString *)containerIdentifier;
532 
540 - (BOOL)isUbiquitousItemAtURL:( NSURL *)url;
541 
550 - (BOOL)setUbiquitous:(BOOL)flag itemAtURL:( NSURL *)url destinationURL:( NSURL *)destinationURL error:(NSError **)error;
551 
560 - (BOOL)startDownloadingUbiquitousItemAtURL:( NSURL *)url error:(NSError **)error;
561 
570 - (BOOL)evictUbiquitousItemAtURL:( NSURL *)url error:(NSError **)error;
571 
580 - (nullable NSURL *)URLForPublishingUbiquitousItemAtURL:( NSURL *)url expirationDate:(NSDate * _Nullable * _Nullable)outDate error:(NSError **)error;
581 
593 #if defined(__MAC_10_13) || defined(__IPHONE_11_0)
594 - (void)getFileProviderServicesForItemAtURL:(NSURL *)url completionHandler:(void (^)(NSDictionary<NSFileProviderServiceName,NSFileProviderService *> *services, NSError *error))completionHandler UNAVAILABLE_IN_GDFILEMANAGER;
595 
596 #endif
597 
605 #if defined(__MAC_10_12) || defined(__IPHONE_10_0)
606 @property(readonly, copy, atomic) NSURL *temporaryDirectory UNAVAILABLE_IN_GDFILEMANAGER;
607 #endif
608 
609 // Linking.
610 
611 - (BOOL)createSymbolicLinkAtURL:( NSURL *)url withDestinationURL:( NSURL *)destURL error:(NSError **)error;
612 
613 - (BOOL)createSymbolicLinkAtPath:( NSString *)path withDestinationPath:( NSString *)destPath error:(NSError **)error;
614 
615 - (BOOL)linkItemAtURL:( NSURL *)srcURL toURL:( NSURL *)dstURL error:(NSError **)error;
616 
617 - (BOOL)linkItemAtPath:( NSString *)srcPath toPath:( NSString *)dstPath error:(NSError **)error;
618 
619 - (nullable NSString *)destinationOfSymbolicLinkAtPath:( NSString *)path error:(NSError **)error;
620 
621 // Determining access.
622 
623 - (BOOL)fileExistsAtPath:( NSString *)path;
624 
625 - (BOOL)fileExistsAtPath:( NSString*)path isDirectory:(nullable BOOL*)isDirectory;
626 
627 - (BOOL)isReadableFileAtPath:( NSString *)path;
628 
629 - (BOOL)isWritableFileAtPath:( NSString *)path;
630 
631 - (BOOL)isExecutableFileAtPath:( NSString *)path;
632 
633 - (BOOL)isDeletableFileAtPath:( NSString *)path;
634 
635 - (nullable NSDictionary<GD_NSFileAttributeKey, id> *)attributesOfItemAtPath:( NSString *)path error:(NSError **)error;
636 
637 - (nullable NSDictionary<GD_NSFileAttributeKey, id> *)attributesOfFileSystemForPath:( NSString *)path error:(NSError **)error;
638 
639 - (BOOL)setAttributes:( NSDictionary<GD_NSFileAttributeKey, id> *)attributes ofItemAtPath:( NSString *)path error:(NSError **)error;
640 
641 // Getting file contents.
642 
643 - (nullable NSData *)contentsAtPath:( NSString *)path;
644 
645 - (BOOL)contentsEqualAtPath:( NSString *)path1 andPath:( NSString *)path2;
646 
647 // Converting paths to strings.
648 
649 - ( const char *)fileSystemRepresentationWithPath:( NSString *)path NS_RETURNS_INNER_POINTER;
650 
651 - ( NSString *)stringWithFileSystemRepresentation:( const char *)string length:(NSUInteger)len;
652 
653 // Get and set the current working directory of the program.
654 
655 - (BOOL)changeCurrentDirectoryPath:( NSString *)path;
656 
657 - ( NSString *)currentDirectoryPath;
658 
659 // Deprecated methods
660 
667 - (BOOL)changeFileAttributes:( NSDictionary *)attributes atPath:( NSString *)path DEPRECATED_IN_NSFILEMANAGER;
668 
675 - (nullable NSDictionary *)fileAttributesAtPath:( NSString *)path traverseLink:(BOOL)flag DEPRECATED_IN_NSFILEMANAGER;
676 
683 - (nullable NSDictionary *)fileSystemAttributesAtPath:( NSString *)path DEPRECATED_IN_NSFILEMANAGER;
684 
691 - (nullable NSArray *)directoryContentsAtPath:( NSString *)path DEPRECATED_IN_NSFILEMANAGER;
692 
699 - (BOOL)createDirectoryAtPath:( NSString *)path attributes:( NSDictionary *)attributes DEPRECATED_IN_NSFILEMANAGER;
700 
707 - (BOOL)createSymbolicLinkAtPath:( NSString *)path pathContent:( NSString *)otherPath DEPRECATED_IN_NSFILEMANAGER;
708 
715 - (nullable NSString *)pathContentOfSymbolicLinkAtPath:( NSString *)path DEPRECATED_IN_NSFILEMANAGER;
716 
717 @end
718 
719 NS_ASSUME_NONNULL_END
GD_NSFileAttributeKey
#define GD_NSFileAttributeKey
Definition: GDFileManager.h:30
GDFileManagerErrorNotSupported
@ GDFileManagerErrorNotSupported
Attempt to utilize unsupported interface.
Definition: GDFileManager.h:95
GDFileManagerErrorICloudNotSupported
@ GDFileManagerErrorICloudNotSupported
Attempt to access "Ubiquitous" file or directory, i.e. one that is in "cloud" storage.
Definition: GDFileManager.h:75
GDFileManagerErrorType
GDFileManagerErrorType
Definition: GDFileManager.h:49
GDFileManagerErrorIOError
@ GDFileManagerErrorIOError
Input or output error occurred during a low-level read or write operation.
Definition: GDFileManager.h:58
GDFileManagerErrorInvalidFileURL
@ GDFileManagerErrorInvalidFileURL
The URL passed in was not a valid file URL.
Definition: GDFileManager.h:91
GDFileManagerErrorUnknownError
@ GDFileManagerErrorUnknownError
An unknown error occured.
Definition: GDFileManager.h:99
GDFileManagerErrorDeleteBackupError
@ GDFileManagerErrorDeleteBackupError
Unable to delete backup.
Definition: GDFileManager.h:83
GDFileManagerErrorDirectoryNotEmpty
@ GDFileManagerErrorDirectoryNotEmpty
Attempt to delete a directory that was not empty.
Definition: GDFileManager.h:66
GDCWriteStream
NSOutputStream subclass for writing files in the secure store.
Definition: GDCWriteStream.h:34
GDFileManagerErrorPathAlreadyExists
@ GDFileManagerErrorPathAlreadyExists
Specified path already exists.
Definition: GDFileManager.h:79
GDCWriteStream.h
GDCReadStream.h
GDFileManagerErrorDomain
NS_ASSUME_NONNULL_BEGIN NSString *const GDFileManagerErrorDomain
Error domain for file system errors.
GDFileManagerErrorPermissionError
@ GDFileManagerErrorPermissionError
Permissions error when attempting to access part of the filesystem.
Definition: GDFileManager.h:62
GDFileManagerErrorPathDoesNotExist
@ GDFileManagerErrorPathDoesNotExist
Specified path does not exist.
Definition: GDFileManager.h:53
GDFileManager
Secure File System.
Definition: GDFileManager.h:307
GD_NSURLResourceKey
#define GD_NSURLResourceKey
Definition: GDFileManager.h:31
GDFileManagerErrorPreservingMetadata
@ GDFileManagerErrorPreservingMetadata
Unable to preserve metadata from original file.
Definition: GDFileManager.h:87
GDFileManagerErrorPathError
@ GDFileManagerErrorPathError
There was a problem with the path.
Definition: GDFileManager.h:70
GDCReadStream
NSInputStream subclass for reading files that are in the secure store.
Definition: GDCReadStream.h:47