blob: 918958541c2ee39271c0064874dba043a8d3f166 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
package com.btr.proxy.search.browser.firefox;
import java.io.File;
import java.io.IOException;
import com.btr.proxy.search.desktop.win.Win32ProxyUtils;
import com.btr.proxy.util.Logger;
import com.btr.proxy.util.Logger.LogLevel;
/*****************************************************************************
* Finds the Firefox profile on Windows platforms.
* On Windows the profiles are located in the users appdata directory under:
* <p>
* <i>Mozilla\Firefox\Profiles\</i>
* </p>
* The location of the appdata folder is read from the windows registry.
*
* @author Bernd Rosstauscher (proxyvole@rosstauscher.de) Copyright 2009
****************************************************************************/
class WinFirefoxProfileSource implements FirefoxProfileSource {
/*************************************************************************
* Constructor
************************************************************************/
public WinFirefoxProfileSource() {
super();
}
/*************************************************************************
* Reads the current location of the app data folder from the registry.
* @return a path to the folder.
************************************************************************/
private String getAppFolder() {
return new Win32ProxyUtils().readUserHomedir();
}
/*************************************************************************
* Get profile folder for the Windows Firefox profile
* @throws IOException on error.
************************************************************************/
public File getProfileFolder() throws IOException {
File appDataDir = new File(getAppFolder());
File cfgDir = new File(appDataDir, "Mozilla"+File.separator+"Firefox"+File.separator+"Profiles");
if (!cfgDir.exists()) {
Logger.log(getClass(), LogLevel.DEBUG, "Firefox windows settings folder not found.");
return null;
}
File[] profiles = cfgDir.listFiles();
if (profiles == null || profiles.length == 0) {
Logger.log(getClass(), LogLevel.DEBUG, "Firefox windows settings folder not found.");
return null;
}
for (File p : profiles) {
if (p.getName().endsWith(".default")) {
Logger.log(getClass(), LogLevel.TRACE, "Firefox windows settings folder is {0}.", p);
return p;
}
}
// Fall back -> take the first one found.
Logger.log(getClass(), LogLevel.TRACE, "Firefox windows settings folder is {0}.", profiles[0]);
return profiles[0];
}
}
|