001/*
002 * SPDX-License-Identifier: Apache-2.0
003 *
004 * Copyright 2024-2026 The Enola <https://enola.dev> Authors
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *     https://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package dev.enola.common;
019
020import dev.dirs.ProjectDirectories;
021
022import java.io.File;
023import java.nio.file.Path;
024
025/**
026 * XDG Base Directories.
027 *
028 * <ul>
029 *   <li><a
030 *       href="https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html">Specification</a>
031 *   <li><a href="https://wiki.archlinux.org/title/XDG_Base_Directory">Arch Linux Wiki</a>
032 *   <li><a href="https://github.com/harawata/appdirs">harawata/appdirs</a>
033 *   <li><a href="https://github.com/dirs-dev/directories-jvm">dirs-dev/directories-jvm</a>
034 *   <li><a href="https://dirs.dev">dirs.dev</a>
035 *   <li><a href="https://github.com/omajid/xdg-java">omajid/xdg-java</a>
036 *   <li><a href="https://xdgbasedirectoryspecification.com/">xdgbasedirectoryspecification.com</a>
037 * </ul>
038 */
039public final class FreedesktopDirectories {
040    // TODO Rename FreedesktopDirectories to something like StandardPaths or so ?
041
042    // TODO Do not hard-code app name, but leave configurable by "Product"
043
044    // TODO Use https://github.com/harawata/appdirs instead of
045    // https://codeberg.org/dirs/directories-jvm
046
047    public static final File CACHE_FILE =
048            new File(ProjectDirectories.from("dev", "Enola", "Enola").cacheDir);
049
050    public static final Path HOSTKEY_PATH =
051            Path.of(ProjectDirectories.from("dev", "Enola", "Enola").configDir, "sshd-hostkey");
052
053    public static final Path PLAINTEXT_VAULT_FILE =
054            Path.of(ProjectDirectories.from("dev", "Enola", "Enola").configDir, "azkaban.yaml");
055
056    public static final Path HISTORY =
057            Path.of(ProjectDirectories.from("dev", "Enola", "Enola").dataLocalDir, "history");
058
059    public static final Path JLINE_CONFIG_DIR =
060            Path.of(ProjectDirectories.from("dev", "Enola", "Enola").preferenceDir, "jline");
061
062    private FreedesktopDirectories() {}
063}