Enum Class DirStructure

java.lang.Object
java.lang.Enum<DirStructure>
org.cryptomator.cryptofs.DirStructure
All Implemented Interfaces:
Serializable, Comparable<DirStructure>, Constable

public enum DirStructure extends Enum<DirStructure>
Enumeration of the vault directory structure resemblances.

A valid vault must contain a `d` directory. Beginning with vault format 8, it must also contain a vault config file. If the vault format is lower than 8, it must instead contain a masterkey file.

In the latter case, to distinguish between a damaged vault 8 directory and a legacy vault the masterkey file must be read. For efficiency reasons, this class only checks for existence/readability of the above elements. Hence, if the result of checkDirStructure(Path, String, String) is MAYBE_LEGACY, one needs to parse the masterkey file and read out the vault version to determine this case.

Since:
2.0.0
  • Enum Constant Details

    • VAULT

      public static final DirStructure VAULT
      Dir contains a d dir as well as a vault config file.
    • MAYBE_LEGACY

      public static final DirStructure MAYBE_LEGACY
      Dir contains a d dir and a masterkey file, but misses a vault config file. Either needs migration to a newer format or damaged.
    • UNRELATED

      public static final DirStructure UNRELATED
      Dir does not qualify as vault.
  • Method Details

    • values

      public static DirStructure[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static DirStructure valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • checkDirStructure

      public static DirStructure checkDirStructure(Path pathToVault, String vaultConfigFilename, String masterkeyFilename) throws IOException
      Analyzes the structure of the given directory under certain vault existence criteria.
      Parameters:
      pathToVault - A directory path
      vaultConfigFilename - Name of the vault config file
      masterkeyFilename - Name of the masterkey file (may be null to skip detection of legacy vaults)
      Returns:
      enum indicating what this directory might be
      Throws:
      IOException - if the provided path is not a directory, does not exist or cannot be read