ZDCDirectoryManager

@interface ZDCDirectoryManager : NSObject

Simple utility class to provide standardized URL’s for common local directories & for temp files.

  • The typical Application Support directory for the app.

    • macOS : ~/Library/Application Support/{Bundle Identifier}/
    • iOS : {App Sandbox}/Application Support/

    Files stored in this directory are persistent, and must be manually deleted by the application.

    Declaration

    Objective-C

    + (nonnull NSURL *)appSupportDirectoryURL;

    Swift

    class func appSupportDirectoryURL() -> URL
  • The typical Cache directory for the app.

    • mac OS : ~/Library/Caches/{Bundle Identifier}/
    • iOS : {App Sandbox}/Caches/

    Files stored in this directory are NOT persistent, and are eligible for deletion at the discretion of the OS.

    Declaration

    Objective-C

    + (nonnull NSURL *)appCacheDirectoryURL;

    Swift

    class func appCacheDirectoryURL() -> URL
  • The typical Temp directory for the app.

    This directory is used for temporary files which do not need to be persistent for long.

    Declaration

    Objective-C

    + (nonnull NSURL *)tempDirectoryURL;

    Swift

    class func tempDirectoryURL() -> URL
  • The ZeroDarkCloud framework attempts to keep all stored files within a few zdc folders. This method returns the top-level zdc directory for persistent files.

    • macOS : ~/Library/Application Support/{Bundle Identifier}/zdc/
    • iOS : {App Sandbox}/Application Support/zdc/

    Files stored in this directory are persistent, and must be manually deleted by the application.

    Declaration

    Objective-C

    + (nonnull NSURL *)zdcPersistentDirectoryURL;

    Swift

    class func zdcPersistentDirectoryURL() -> URL
  • The ZeroDarkCloud framework attempts to keep all stored files within a few zdc folders. This method returns the top-level zdc directory for temporarily cached files.

    • mac OS : ~/Library/Caches/{Bundle Identifier}/zdc/
    • iOS : {App Sandbox}/Caches/zdc/

    Files stored in this directory are NOT persistent, and are eligible for deletion at the discretion of the OS.

    Declaration

    Objective-C

    + (nonnull NSURL *)zdcCacheDirectoryURL;

    Swift

    class func zdcCacheDirectoryURL() -> URL
  • The ZeroDarkCloud framework attempts to keep all stored files within a few zdc folders. This method returns the top-level container that stores all database files.

    • macOS : ~/Library/Application Support/{Bundle Identifier}/zdc/db/
    • iOS : {App Sandbox}/Application Support/zdc/db/

    Declaration

    Objective-C

    + (nonnull NSURL *)zdcDatabaseDirectoryURL;

    Swift

    class func zdcDatabaseDirectoryURL() -> URL
  • The ZeroDarkCloud framework attempts to keep all stored files within a few zdc folders. This method returns the top-level container for persistent data files stored by the ZeroDarkCloud instance using the given databaseName.

    • macOS : ~/Library/Application Support/{Bundle Identifier}/zdc/data/{Database Name}/
    • iOS : {App Sandbox}/Application Support/zdc/data/{Database Name}/

    Files stored in this directory are persistent, and must be manually deleted by the application.

    Declaration

    Objective-C

    + (nonnull NSURL *)zdcPersistentDataDirectoryForDatabaseName:
        (nonnull NSString *)databaseName;

    Swift

    class func zdcPersistentDataDirectory(forDatabaseName databaseName: String) -> URL
  • The ZeroDarkCloud framework attempts to keep all stored files within a few zdc folders. This method returns the top-level container for temporary cached data files stored by the ZeroDarkCloud instance using the given databaseName.

    • mac OS : ~/Library/Caches/{Bundle Identifier}/zdc/db/{Database Name}/
    • iOS : {App Sandbox}/Caches/zdc/db/{Database Name}/

    Files stored in this directory are NOT persistent, and are eligible for deletion at the discretion of the OS.

    Declaration

    Objective-C

    + (nonnull NSURL *)zdcCacheDataDirectoryForDatabaseName:
        (nonnull NSString *)databaseName;

    Swift

    class func zdcCacheDataDirectory(forDatabaseName databaseName: String) -> URL
  • Sqlite creates multiple files for each database. This method returns all the corresponding fileURL’s.

    • …/zdc/db/{Database Name}
    • …/zdc/db/{Database Name}-wal
    • …/zdc/db/{Database Name}-shm

    Declaration

    Objective-C

    + (nonnull NSArray<NSURL *> *)fileURLsForDatabaseName:
        (nonnull NSString *)databaseName;

    Swift

    class func fileURLs(forDatabaseName databaseName: String) -> [URL]
  • Social Media Icons cache directory.

    ZeroDark.cloud supports a number of different social media providers (for sign-in / sign-up). The framework needs to fetch various related information, such as the images for each provider.

    • mac OS : ~/Library/Caches/{Bundle Identifier}/zdc/socialmediaicons
    • iOS : {App Sandbox}/Caches/zdc/socialmediaicons

    Declaration

    Objective-C

    + (nonnull NSURL *)smiCacheDirectoryURL;

    Swift

    class func smiCacheDirectoryURL() -> URL
  • Background NSURLSession’s only support download & upload tasks. They explicitly do not support data tasks.

    So if you want to do perform a data task in the background, you may have to masquerade it as an upload task, and provide an empty file.

    This file acts as the empty file which can be shared for such tasks.

    • mac OS : ~/Library/Caches/{Bundle Identifier}/zdc/empty
    • iOS : {App Sandbox}/Caches/zdc/empty

    Declaration

    Objective-C

    + (nonnull NSURL *)emptyUploadFileURL;

    Swift

    class func emptyUploadFileURL() -> URL
  • Generates a random fileName (using a UUID), and returns a fileURL for it within the tempDirectory.

    Declaration

    Objective-C

    + (nonnull NSURL *)generateTempURL;

    Swift

    class func generateTempURL() -> URL
  • A common download directory used by the framework. The directory is specific to the ZeroDarkCloud instance.

    • mac OS : ~/Library/Caches/{Bundle Identifier}/zdc/db/{Database Name}/downloads
    • iOS : {App Sandbox}/Caches/zdc/db/{Database Name}/downloads

    Declaration

    Objective-C

    - (nonnull NSURL *)downloadDirectoryURL;

    Swift

    func downloadDirectoryURL() -> URL
  • Generates a random fileName (using a UUID), and returns a fileURL for it. The fileURL resides within the downloadDirectoryURL, which is specific to the ZeroDarkCloud instance.

    • mac OS : ~/Library/Caches/{Bundle Identifier}/zdc/db/{Database Name}/downloads/{uuid}
    • iOS : {App Sandbox}/Caches/zdc/db/{Database Name}/downloads/{uuid}

    Declaration

    Objective-C

    - (nonnull NSURL *)generateDownloadURL;

    Swift

    func generateDownloadURL() -> URL
  • Extracted from main NSBundle using key kCFBundleIdentifierKey.

    Declaration

    Objective-C

    + (nonnull NSString *)bundleIdentifier;

    Swift

    class func bundleIdentifier() -> String
  • Extracted from main NSBundle using key kCFBundleNameKey.

    Declaration

    Objective-C

    + (nonnull NSString *)bundleName;

    Swift

    class func bundleName() -> String