• BlackBerry Dynamics
  • Runtime library for iOS applications
  • 12.0.1.79
GDFileManager.h
Go to the documentation of this file.
1 /*
2  * Copyright 2023 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 
268 @interface GDFileManager : NSFileManager <NSStreamDelegate>
269 {
270 
271 }
272 
273 + (GDFileManager *)defaultManager;
274 
289 + (nullable GDCReadStream*) getReadStream:(NSString*)filePath error:(NSError** ) error;
290 
312 + (nullable GDCWriteStream*) getWriteStream:(NSString*)filePath appendmode:(BOOL) flag error:(NSError**) error;
313 
325 + (nullable NSString*)getAbsoluteEncryptedPath:(NSString*)filePath;
326 
349 + (nullable NSString*)pathForCFromManagerPath: (NSString*) filePath;
350 
375 + (nullable NSString*)pathForManagerFromCPath: (NSString*) filePath;
376 
377 /* \cond DOXYGEN_IGNORE */
378 #if __has_extension(attribute_deprecated_with_message)
379 # define DEPRECATE_EXP_LOGFILE_TO_DOC_FOLDER __attribute__((deprecated("Will be removed.")))
380 #else
381 # define DEPRECATE_EXP_LOGFILE_TO_DOC_FOLDER __attribute__((deprecated))
382 #endif
383 /* \endcond */
384 
402 + (BOOL)exportLogFileToDocumentsFolder:(NSError**)error DEPRECATE_EXP_LOGFILE_TO_DOC_FOLDER;
403 
404 // Working with directories.
405 
406 - (nullable NSURL *)URLForDirectory:(NSSearchPathDirectory)directory inDomain:(NSSearchPathDomainMask)domain appropriateForURL:(nullable NSURL *)url create:(BOOL)shouldCreate error:(NSError **)error;
407 
408 - (NSArray<NSURL *> *)URLsForDirectory:(NSSearchPathDirectory)directory inDomains:(NSSearchPathDomainMask)domainMask;
409 
417 - (nullable NSURL *)containerURLForSecurityApplicationGroupIdentifier:(NSString *)groupIdentifier;
418 
419 - (nullable NSArray<NSURL*>*)contentsOfDirectoryAtURL:(NSURL *)url includingPropertiesForKeys:(nullable NSArray<GD_NSURLResourceKey>*)keys options:(NSDirectoryEnumerationOptions)mask error:(NSError **)error;
420 
421 - (nullable NSArray<NSString*>*)contentsOfDirectoryAtPath:(NSString *)path error:(NSError **)error;
422 
423 - (nullable NSDirectoryEnumerator<NSURL *> *)enumeratorAtURL:(NSURL *)url includingPropertiesForKeys:(nullable NSArray<GD_NSURLResourceKey> *)keys options:(NSDirectoryEnumerationOptions)mask errorHandler:(nullable BOOL (^)(NSURL * url, NSError * error))handler;
424 
425 - (nullable NSDirectoryEnumerator<NSString *> *)enumeratorAtPath:(NSString *)path;
426 
427 - (nullable NSArray<NSString*> *)subpathsOfDirectoryAtPath:( NSString *)pathRaw error:(NSError **)error;
428 
429 - (nullable NSArray<NSString*> *)subpathsAtPath:( NSString *)path;
430 
431 // Creating and deleting items.
432 
433 - (BOOL)createDirectoryAtURL:( NSURL *)url withIntermediateDirectories:(BOOL)createIntermediates attributes:(nullable NSDictionary<NSString*, id>*)attributes error:(NSError **)error;
434 
435 - (BOOL)createDirectoryAtPath:( NSString*)path withIntermediateDirectories:(BOOL) createIntermediates attributes:(nullable NSDictionary<NSString*, id>*)attributes error:(NSError **)error;
436 
437 - (BOOL)createFileAtPath:( NSString *)path contents:(nullable NSData *)contents attributes:(nullable NSDictionary<NSString*, id>*)attributes;
438 
439 - (BOOL)removeItemAtURL:( NSURL *)URL error:(NSError **)error;
440 
441 - (BOOL)removeItemAtPath:( NSString*)filePath error:(NSError **)error;
442 
443 - (BOOL)replaceItemAtURL:( NSURL *)originalItemURL withItemAtURL:( NSURL *)newItemURL backupItemName:(nullable NSString *)backupItemName options:(NSFileManagerItemReplacementOptions)options resultingItemURL:(NSURL * _Nullable * _Nullable)resultingURL error:(NSError **)error;
444 
445 // Moving and copying items.
446 
447 - (BOOL)copyItemAtURL:( NSURL *)srcURL toURL:( NSURL *)dstURL error:(NSError **)error;
448 
449 - (BOOL)copyItemAtPath:( NSString *)srcPath toPath:( NSString *)dstPath error:(NSError **)error;
450 
451 - (BOOL)moveItemAtURL:( NSURL *)srcURL toURL:( NSURL *)dstURL error:(NSError **)error;
452 
453 - (BOOL)moveItemAtPath:( NSString*)srcPath toPath:( NSString*)dstPath error:(NSError **)error;
454 
455 
456 #if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
457 //Getting home directory details.
458 
468 #if defined(__MAC_10_12)
469 - (nullable NSURL *)homeDirectoryForUser:(NSString *)userName GD_API_AVAILABLE(macosx(10.12)) GD_API_UNAVAILABLE(ios, watchos, tvos);
470 #endif
471 #endif
472 
473 // Unavailable API elements.
474 // iCloud - unsupported
475 
483 @property(nullable, readonly, copy, atomic) id<NSObject, NSCopying, NSSecureCoding> ubiquityIdentityToken;
484 
492 - (nullable NSURL *)URLForUbiquityContainerIdentifier:(nullable NSString *)containerIdentifier;
493 
501 - (BOOL)isUbiquitousItemAtURL:( NSURL *)url;
502 
511 - (BOOL)setUbiquitous:(BOOL)flag itemAtURL:( NSURL *)url destinationURL:( NSURL *)destinationURL error:(NSError **)error;
512 
521 - (BOOL)startDownloadingUbiquitousItemAtURL:( NSURL *)url error:(NSError **)error;
522 
531 - (BOOL)evictUbiquitousItemAtURL:( NSURL *)url error:(NSError **)error;
532 
541 - (nullable NSURL *)URLForPublishingUbiquitousItemAtURL:( NSURL *)url expirationDate:(NSDate * _Nullable * _Nullable)outDate error:(NSError **)error;
542 
554 #if defined(__MAC_10_13) || defined(__IPHONE_11_0)
555 - (void)getFileProviderServicesForItemAtURL:(NSURL *)url completionHandler:(void (^)(NSDictionary<NSFileProviderServiceName,NSFileProviderService *> *services, NSError *error))completionHandler UNAVAILABLE_IN_GDFILEMANAGER;
556 
557 #endif
558 
566 #if defined(__MAC_10_12) || defined(__IPHONE_10_0)
567 @property(readonly, copy, atomic) NSURL *temporaryDirectory UNAVAILABLE_IN_GDFILEMANAGER;
568 #endif
569 
570 // Linking.
571 
572 - (BOOL)createSymbolicLinkAtURL:( NSURL *)url withDestinationURL:( NSURL *)destURL error:(NSError **)error;
573 
574 - (BOOL)createSymbolicLinkAtPath:( NSString *)path withDestinationPath:( NSString *)destPath error:(NSError **)error;
575 
576 - (BOOL)linkItemAtURL:( NSURL *)srcURL toURL:( NSURL *)dstURL error:(NSError **)error;
577 
578 - (BOOL)linkItemAtPath:( NSString *)srcPath toPath:( NSString *)dstPath error:(NSError **)error;
579 
580 - (nullable NSString *)destinationOfSymbolicLinkAtPath:( NSString *)path error:(NSError **)error;
581 
582 // Determining access.
583 
584 - (BOOL)fileExistsAtPath:( NSString *)path;
585 
586 - (BOOL)fileExistsAtPath:( NSString*)path isDirectory:(nullable BOOL*)isDirectory;
587 
588 - (BOOL)isReadableFileAtPath:( NSString *)path;
589 
590 - (BOOL)isWritableFileAtPath:( NSString *)path;
591 
592 - (BOOL)isExecutableFileAtPath:( NSString *)path;
593 
594 - (BOOL)isDeletableFileAtPath:( NSString *)path;
595 
596 - (nullable NSDictionary<GD_NSFileAttributeKey, id> *)attributesOfItemAtPath:( NSString *)path error:(NSError **)error;
597 
598 - (nullable NSDictionary<GD_NSFileAttributeKey, id> *)attributesOfFileSystemForPath:( NSString *)path error:(NSError **)error;
599 
600 - (BOOL)setAttributes:( NSDictionary<GD_NSFileAttributeKey, id> *)attributes ofItemAtPath:( NSString *)path error:(NSError **)error;
601 
602 // Getting file contents.
603 
604 - (nullable NSData *)contentsAtPath:( NSString *)path;
605 
606 - (BOOL)contentsEqualAtPath:( NSString *)path1 andPath:( NSString *)path2;
607 
608 // Converting paths to strings.
609 
610 - ( const char *)fileSystemRepresentationWithPath:( NSString *)path NS_RETURNS_INNER_POINTER;
611 
612 - ( NSString *)stringWithFileSystemRepresentation:( const char *)string length:(NSUInteger)len;
613 
614 // Get and set the current working directory of the program.
615 
616 - (BOOL)changeCurrentDirectoryPath:( NSString *)path;
617 
618 - ( NSString *)currentDirectoryPath;
619 
620 // Deprecated methods
621 
628 - (BOOL)changeFileAttributes:( NSDictionary *)attributes atPath:( NSString *)path DEPRECATED_IN_NSFILEMANAGER;
629 
636 - (nullable NSDictionary *)fileAttributesAtPath:( NSString *)path traverseLink:(BOOL)flag DEPRECATED_IN_NSFILEMANAGER;
637 
644 - (nullable NSDictionary *)fileSystemAttributesAtPath:( NSString *)path DEPRECATED_IN_NSFILEMANAGER;
645 
652 - (nullable NSArray *)directoryContentsAtPath:( NSString *)path DEPRECATED_IN_NSFILEMANAGER;
653 
660 - (BOOL)createDirectoryAtPath:( NSString *)path attributes:( NSDictionary *)attributes DEPRECATED_IN_NSFILEMANAGER;
661 
668 - (BOOL)createSymbolicLinkAtPath:( NSString *)path pathContent:( NSString *)otherPath DEPRECATED_IN_NSFILEMANAGER;
669 
676 - (nullable NSString *)pathContentOfSymbolicLinkAtPath:( NSString *)path DEPRECATED_IN_NSFILEMANAGER;
677 
678 @end
679 
680 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:36
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:268
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:49