22 package com.realtime.crossfire.jxclient.settings;
26 import java.io.IOException;
27 import org.jetbrains.annotations.NotNull;
28 import org.jetbrains.annotations.Nullable;
50 }
catch (
final IOException ex) {
51 System.err.println(ex.getMessage());
53 throw new AssertionError(ex);
65 }
catch (
final IOException ex) {
66 System.err.println(ex.getMessage());
68 throw new AssertionError(ex);
80 }
catch (
final IOException ex) {
81 System.err.println(ex.getMessage());
83 throw new AssertionError(ex);
107 public static File
getShortcutsFile(@NotNull
final CharSequence hostname, @NotNull
final CharSequence character)
throws IOException {
122 public static File
getKeybindingsFile(@Nullable
final CharSequence hostname, @Nullable
final CharSequence character)
throws IOException {
123 return getSettingsFile(hostname == null || character == null ?
"keybindings.txt" :
"keybindings-"+
encode(hostname)+
"-"+
encode(character)+
".txt");
135 }
catch (
final IOException ex) {
136 System.err.println(
"Cannot access metaserver cache file: "+ex.getMessage());
148 public static File
getDialogsFile(@NotNull
final String skinName)
throws IOException {
159 public static File
getSettingsFile(@NotNull
final String filename)
throws IOException {
161 if (!settingsDir.exists() && !settingsDir.mkdirs()) {
162 throw new IOException(
"cannot create "+settingsDir);
165 return new File(settingsDir, filename);
175 final String home = System.getProperty(
"user.home");
177 throw new IOException(
"cannot find home directory");
180 return new File(home,
".crossfire");
189 private static String
encode(@NotNull
final CharSequence str) {
190 final StringBuilder sb =
new StringBuilder();
191 for (
int i = 0; i < str.length(); i++) {
192 final char ch = str.charAt(i);
193 if ((
'a' <= ch && ch <=
'z') || (
'A' <= ch && ch <=
'Z') || (
'0' <= ch && ch <=
'9') || ch ==
'-' || ch ==
'_' || ch ==
'.') {
200 return sb.toString();
211 return getSettingsFile(hostname == null ?
"jxclient.txt" :
"jxclient-"+hostname+
".txt");
static File getScaledImageCacheDir()
Returns the image cache directory for double size images.
Utility class to return references to settings files.
static File getShortcutsFile(@NotNull final CharSequence hostname, @NotNull final CharSequence character)
Returns the shortcuts file.
static File getSettingsFile()
Returns the main settings file.
Filenames()
Private constructor to prevent instantiation.
static File getKeybindingsFile(@Nullable final CharSequence hostname, @Nullable final CharSequence character)
Returns the keybindings file.
static File getMessageLogFile(@Nullable final String hostname)
Returns the log file for text message logging.
static File getOriginalImageCacheDir()
Returns the image cache directory.
static void hexEncode2(@NotNull final StringBuilder sb, final int value)
Append a given value as a two digits hexadecimal number.
static String encode(@NotNull final CharSequence str)
Encodes a string to make it safe as a file name.
static File getDialogsFile(@NotNull final String skinName)
Returns the file for storing dialog related information for a skin.
static File getCrossfireFile()
Returns the crossfire settings directory.
static File getSettingsFile(@NotNull final String filename)
Returns a file within the settings directory.
static File getMetaserverCacheFile()
Returns the metaserver cache file.
Utility class for en-/decoding hexadecimal strings.
static File getMagicMapImageCacheDir()
Returns the image cache directory for magic map sized images.