01: package org.columba.core.config;
02:
03: import java.io.File;
04:
05: import org.columba.core.base.OSInfo;
06:
07: /**
08: * Path to configuration directory.
09: *
10: * @author Frederik Dietz
11: */
12: public class DefaultConfigDirectory {
13:
14: private static DefaultConfigDirectory instance = new DefaultConfigDirectory();
15:
16: private File currentPath;
17:
18: private DefaultConfigDirectory() {
19: }
20:
21: public static DefaultConfigDirectory getInstance() {
22: return instance;
23: }
24:
25: /**
26: * Set current path to config directory. This is set by org.columba.main.Bootstrap and depends on the
27: * selected profile.
28: *
29: * @param currentPath
30: */
31: public void setCurrentPath(File currentPath) {
32: this .currentPath = currentPath;
33: }
34:
35: public File getCurrentPath() {
36: if (currentPath == null) {
37: // fall back to default path
38: currentPath = DefaultConfigDirectory.getDefaultPath();
39: }
40:
41: return currentPath;
42: }
43:
44: /**
45: * Returns the default configuration path. This value depends on the
46: * underlying operating system. This method must never return null.
47: */
48: public static File getDefaultPath() {
49: if (OSInfo.isWindowsPlatform()) {
50: return new File("config"); //$NON-NLS-1$
51: }
52: return new File(System.getProperty("user.home"), ".columba"); //$NON-NLS-1$//$NON-NLS-2$
53: }
54: }
|