Gridarta Editor
ConfigFileUtils.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.utils;
21 
22 import java.io.File;
23 import org.jetbrains.annotations.NotNull;
24 
29 public class ConfigFileUtils {
30 
34  @NotNull
35  private static final String APP_SETTINGS_DIR = ".gridarta";
36 
40  private ConfigFileUtils() {
41  }
42 
52  @NotNull
53  public static File getHomeFile(@NotNull final String filename) {
54  final StringBuilder buf = new StringBuilder();
55  buf.append(getHomeDir());
56  buf.append(File.separator).append(APP_SETTINGS_DIR);
57  final File rc = new File(buf.toString());
58  if (!rc.isDirectory()) {
59  //noinspection ResultOfMethodCallIgnored
60  rc.mkdirs();
61  }
62  buf.append(File.separator);
63  buf.append(filename);
64  return new File(buf.toString());
65  }
66 
71  @NotNull
72  public static File getHomeDir() {
73  return new File(System.getProperty("user.home"));
74  }
75 
76 }
net.sf.gridarta.utils.ConfigFileUtils.getHomeFile
static File getHomeFile(@NotNull final String filename)
Return the filename to use when dealing with this application's and current users' home directory.
Definition: ConfigFileUtils.java:53
net.sf.gridarta.utils.ConfigFileUtils.getHomeDir
static File getHomeDir()
Returns the user's home directory.
Definition: ConfigFileUtils.java:72
net.sf.gridarta.utils.ConfigFileUtils.ConfigFileUtils
ConfigFileUtils()
Private constructor to prevent instantiation.
Definition: ConfigFileUtils.java:40
net.sf.gridarta.utils.ConfigFileUtils.APP_SETTINGS_DIR
static final String APP_SETTINGS_DIR
Name of directory with settings file.
Definition: ConfigFileUtils.java:35
net.sf.gridarta.utils.ConfigFileUtils
Loader for loading resources the user's home directory.
Definition: ConfigFileUtils.java:29