package info.knacki.pass.io;

import android.content.Context;

public class PathUtils {
    private static final String DATA_DIR_NAME = "pass";
    @SuppressWarnings("SpellCheckingInspection")
    private static final String DATA_GIT_LOCAL = "gitfiles";
    private static final String DATA_FINGER_LOCAL = "fingerprint";
    private static final String DATA_PRIVATE_SSH_KEY = "id_rsa";
    private static final String DATA_GPG_FILE = "key";

    private static String GetAppRootDir(Context ctx) {
        return ctx.getFilesDir().getAbsolutePath();
    }

    public static String GetPassDir(Context ctx) {
        return GetAppRootDir(ctx) +"/" +DATA_DIR_NAME;
    }

    public static String GetGitFile(Context ctx) {
        return GetAppRootDir(ctx) +"/" +DATA_GIT_LOCAL;
    }

    public static String GetFingerprintFile(Context ctx) {
        return GetAppRootDir(ctx) +"/" +DATA_FINGER_LOCAL;
    }

    public static String GetGPGKeyFile(Context ctx) {
        return GetAppRootDir(ctx) +"/" +DATA_GPG_FILE;
    }

    public static String GetPrivateRSAKey(Context ctx) {
        return GetAppRootDir(ctx) +"/" +DATA_PRIVATE_SSH_KEY;
    }

    public static final String TRASH_SUFFIX = ".trash";

    public static boolean IsHidden(String path) {
        return path.endsWith(TRASH_SUFFIX);
    }

    public static String UnHiddenPath(String path) {
        return IsHidden(path) ? path.substring(0, path.length() -TRASH_SUFFIX.length()) : path;
    }

    public static String HiddenPath(String path) {
        return IsHidden(path) ? path : path +TRASH_SUFFIX;
    }
}
