ZDCCloudPath

@interface ZDCCloudPath : NSObject <NSCoding, NSCopying>

Encapsultes a standardized & parsed cloudPath, which takes the form of: {treeID}/{dirPrefix}/{filename}

For example, the following are valid cloudPaths:

  • com.4th-a.storm4/00000000000000000000000000000000/3h6omkbtsn3o7xfsjtz6xcnyxn5e6bug.rcrd
  • tld.foo.bar/640C24E8B6874D428A19C63652DF5F8C/54yqj8u5796uaoaa41n6unywki8t3wpn.data
  • tld.foo.bar/mgsIn/7ckebgr1c4s7a9xgu6gqcb7ix55mndbg
  • Returns YES if the given value is a valid treeID.

    A treeID has the following requirements:

    • minimum of 8 characters
    • maximum of 64 characters
    • cannot start with a period
    • all characters are in set: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_

    Declaration

    Objective-C

    + (BOOL)isValidTreeID:(nonnull NSString *)treeID;

    Swift

    class func isValidTreeID(_ treeID: String) -> Bool
  • Returns YES if the given value is a valid dirPrefix.

    A dirPrefix has the following requirements:

    • 32 characters
    • all characters are hexadecimal (UPPER-CASE)

    Declaration

    Objective-C

    + (BOOL)isValidDirPrefix:(nonnull NSString *)dirPrefix;

    Swift

    class func isValidDirPrefix(_ dirPrefix: String) -> Bool
  • Returns YES if the given value is a valid filename.

    A filename has the following requirements;

    • 32 characters
    • all characters are in zBase32 alphabet
    • may or may not have a file extension

    Declaration

    Objective-C

    + (BOOL)isValidFileName:(nonnull NSString *)filename;

    Swift

    class func isValidFileName(_ filename: String) -> Bool
  • Returns YES if the given value is a valid cloudPath.

    A cloudPath is of the form X/Y/Z, where:

    • X is a valid treeID
    • Y is a valid dirPrefix
    • Z is a valid filename

    Declaration

    Objective-C

    + (BOOL)isValidCloudPath:(nonnull NSString *)cloudPath;

    Swift

    class func isValidCloudPath(_ cloudPath: String) -> Bool
  • Attempts to parse the given string into a cloudPath.

    Declaration

    Objective-C

    - (nullable instancetype)initWithPath:(nonnull NSString *)path;

    Swift

    init?(path: String)

    Parameters

    path

    A cloud path of the form X/Y/Z, where X=treeID, Y=dirPrefix, Z=fileName

  • Creates a new instance with the given components.

    Declaration

    Objective-C

    - (nullable instancetype)initWithTreeID:(nonnull NSString *)treeID
                                  dirPrefix:(nonnull NSString *)dirPrefix
                                   fileName:(nonnull NSString *)fileName;

    Swift

    init?(treeID: String, dirPrefix: String, fileName: String)

    Parameters

    treeID

    The treesystem container name. This is the name you registered via dashboard.zerodark.cloud.

    dirPrefix

    Represents the parentNode.dirPrefix value. That is, all direct children of the same parentNode share the same dirPrefix.

    fileName

    The (hashed) name of the file. This is also referred to as the cloudName. The fileName does not require a fileExtension.

  • Creates a new instance, where the dirPrefix is set to be the inbox.

    Declaration

    Objective-C

    - (nullable instancetype)initWithTreeID:(nonnull NSString *)treeID
                              inboxFileName:(nonnull NSString *)fileName;

    Swift

    init?(treeID: String, inboxFileName fileName: String)

    Parameters

    treeID

    The treesystem container name. This is the name you registered via dashboard.zerodark.cloud.

    fileName

    The (hashed) name of the file. This is also referred to as the cloudName. The fileName does not require a fileExtension.

  • Creates a new instance, where the dirPrefix is set to be the outbox.

    Declaration

    Objective-C

    - (nullable instancetype)initWithTreeID:(nonnull NSString *)treeID
                             outboxFileName:(nonnull NSString *)fileName;

    Swift

    init?(treeID: String, outboxFileName fileName: String)

    Parameters

    treeID

    The treesystem container name. This is the name you registered via dashboard.zerodark.cloud.

    fileName

    The (hashed) name of the file. This is also referred to as the cloudName. The fileName does not require a fileExtension.

  • The treesystem container name. This is the name you registered via dashboard.zerodark.cloud.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic) NSString *_Nonnull treeID;

    Swift

    var treeID: String { get }
  • Represents the parentNode.dirPrefix value. That is, all direct children of the same parentNode share the same dirPrefix.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic) NSString *_Nonnull dirPrefix;

    Swift

    var dirPrefix: String { get }
  • The (hashed) name of the file. This is also referred to as the cloudName. The fileName may or may not include a fileExtension.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic) NSString *_Nonnull fileName;

    Swift

    var fileName: String { get }
  • Extracts the fileExtension, if it includes ones. E.g. rcrd or data.

    Declaration

    Objective-C

    - (nullable NSString *)fileNameExt;

    Swift

    func fileNameExt() -> String?
  • Returns the current fileName, stripped of its existing fileExtension, and with the given fileNameExt added instead.

    Declaration

    Objective-C

    - (nonnull NSString *)fileNameWithExt:(nullable NSString *)fileNameExt;

    Swift

    func fileName(withExt fileNameExt: String?) -> String
  • Returns the full cloudPath in string form. (i.e. with ‘/’ separator between components)

    Declaration

    Objective-C

    - (nonnull NSString *)path;

    Swift

    func path() -> String
  • Returns a path including only the specific components (with ‘/’ separator between components).

    Declaration

    Objective-C

    - (nonnull NSString *)pathWithComponents:(ZDCCloudPathComponents)components;

    Swift

    func path(with components: ZDCCloudPathComponents) -> String
  • Returns the full cloudPath in string form, but with the given fileExtension.

    Declaration

    Objective-C

    - (nonnull NSString *)pathWithExt:(nullable NSString *)fileNameExt;

    Swift

    func path(withExt fileNameExt: String?) -> String
  • Returns YES if the fileNames match (including fileExtension).

    Declaration

    Objective-C

    - (BOOL)matchesFileName:(nonnull NSString *)fileName;

    Swift

    func matchesFileName(_ fileName: String) -> Bool
  • Returns YES if the fileNames match, comparing only the given components.

    Declaration

    Objective-C

    - (BOOL)matchesFileName:(nonnull NSString *)fileName
        comparingComponents:(ZDCCloudPathComponents)components;

    Swift

    func matchesFileName(_ fileName: String, comparing components: ZDCCloudPathComponents) -> Bool
  • Retursn YES if the cloudPath matches the given path, including all components & fileExtension.

    Declaration

    Objective-C

    - (BOOL)matchesPath:(nonnull NSString *)path;

    Swift

    func matchesPath(_ path: String) -> Bool
  • Returns YES if the cloudPath matches the given path, comparing only the given components.

    Declaration

    Objective-C

    - (BOOL)matchesPath:(nonnull NSString *)path
        comparingComponents:(ZDCCloudPathComponents)components;

    Swift

    func matchesPath(_ path: String, comparing components: ZDCCloudPathComponents) -> Bool
  • Compares the cloudPaths, and returns YES if they match exactly.

    Declaration

    Objective-C

    - (BOOL)isEqualToCloudPath:(nonnull ZDCCloudPath *)another;

    Swift

    func isEqual(to another: ZDCCloudPath) -> Bool
  • Compares the cloudPaths, and returne YES if they match (excluding fileExtension).

    Declaration

    Objective-C

    - (BOOL)isEqualToCloudPathIgnoringExt:(nonnull ZDCCloudPath *)another;

    Swift

    func isEqual(toCloudPathIgnoringExt another: ZDCCloudPath) -> Bool
  • Compares the cloudPaths, but only comparing the given components.

    Declaration

    Objective-C

    - (BOOL)isEqualToCloudPath:(nonnull ZDCCloudPath *)another
                    components:(ZDCCloudPathComponents)components;

    Swift

    func isEqual(to another: ZDCCloudPath, components: ZDCCloudPathComponents) -> Bool
  • Returns a copy with a different fileExtension. For example, if the cloudPath has a rcrd fileExtension, you can use this method to get a cloudPath for the data extension.

    Declaration

    Objective-C

    - (nonnull id)copyWithFileNameExt:(nullable NSString *)newFileNameExt;

    Swift

    func copy(withFileNameExt newFileNameExt: String?) -> Any