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

GDFileManager.h

Go to the documentation of this file.
00001 /*
00002  * (c) 2017 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 (defined(__MAC_10_12) && defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12)\
00017  || (defined(__IPHONE_10_0) && defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0)
00018 #   define GD_NSFileAttributeKey NSFileAttributeKey
00019 #   define GD_NSURLResourceKey NSURLResourceKey
00020 #else
00021 #   define GD_NSFileAttributeKey NSString *
00022 #   define GD_NSURLResourceKey NSString *
00023 #endif
00024 
00034 GD_NS_ASSUME_NONNULL_BEGIN
00035 
00038 extern NSString* const GDFileManagerErrorDomain;
00039 
00040 typedef NS_ENUM(NSInteger, GDFileManagerErrorType)
00041 {
00044     GDFileManagerErrorPathDoesNotExist = 100,
00045     
00049     GDFileManagerErrorIOError         = 101,
00050     
00053     GDFileManagerErrorPermissionError = 102,
00054     
00057     GDFileManagerErrorDirectoryNotEmpty     = 103,
00058     
00061     GDFileManagerErrorPathError  = 104,
00062     
00066     GDFileManagerErrorICloudNotSupported  = 105,
00067     
00070     GDFileManagerErrorPathAlreadyExists  = 106,
00071     
00074     GDFileManagerErrorDeleteBackupError = 107,
00075     
00078     GDFileManagerErrorPreservingMetadata = 108,
00079     
00082     GDFileManagerErrorInvalidFileURL = 109,
00083     
00086     GDFileManagerErrorUnknownError    = 500
00087 };
00088 
00271 @interface GDFileManager : NSFileManager <NSStreamDelegate>
00272 {
00273 
00274 }
00275 
00276 + (GDFileManager *)defaultManager;
00277 
00292 + (GD_NSNULLABLE GDCReadStream*) getReadStream:(NSString*)filePath error:(NSError** ) error;
00293 
00315 + (GD_NSNULLABLE GDCWriteStream*) getWriteStream:(NSString*)filePath appendmode:(BOOL) flag error:(NSError**) error;
00316 
00328 + (GD_NSNULLABLE NSString*)getAbsoluteEncryptedPath:(NSString*)filePath;
00329 
00352 + (GD_NSNULLABLE NSString*)pathForCFromManagerPath: (NSString*) filePath;
00353 
00378 + (GD_NSNULLABLE NSString*)pathForManagerFromCPath: (NSString*) filePath;
00379 
00380 #if __has_extension(attribute_deprecated_with_message)
00381 #   define DEPRECATE_EXP_LOGFILE_TO_DOC_FOLDER __attribute__((deprecated("Will be removed.")))
00382 #else
00383 #   define DEPRECATE_EXP_LOGFILE_TO_DOC_FOLDER __attribute__((deprecated))
00384 #endif
00385 
00402 + (BOOL)exportLogFileToDocumentsFolder:(NSError**)error DEPRECATE_EXP_LOGFILE_TO_DOC_FOLDER;
00403 
00404 #if __has_extension(attribute_deprecated_with_message)
00405 #   define DEPRECATE_UPLOAD_LOGS __attribute__((deprecated("Use startUpload in GDLogManager instead.")))
00406 #else
00407 #   define DEPRECATE_UPLOAD_LOGS __attribute__((deprecated))
00408 #endif
00409 
00431 + (BOOL)uploadLogs:(NSError**) error DEPRECATE_UPLOAD_LOGS;
00432 
00433 // Working with directories.
00434 
00435 - (GD_NSNULLABLE NSURL *)URLForDirectory:(NSSearchPathDirectory)directory inDomain:(NSSearchPathDomainMask)domain appropriateForURL:(GD_NSNULLABLE NSURL *)url create:(BOOL)shouldCreate error:(NSError **)error;
00436 
00437 - (GD_NSArray(NSURL *) *)URLsForDirectory:(NSSearchPathDirectory)directory inDomains:(NSSearchPathDomainMask)domainMask;
00438 
00439 - (GD_NSNULLABLE GD_NSArray(NSURL*)*)contentsOfDirectoryAtURL:(NSURL *)url includingPropertiesForKeys:(GD_NSNULLABLE GD_NSArray(GD_NSURLResourceKey)*)keys options:(NSDirectoryEnumerationOptions)mask error:(NSError **)error;
00440 
00441 - (GD_NSNULLABLE GD_NSArray(NSString*)*)contentsOfDirectoryAtPath:(NSString *)path error:(NSError **)error;
00442 
00443 - (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;
00444 
00445 - (GD_NSNULLABLE GD_NSDirectoryEnumerator(NSString *) *)enumeratorAtPath:(NSString *)path;
00446 
00447 - (GD_NSNULLABLE GD_NSArray(NSString*) *)subpathsOfDirectoryAtPath:( NSString *)pathRaw error:(NSError **)error;
00448 
00449 - (GD_NSNULLABLE GD_NSArray(NSString*) *)subpathsAtPath:( NSString *)path;
00450 
00451 // Creating and deleting items.
00452 
00453 - (BOOL)createDirectoryAtURL:( NSURL *)url withIntermediateDirectories:(BOOL)createIntermediates attributes:(GD_NSNULLABLE GD_NSDictionary(NSString*, id)*)attributes error:(NSError **)error;
00454 
00455 - (BOOL)createDirectoryAtPath:( NSString*)path withIntermediateDirectories:(BOOL) createIntermediates attributes:(GD_NSNULLABLE GD_NSDictionary(NSString*, id)*)attributes error:(NSError **)error;
00456 
00457 - (BOOL)createFileAtPath:( NSString *)path contents:(GD_NSNULLABLE NSData *)contents attributes:(GD_NSNULLABLE GD_NSDictionary(NSString*, id)*)attributes;
00458 
00459 - (BOOL)removeItemAtURL:( NSURL *)URL error:(NSError **)error;
00460 
00461 - (BOOL)removeItemAtPath:( NSString*)filePath error:(NSError **)error;
00462 
00463 - (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;
00464 
00465 // Moving and copying items.
00466 
00467 - (BOOL)copyItemAtURL:( NSURL *)srcURL toURL:( NSURL *)dstURL error:(NSError **)error;
00468 
00469 - (BOOL)copyItemAtPath:( NSString *)srcPath toPath:( NSString *)dstPath error:(NSError **)error;
00470 
00471 - (BOOL)moveItemAtURL:( NSURL *)srcURL toURL:( NSURL *)dstURL error:(NSError **)error;
00472 
00473 - (BOOL)moveItemAtPath:( NSString*)srcPath toPath:( NSString*)dstPath error:(NSError **)error;
00474 
00475 
00476 #if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
00477 //Getting home directory details.
00478 
00488 #if defined(__MAC_10_12)
00489 - (GD_NSNULLABLE NSURL *)homeDirectoryForUser:(NSString *)userName GD_API_AVAILABLE(macosx(10.12)) GD_API_UNAVAILABLE(ios, watchos, tvos);
00490 #endif
00491 #endif
00492 
00493 // Unavailable API elements.
00494 // iCloud - unsupported
00495 
00503 @property(GD_NSNULLABLE_PROP readonly, copy, atomic) id<NSObject, NSCopying, NSCoding> ubiquityIdentityToken;
00504 
00512 - (GD_NSNULLABLE NSURL *)URLForUbiquityContainerIdentifier:(GD_NSNULLABLE NSString *)containerIdentifier;
00513 
00521 - (BOOL)isUbiquitousItemAtURL:( NSURL *)url;
00522 
00531 - (BOOL)setUbiquitous:(BOOL)flag itemAtURL:( NSURL *)url destinationURL:( NSURL *)destinationURL error:(NSError **)error;
00532 
00541 - (BOOL)startDownloadingUbiquitousItemAtURL:( NSURL *)url error:(NSError **)error;
00542 
00551 - (BOOL)evictUbiquitousItemAtURL:( NSURL *)url error:(NSError **)error;
00552 
00561 - (GD_NSNULLABLE NSURL *)URLForPublishingUbiquitousItemAtURL:( NSURL *)url expirationDate:(NSDate * GD_NSNULLABLE_POINTER * GD_NSNULLABLE_POINTER)outDate error:(NSError **)error;
00562 
00563 
00564 // Linking.
00565 
00566 - (BOOL)createSymbolicLinkAtURL:( NSURL *)url withDestinationURL:( NSURL *)destURL error:(NSError **)error;
00567 
00568 - (BOOL)createSymbolicLinkAtPath:( NSString *)path withDestinationPath:( NSString *)destPath error:(NSError **)error;
00569 
00570 - (BOOL)linkItemAtURL:( NSURL *)srcURL toURL:( NSURL *)dstURL error:(NSError **)error;
00571 
00572 - (BOOL)linkItemAtPath:( NSString *)srcPath toPath:( NSString *)dstPath error:(NSError **)error;
00573 
00574 - (GD_NSNULLABLE NSString *)destinationOfSymbolicLinkAtPath:( NSString *)path error:(NSError **)error;
00575 
00576 // Determining access.
00577 
00578 - (BOOL)fileExistsAtPath:( NSString *)path;
00579 
00580 - (BOOL)fileExistsAtPath:( NSString*)path isDirectory:(GD_NSNULLABLE BOOL*)isDirectory;
00581 
00582 - (BOOL)isReadableFileAtPath:( NSString *)path;
00583 
00584 - (BOOL)isWritableFileAtPath:( NSString *)path;
00585 
00586 - (BOOL)isExecutableFileAtPath:( NSString *)path;
00587 
00588 - (BOOL)isDeletableFileAtPath:( NSString *)path;
00589 
00590 - (GD_NSNULLABLE GD_NSDictionary(GD_NSFileAttributeKey, id) *)attributesOfItemAtPath:( NSString *)path error:(NSError **)error;
00591 
00592 - (GD_NSNULLABLE GD_NSDictionary(GD_NSFileAttributeKey, id) *)attributesOfFileSystemForPath:( NSString *)path error:(NSError **)error;
00593 
00594 - (BOOL)setAttributes:( GD_NSDictionary(GD_NSFileAttributeKey, id) *)attributes ofItemAtPath:( NSString *)path error:(NSError **)error;
00595 
00596 // Getting file contents.
00597 
00598 - (GD_NSNULLABLE NSData *)contentsAtPath:( NSString *)path;
00599 
00600 - (BOOL)contentsEqualAtPath:( NSString *)path1 andPath:( NSString *)path2;
00601 
00602 // Converting paths to strings.
00603 
00604 - ( const char *)fileSystemRepresentationWithPath:( NSString *)path NS_RETURNS_INNER_POINTER;
00605 
00606 - ( NSString *)stringWithFileSystemRepresentation:( const char *)string length:(NSUInteger)len;
00607 
00608 // Get and set the current working directory of the program.
00609 
00610 - (BOOL)changeCurrentDirectoryPath:( NSString *)path;
00611 
00612 - ( NSString *)currentDirectoryPath;
00613 
00614 // Deprecated methods
00615 
00622 - (BOOL)changeFileAttributes:( NSDictionary *)attributes atPath:( NSString *)path DEPRECATED_IN_NSFILEMANAGER;
00623 
00630 - (GD_NSNULLABLE NSDictionary *)fileAttributesAtPath:( NSString *)path traverseLink:(BOOL)flag DEPRECATED_IN_NSFILEMANAGER;
00631 
00638 - (GD_NSNULLABLE NSDictionary *)fileSystemAttributesAtPath:( NSString *)path  DEPRECATED_IN_NSFILEMANAGER;
00639 
00646 - (GD_NSNULLABLE NSArray *)directoryContentsAtPath:( NSString *)path DEPRECATED_IN_NSFILEMANAGER;
00647 
00654 - (BOOL)createDirectoryAtPath:( NSString *)path attributes:( NSDictionary *)attributes DEPRECATED_IN_NSFILEMANAGER;
00655 
00662 - (BOOL)createSymbolicLinkAtPath:( NSString *)path pathContent:( NSString *)otherPath DEPRECATED_IN_NSFILEMANAGER;
00663 
00670 - (GD_NSNULLABLE NSString *)pathContentOfSymbolicLinkAtPath:( NSString *)path  DEPRECATED_IN_NSFILEMANAGER;
00671 
00672 @end
00673 
00674 GD_NS_ASSUME_NONNULL_END