• BlackBerry Dynamics
  • Runtime library for iOS applications
  • 7.1.0.193
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 #import "GDPortability.h"
9 
10 /* \cond DOXYGEN_IGNORE */
11 #if __has_extension(attribute_deprecated_with_message)
12 # define DEPRECATED_IN_NSFILEMANAGER __attribute__((deprecated("Deprecated in NSFileManager. Do not use.")))
13 #else
14 # define DEPRECATED_IN_NSFILEMANAGER __attribute__((deprecated))
15 #endif
16 /* \endcond */
17 
18 /* \cond DOXYGEN_IGNORE */
19 #if __has_extension(attribute_unavailable_with_message)
20 # define UNAVAILABLE_IN_GDFILEMANAGER __attribute__((unavailable("Unavailable in GDFileManager. Do not use.")))
21 #else
22 # define UNAVAILABLE_IN_GDFILEMANAGER __attribute__((deprecated))
23 #endif
24 /* \endcond */
25 
26 #if (defined(__MAC_10_12) && defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12)\
27  || (defined(__IPHONE_10_0) && defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0)
28 # define GD_NSFileAttributeKey NSFileAttributeKey
29 # define GD_NSURLResourceKey NSURLResourceKey
30 #else
31 # define GD_NSFileAttributeKey NSString *
32 # define GD_NSURLResourceKey NSString *
33 #endif
34 
45 
48 extern NSString* const GDFileManagerErrorDomain;
49 
50 typedef NS_ENUM(NSInteger, GDFileManagerErrorType)
51 {
55 
60 
64 
68 
72 
77 
81 
85 
89 
93 
97 
101 };
102 
308 @interface GDFileManager : NSFileManager <NSStreamDelegate>
309 {
310 
311 }
312 
313 + (GDFileManager *)defaultManager;
314 
329 + (GD_NSNULLABLE GDCReadStream*) getReadStream:(NSString*)filePath error:(NSError** ) error;
330 
352 + (GD_NSNULLABLE GDCWriteStream*) getWriteStream:(NSString*)filePath appendmode:(BOOL) flag error:(NSError**) error;
353 
365 + (GD_NSNULLABLE NSString*)getAbsoluteEncryptedPath:(NSString*)filePath;
366 
389 + (GD_NSNULLABLE NSString*)pathForCFromManagerPath: (NSString*) filePath;
390 
415 + (GD_NSNULLABLE NSString*)pathForManagerFromCPath: (NSString*) filePath;
416 
417 /* \cond DOXYGEN_IGNORE */
418 #if __has_extension(attribute_deprecated_with_message)
419 # define DEPRECATE_EXP_LOGFILE_TO_DOC_FOLDER __attribute__((deprecated("Will be removed.")))
420 #else
421 # define DEPRECATE_EXP_LOGFILE_TO_DOC_FOLDER __attribute__((deprecated))
422 #endif
423 /* \endcond */
424 
442 + (BOOL)exportLogFileToDocumentsFolder:(NSError**)error DEPRECATE_EXP_LOGFILE_TO_DOC_FOLDER;
443 
444 /* \cond DOXYGEN_IGNORE */
445 #if __has_extension(attribute_deprecated_with_message)
446 # define DEPRECATE_UPLOAD_LOGS __attribute__((deprecated("Use startUpload in GDLogManager instead.")))
447 #else
448 # define DEPRECATE_UPLOAD_LOGS __attribute__((deprecated))
449 #endif
450 /* \endcond */
451 
473 + (BOOL)uploadLogs:(NSError**) error DEPRECATE_UPLOAD_LOGS;
474 
475 // Working with directories.
476 
477 - (GD_NSNULLABLE NSURL *)URLForDirectory:(NSSearchPathDirectory)directory inDomain:(NSSearchPathDomainMask)domain appropriateForURL:(GD_NSNULLABLE NSURL *)url create:(BOOL)shouldCreate error:(NSError **)error;
478 
479 - (GD_NSArray(NSURL *) *)URLsForDirectory:(NSSearchPathDirectory)directory inDomains:(NSSearchPathDomainMask)domainMask;
480 
488 - (nullable NSURL *)containerURLForSecurityApplicationGroupIdentifier:(NSString *)groupIdentifier;
489 
490 - (GD_NSNULLABLE GD_NSArray(NSURL*)*)contentsOfDirectoryAtURL:(NSURL *)url includingPropertiesForKeys:(GD_NSNULLABLE GD_NSArray(GD_NSURLResourceKey)*)keys options:(NSDirectoryEnumerationOptions)mask error:(NSError **)error;
491 
492 - (GD_NSNULLABLE GD_NSArray(NSString*)*)contentsOfDirectoryAtPath:(NSString *)path error:(NSError **)error;
493 
494 - (GD_NSNULLABLE GD_NSDirectoryEnumerator(NSURL *) *)enumeratorAtURL:(NSURL *)url includingPropertiesForKeys:(GD_NSNULLABLE GD_NSArray(GD_NSURLResourceKey) *)keys options:(NSDirectoryEnumerationOptions)mask errorHandler:(GD_NSNULLABLE BOOL (^)(NSURL * url, NSError * error))handler;
495 
496 - (GD_NSNULLABLE GD_NSDirectoryEnumerator(NSString *) *)enumeratorAtPath:(NSString *)path;
497 
498 - (GD_NSNULLABLE GD_NSArray(NSString*) *)subpathsOfDirectoryAtPath:( NSString *)pathRaw error:(NSError **)error;
499 
500 - (GD_NSNULLABLE GD_NSArray(NSString*) *)subpathsAtPath:( NSString *)path;
501 
502 // Creating and deleting items.
503 
504 - (BOOL)createDirectoryAtURL:( NSURL *)url withIntermediateDirectories:(BOOL)createIntermediates attributes:(GD_NSNULLABLE GD_NSDictionary(NSString*, id)*)attributes error:(NSError **)error;
505 
506 - (BOOL)createDirectoryAtPath:( NSString*)path withIntermediateDirectories:(BOOL) createIntermediates attributes:(GD_NSNULLABLE GD_NSDictionary(NSString*, id)*)attributes error:(NSError **)error;
507 
508 - (BOOL)createFileAtPath:( NSString *)path contents:(GD_NSNULLABLE NSData *)contents attributes:(GD_NSNULLABLE GD_NSDictionary(NSString*, id)*)attributes;
509 
510 - (BOOL)removeItemAtURL:( NSURL *)URL error:(NSError **)error;
511 
512 - (BOOL)removeItemAtPath:( NSString*)filePath error:(NSError **)error;
513 
514 - (BOOL)replaceItemAtURL:( NSURL *)originalItemURL withItemAtURL:( NSURL *)newItemURL backupItemName:(GD_NSNULLABLE NSString *)backupItemName options:(NSFileManagerItemReplacementOptions)options resultingItemURL:(NSURL * GD_NSNULLABLE_POINTER * GD_NSNULLABLE_POINTER)resultingURL error:(NSError **)error;
515 
516 // Moving and copying items.
517 
518 - (BOOL)copyItemAtURL:( NSURL *)srcURL toURL:( NSURL *)dstURL error:(NSError **)error;
519 
520 - (BOOL)copyItemAtPath:( NSString *)srcPath toPath:( NSString *)dstPath error:(NSError **)error;
521 
522 - (BOOL)moveItemAtURL:( NSURL *)srcURL toURL:( NSURL *)dstURL error:(NSError **)error;
523 
524 - (BOOL)moveItemAtPath:( NSString*)srcPath toPath:( NSString*)dstPath error:(NSError **)error;
525 
526 
527 #if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
528 //Getting home directory details.
529 
539 #if defined(__MAC_10_12)
540 - (GD_NSNULLABLE NSURL *)homeDirectoryForUser:(NSString *)userName GD_API_AVAILABLE(macosx(10.12)) GD_API_UNAVAILABLE(ios, watchos, tvos);
541 #endif
542 #endif
543 
544 // Unavailable API elements.
545 // iCloud - unsupported
546 
554 @property(GD_NSNULLABLE_PROP readonly, copy, atomic) id<NSObject, NSCopying, NSCoding> ubiquityIdentityToken;
555 
563 - (GD_NSNULLABLE NSURL *)URLForUbiquityContainerIdentifier:(GD_NSNULLABLE NSString *)containerIdentifier;
564 
572 - (BOOL)isUbiquitousItemAtURL:( NSURL *)url;
573 
582 - (BOOL)setUbiquitous:(BOOL)flag itemAtURL:( NSURL *)url destinationURL:( NSURL *)destinationURL error:(NSError **)error;
583 
592 - (BOOL)startDownloadingUbiquitousItemAtURL:( NSURL *)url error:(NSError **)error;
593 
602 - (BOOL)evictUbiquitousItemAtURL:( NSURL *)url error:(NSError **)error;
603 
612 - (GD_NSNULLABLE NSURL *)URLForPublishingUbiquitousItemAtURL:( NSURL *)url expirationDate:(NSDate * GD_NSNULLABLE_POINTER * GD_NSNULLABLE_POINTER)outDate error:(NSError **)error;
613 
625 #if defined(__MAC_10_13) || defined(__IPHONE_11_0)
626 - (void)getFileProviderServicesForItemAtURL:(NSURL *)url completionHandler:(void (^)(GD_NSDictionary(NSFileProviderServiceName,NSFileProviderService *) *services, NSError *error))completionHandler UNAVAILABLE_IN_GDFILEMANAGER;
627 
628 #endif
629 
637 #if defined(__MAC_10_12) || defined(__IPHONE_10_0)
638 @property(readonly, copy, atomic) NSURL *temporaryDirectory UNAVAILABLE_IN_GDFILEMANAGER;
639 #endif
640 
641 // Linking.
642 
643 - (BOOL)createSymbolicLinkAtURL:( NSURL *)url withDestinationURL:( NSURL *)destURL error:(NSError **)error;
644 
645 - (BOOL)createSymbolicLinkAtPath:( NSString *)path withDestinationPath:( NSString *)destPath error:(NSError **)error;
646 
647 - (BOOL)linkItemAtURL:( NSURL *)srcURL toURL:( NSURL *)dstURL error:(NSError **)error;
648 
649 - (BOOL)linkItemAtPath:( NSString *)srcPath toPath:( NSString *)dstPath error:(NSError **)error;
650 
651 - (GD_NSNULLABLE NSString *)destinationOfSymbolicLinkAtPath:( NSString *)path error:(NSError **)error;
652 
653 // Determining access.
654 
655 - (BOOL)fileExistsAtPath:( NSString *)path;
656 
657 - (BOOL)fileExistsAtPath:( NSString*)path isDirectory:(GD_NSNULLABLE BOOL*)isDirectory;
658 
659 - (BOOL)isReadableFileAtPath:( NSString *)path;
660 
661 - (BOOL)isWritableFileAtPath:( NSString *)path;
662 
663 - (BOOL)isExecutableFileAtPath:( NSString *)path;
664 
665 - (BOOL)isDeletableFileAtPath:( NSString *)path;
666 
667 - (GD_NSNULLABLE GD_NSDictionary(GD_NSFileAttributeKey, id) *)attributesOfItemAtPath:( NSString *)path error:(NSError **)error;
668 
669 - (GD_NSNULLABLE GD_NSDictionary(GD_NSFileAttributeKey, id) *)attributesOfFileSystemForPath:( NSString *)path error:(NSError **)error;
670 
671 - (BOOL)setAttributes:( GD_NSDictionary(GD_NSFileAttributeKey, id) *)attributes ofItemAtPath:( NSString *)path error:(NSError **)error;
672 
673 // Getting file contents.
674 
675 - (GD_NSNULLABLE NSData *)contentsAtPath:( NSString *)path;
676 
677 - (BOOL)contentsEqualAtPath:( NSString *)path1 andPath:( NSString *)path2;
678 
679 // Converting paths to strings.
680 
681 - ( const char *)fileSystemRepresentationWithPath:( NSString *)path NS_RETURNS_INNER_POINTER;
682 
683 - ( NSString *)stringWithFileSystemRepresentation:( const char *)string length:(NSUInteger)len;
684 
685 // Get and set the current working directory of the program.
686 
687 - (BOOL)changeCurrentDirectoryPath:( NSString *)path;
688 
689 - ( NSString *)currentDirectoryPath;
690 
691 // Deprecated methods
692 
699 - (BOOL)changeFileAttributes:( NSDictionary *)attributes atPath:( NSString *)path DEPRECATED_IN_NSFILEMANAGER;
700 
707 - (GD_NSNULLABLE NSDictionary *)fileAttributesAtPath:( NSString *)path traverseLink:(BOOL)flag DEPRECATED_IN_NSFILEMANAGER;
708 
715 - (GD_NSNULLABLE NSDictionary *)fileSystemAttributesAtPath:( NSString *)path DEPRECATED_IN_NSFILEMANAGER;
716 
723 - (GD_NSNULLABLE NSArray *)directoryContentsAtPath:( NSString *)path DEPRECATED_IN_NSFILEMANAGER;
724 
731 - (BOOL)createDirectoryAtPath:( NSString *)path attributes:( NSDictionary *)attributes DEPRECATED_IN_NSFILEMANAGER;
732 
739 - (BOOL)createSymbolicLinkAtPath:( NSString *)path pathContent:( NSString *)otherPath DEPRECATED_IN_NSFILEMANAGER;
740 
747 - (GD_NSNULLABLE NSString *)pathContentOfSymbolicLinkAtPath:( NSString *)path DEPRECATED_IN_NSFILEMANAGER;
748 
749 @end
750 
GD_NSNULLABLE
#define GD_NSNULLABLE
Definition: GDPortability.h:71
GD_NSFileAttributeKey
#define GD_NSFileAttributeKey
Definition: GDFileManager.h:31
GDFileManagerErrorNotSupported
@ GDFileManagerErrorNotSupported
Attempt to utilize unsupported interface.
Definition: GDFileManager.h:96
GD_NSNULLABLE_PROP
#define GD_NSNULLABLE_PROP
Definition: GDPortability.h:70
GDFileManagerErrorICloudNotSupported
@ GDFileManagerErrorICloudNotSupported
Attempt to access "Ubiquitous" file or directory, i.e. one that is in "cloud" storage.
Definition: GDFileManager.h:76
GDFileManagerErrorType
GDFileManagerErrorType
Definition: GDFileManager.h:50
GDFileManagerErrorIOError
@ GDFileManagerErrorIOError
Input or output error occurred during a low-level read or write operation.
Definition: GDFileManager.h:59
GDFileManagerErrorInvalidFileURL
@ GDFileManagerErrorInvalidFileURL
The URL passed in was not a valid file URL.
Definition: GDFileManager.h:92
GDFileManagerErrorUnknownError
@ GDFileManagerErrorUnknownError
An unknown error occured.
Definition: GDFileManager.h:100
GDFileManagerErrorDeleteBackupError
@ GDFileManagerErrorDeleteBackupError
Unable to delete backup.
Definition: GDFileManager.h:84
GDFileManagerErrorDirectoryNotEmpty
@ GDFileManagerErrorDirectoryNotEmpty
Attempt to delete a directory that was not empty.
Definition: GDFileManager.h:67
GD_NSDirectoryEnumerator
#define GD_NSDirectoryEnumerator(ObjectType)
Definition: GDPortability.h:118
GDCWriteStream
NSOutputStream subclass for writing files in the secure store.
Definition: GDCWriteStream.h:34
GDFileManagerErrorPathAlreadyExists
@ GDFileManagerErrorPathAlreadyExists
Specified path already exists.
Definition: GDFileManager.h:80
GDCWriteStream.h
GDCReadStream.h
GD_NSNULLABLE_POINTER
#define GD_NSNULLABLE_POINTER
Definition: GDPortability.h:77
GDFileManagerErrorPermissionError
@ GDFileManagerErrorPermissionError
Permissions error when attempting to access part of the filesystem.
Definition: GDFileManager.h:63
GDFileManagerErrorPathDoesNotExist
@ GDFileManagerErrorPathDoesNotExist
Specified path does not exist.
Definition: GDFileManager.h:54
GDFileManager
Secure File System.
Definition: GDFileManager.h:308
GD_NS_ASSUME_NONNULL_END
#define GD_NS_ASSUME_NONNULL_END
Definition: GDPortability.h:89
GD_NSURLResourceKey
#define GD_NSURLResourceKey
Definition: GDFileManager.h:32
GDFileManagerErrorPreservingMetadata
@ GDFileManagerErrorPreservingMetadata
Unable to preserve metadata from original file.
Definition: GDFileManager.h:88
GD_NSArray
#define GD_NSArray(ObjectType)
Definition: GDPortability.h:112
GD_NSDictionary
#define GD_NSDictionary(KeyType, ObjectType)
Definition: GDPortability.h:109
GDFileManagerErrorPathError
@ GDFileManagerErrorPathError
There was a problem with the path.
Definition: GDFileManager.h:71
GDFileManagerErrorDomain
NSString *const GDFileManagerErrorDomain
Error domain for file system errors.
GDCReadStream
NSInputStream subclass for reading files that are in the secure store.
Definition: GDCReadStream.h:47
GD_NS_ASSUME_NONNULL_BEGIN
#define GD_NS_ASSUME_NONNULL_BEGIN
Definition: GDPortability.h:88
GDPortability.h