blackberry.com
BlackBerry Dynamics
Runtime library for iOS applications
from the application developer portal

GDFileManager.h

Go to the documentation of this file.
00001 /*
00002  * (c) 2018 BlackBerry Limited. All rights reserved.
00003  */
00004 
00005 #import <Foundation/Foundation.h>
00006 #import "GDCReadStream.h"
00007 #import "GDCWriteStream.h"
00008 #import "GDPortability.h"
00009 
00010 #if __has_extension(attribute_deprecated_with_message)
00011 #   define DEPRECATED_IN_NSFILEMANAGER __attribute__((deprecated("Deprecated in NSFileManager. Do not use.")))
00012 #else
00013 #   define DEPRECATED_IN_NSFILEMANAGER __attribute__((deprecated))
00014 #endif
00015 
00016 #if __has_extension(attribute_unavailable_with_message)
00017 #   define UNAVAILABLE_IN_GDFILEMANAGER __attribute__((unavailable("Unavailable in GDFileManager. Do not use.")))
00018 #else
00019 #   define UNAVAILABLE_IN_GDFILEMANAGER __attribute__((deprecated))
00020 #endif
00021 
00022 #if (defined(__MAC_10_12) && defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12)\
00023  || (defined(__IPHONE_10_0) && defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0)
00024 #   define GD_NSFileAttributeKey NSFileAttributeKey
00025 #   define GD_NSURLResourceKey NSURLResourceKey
00026 #else
00027 #   define GD_NSFileAttributeKey NSString *
00028 #   define GD_NSURLResourceKey NSString *
00029 #endif
00030 
00040 GD_NS_ASSUME_NONNULL_BEGIN
00041 
00044 extern NSString* const GDFileManagerErrorDomain;
00045 
00046 typedef NS_ENUM(NSInteger, GDFileManagerErrorType)
00047 {
00050     GDFileManagerErrorPathDoesNotExist = 100,
00051     
00055     GDFileManagerErrorIOError         = 101,
00056     
00059     GDFileManagerErrorPermissionError = 102,
00060     
00063     GDFileManagerErrorDirectoryNotEmpty     = 103,
00064     
00067     GDFileManagerErrorPathError  = 104,
00068     
00072     GDFileManagerErrorICloudNotSupported  = 105,
00073     
00076     GDFileManagerErrorPathAlreadyExists  = 106,
00077     
00080     GDFileManagerErrorDeleteBackupError = 107,
00081     
00084     GDFileManagerErrorPreservingMetadata = 108,
00085     
00088     GDFileManagerErrorInvalidFileURL = 109,
00089     
00092     GDFileManagerErrorNotSupported  = 110,
00093     
00096     GDFileManagerErrorUnknownError    = 500
00097 };
00098 
00306 @interface GDFileManager : NSFileManager <NSStreamDelegate>
00307 {
00308 
00309 }
00310 
00311 + (GDFileManager *)defaultManager;
00312 
00327 + (GD_NSNULLABLE GDCReadStream*) getReadStream:(NSString*)filePath error:(NSError** ) error;
00328 
00350 + (GD_NSNULLABLE GDCWriteStream*) getWriteStream:(NSString*)filePath appendmode:(BOOL) flag error:(NSError**) error;
00351 
00363 + (GD_NSNULLABLE NSString*)getAbsoluteEncryptedPath:(NSString*)filePath;
00364 
00387 + (GD_NSNULLABLE NSString*)pathForCFromManagerPath: (NSString*) filePath;
00388 
00413 + (GD_NSNULLABLE NSString*)pathForManagerFromCPath: (NSString*) filePath;
00414 
00415 #if __has_extension(attribute_deprecated_with_message)
00416 #   define DEPRECATE_EXP_LOGFILE_TO_DOC_FOLDER __attribute__((deprecated("Will be removed.")))
00417 #else
00418 #   define DEPRECATE_EXP_LOGFILE_TO_DOC_FOLDER __attribute__((deprecated))
00419 #endif
00420 
00438 + (BOOL)exportLogFileToDocumentsFolder:(NSError**)error DEPRECATE_EXP_LOGFILE_TO_DOC_FOLDER;
00439 
00440 #if __has_extension(attribute_deprecated_with_message)
00441 #   define DEPRECATE_UPLOAD_LOGS __attribute__((deprecated("Use startUpload in GDLogManager instead.")))
00442 #else
00443 #   define DEPRECATE_UPLOAD_LOGS __attribute__((deprecated))
00444 #endif
00445 
00467 + (BOOL)uploadLogs:(NSError**) error DEPRECATE_UPLOAD_LOGS;
00468 
00469 // Working with directories.
00470 
00471 - (GD_NSNULLABLE NSURL *)URLForDirectory:(NSSearchPathDirectory)directory inDomain:(NSSearchPathDomainMask)domain appropriateForURL:(GD_NSNULLABLE NSURL *)url create:(BOOL)shouldCreate error:(NSError **)error;
00472 
00473 - (GD_NSArray(NSURL *) *)URLsForDirectory:(NSSearchPathDirectory)directory inDomains:(NSSearchPathDomainMask)domainMask;
00474 
00482 - (NSURL *)containerURLForSecurityApplicationGroupIdentifier:(NSString *)groupIdentifier;
00483 
00484 - (GD_NSNULLABLE GD_NSArray(NSURL*)*)contentsOfDirectoryAtURL:(NSURL *)url includingPropertiesForKeys:(GD_NSNULLABLE GD_NSArray(GD_NSURLResourceKey)*)keys options:(NSDirectoryEnumerationOptions)mask error:(NSError **)error;
00485 
00486 - (GD_NSNULLABLE GD_NSArray(NSString*)*)contentsOfDirectoryAtPath:(NSString *)path error:(NSError **)error;
00487 
00488 - (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;
00489 
00490 - (GD_NSNULLABLE GD_NSDirectoryEnumerator(NSString *) *)enumeratorAtPath:(NSString *)path;
00491 
00492 - (GD_NSNULLABLE GD_NSArray(NSString*) *)subpathsOfDirectoryAtPath:( NSString *)pathRaw error:(NSError **)error;
00493 
00494 - (GD_NSNULLABLE GD_NSArray(NSString*) *)subpathsAtPath:( NSString *)path;
00495 
00496 // Creating and deleting items.
00497 
00498 - (BOOL)createDirectoryAtURL:( NSURL *)url withIntermediateDirectories:(BOOL)createIntermediates attributes:(GD_NSNULLABLE GD_NSDictionary(NSString*, id)*)attributes error:(NSError **)error;
00499 
00500 - (BOOL)createDirectoryAtPath:( NSString*)path withIntermediateDirectories:(BOOL) createIntermediates attributes:(GD_NSNULLABLE GD_NSDictionary(NSString*, id)*)attributes error:(NSError **)error;
00501 
00502 - (BOOL)createFileAtPath:( NSString *)path contents:(GD_NSNULLABLE NSData *)contents attributes:(GD_NSNULLABLE GD_NSDictionary(NSString*, id)*)attributes;
00503 
00504 - (BOOL)removeItemAtURL:( NSURL *)URL error:(NSError **)error;
00505 
00506 - (BOOL)removeItemAtPath:( NSString*)filePath error:(NSError **)error;
00507 
00508 - (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;
00509 
00510 // Moving and copying items.
00511 
00512 - (BOOL)copyItemAtURL:( NSURL *)srcURL toURL:( NSURL *)dstURL error:(NSError **)error;
00513 
00514 - (BOOL)copyItemAtPath:( NSString *)srcPath toPath:( NSString *)dstPath error:(NSError **)error;
00515 
00516 - (BOOL)moveItemAtURL:( NSURL *)srcURL toURL:( NSURL *)dstURL error:(NSError **)error;
00517 
00518 - (BOOL)moveItemAtPath:( NSString*)srcPath toPath:( NSString*)dstPath error:(NSError **)error;
00519 
00520 
00521 #if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
00522 //Getting home directory details.
00523 
00533 #if defined(__MAC_10_12)
00534 - (GD_NSNULLABLE NSURL *)homeDirectoryForUser:(NSString *)userName GD_API_AVAILABLE(macosx(10.12)) GD_API_UNAVAILABLE(ios, watchos, tvos);
00535 #endif
00536 #endif
00537 
00538 // Unavailable API elements.
00539 // iCloud - unsupported
00540 
00548 @property(GD_NSNULLABLE_PROP readonly, copy, atomic) id<NSObject, NSCopying, NSCoding> ubiquityIdentityToken;
00549 
00557 - (GD_NSNULLABLE NSURL *)URLForUbiquityContainerIdentifier:(GD_NSNULLABLE NSString *)containerIdentifier;
00558 
00566 - (BOOL)isUbiquitousItemAtURL:( NSURL *)url;
00567 
00576 - (BOOL)setUbiquitous:(BOOL)flag itemAtURL:( NSURL *)url destinationURL:( NSURL *)destinationURL error:(NSError **)error;
00577 
00586 - (BOOL)startDownloadingUbiquitousItemAtURL:( NSURL *)url error:(NSError **)error;
00587 
00596 - (BOOL)evictUbiquitousItemAtURL:( NSURL *)url error:(NSError **)error;
00597 
00606 - (GD_NSNULLABLE NSURL *)URLForPublishingUbiquitousItemAtURL:( NSURL *)url expirationDate:(NSDate * GD_NSNULLABLE_POINTER * GD_NSNULLABLE_POINTER)outDate error:(NSError **)error;
00607 
00619 #if defined(__MAC_10_13) || defined(__IPHONE_11_0)
00620 - (void)getFileProviderServicesForItemAtURL:(NSURL *)url completionHandler:(void (^)(GD_NSDictionary(NSFileProviderServiceName,NSFileProviderService *) *services, NSError *error))completionHandler UNAVAILABLE_IN_GDFILEMANAGER;
00621 
00622 #endif
00623 
00631 #if defined(__MAC_10_12) || defined(__IPHONE_10_0)
00632 @property(readonly, copy, atomic) NSURL *temporaryDirectory UNAVAILABLE_IN_GDFILEMANAGER;
00633 #endif
00634 
00635 // Linking.
00636 
00637 - (BOOL)createSymbolicLinkAtURL:( NSURL *)url withDestinationURL:( NSURL *)destURL error:(NSError **)error;
00638 
00639 - (BOOL)createSymbolicLinkAtPath:( NSString *)path withDestinationPath:( NSString *)destPath error:(NSError **)error;
00640 
00641 - (BOOL)linkItemAtURL:( NSURL *)srcURL toURL:( NSURL *)dstURL error:(NSError **)error;
00642 
00643 - (BOOL)linkItemAtPath:( NSString *)srcPath toPath:( NSString *)dstPath error:(NSError **)error;
00644 
00645 - (GD_NSNULLABLE NSString *)destinationOfSymbolicLinkAtPath:( NSString *)path error:(NSError **)error;
00646 
00647 // Determining access.
00648 
00649 - (BOOL)fileExistsAtPath:( NSString *)path;
00650 
00651 - (BOOL)fileExistsAtPath:( NSString*)path isDirectory:(GD_NSNULLABLE BOOL*)isDirectory;
00652 
00653 - (BOOL)isReadableFileAtPath:( NSString *)path;
00654 
00655 - (BOOL)isWritableFileAtPath:( NSString *)path;
00656 
00657 - (BOOL)isExecutableFileAtPath:( NSString *)path;
00658 
00659 - (BOOL)isDeletableFileAtPath:( NSString *)path;
00660 
00661 - (GD_NSNULLABLE GD_NSDictionary(GD_NSFileAttributeKey, id) *)attributesOfItemAtPath:( NSString *)path error:(NSError **)error;
00662 
00663 - (GD_NSNULLABLE GD_NSDictionary(GD_NSFileAttributeKey, id) *)attributesOfFileSystemForPath:( NSString *)path error:(NSError **)error;
00664 
00665 - (BOOL)setAttributes:( GD_NSDictionary(GD_NSFileAttributeKey, id) *)attributes ofItemAtPath:( NSString *)path error:(NSError **)error;
00666 
00667 // Getting file contents.
00668 
00669 - (GD_NSNULLABLE NSData *)contentsAtPath:( NSString *)path;
00670 
00671 - (BOOL)contentsEqualAtPath:( NSString *)path1 andPath:( NSString *)path2;
00672 
00673 // Converting paths to strings.
00674 
00675 - ( const char *)fileSystemRepresentationWithPath:( NSString *)path NS_RETURNS_INNER_POINTER;
00676 
00677 - ( NSString *)stringWithFileSystemRepresentation:( const char *)string length:(NSUInteger)len;
00678 
00679 // Get and set the current working directory of the program.
00680 
00681 - (BOOL)changeCurrentDirectoryPath:( NSString *)path;
00682 
00683 - ( NSString *)currentDirectoryPath;
00684 
00685 // Deprecated methods
00686 
00693 - (BOOL)changeFileAttributes:( NSDictionary *)attributes atPath:( NSString *)path DEPRECATED_IN_NSFILEMANAGER;
00694 
00701 - (GD_NSNULLABLE NSDictionary *)fileAttributesAtPath:( NSString *)path traverseLink:(BOOL)flag DEPRECATED_IN_NSFILEMANAGER;
00702 
00709 - (GD_NSNULLABLE NSDictionary *)fileSystemAttributesAtPath:( NSString *)path  DEPRECATED_IN_NSFILEMANAGER;
00710 
00717 - (GD_NSNULLABLE NSArray *)directoryContentsAtPath:( NSString *)path DEPRECATED_IN_NSFILEMANAGER;
00718 
00725 - (BOOL)createDirectoryAtPath:( NSString *)path attributes:( NSDictionary *)attributes DEPRECATED_IN_NSFILEMANAGER;
00726 
00733 - (BOOL)createSymbolicLinkAtPath:( NSString *)path pathContent:( NSString *)otherPath DEPRECATED_IN_NSFILEMANAGER;
00734 
00741 - (GD_NSNULLABLE NSString *)pathContentOfSymbolicLinkAtPath:( NSString *)path  DEPRECATED_IN_NSFILEMANAGER;
00742 
00743 @end
00744 
00745 GD_NS_ASSUME_NONNULL_END