Scholar DB now stored in scholar subfolder of profile directory
New methods for retrieving profile directory, scholar subdirectory and scholar/storage subsubdirectory
This commit is contained in:
parent
46f77ec8ab
commit
4959535aff
2 changed files with 38 additions and 5 deletions
|
@ -359,12 +359,10 @@ Scholar.DB = new function(){
|
||||||
var store = Components.classes["@mozilla.org/storage/service;1"].
|
var store = Components.classes["@mozilla.org/storage/service;1"].
|
||||||
getService(Components.interfaces.mozIStorageService);
|
getService(Components.interfaces.mozIStorageService);
|
||||||
|
|
||||||
// Get the profile directory
|
// Get the storage directory
|
||||||
var file = Components.classes["@mozilla.org/file/directory_service;1"]
|
var file = Scholar.getScholarDirectory();
|
||||||
.getService(Components.interfaces.nsIProperties)
|
|
||||||
.get("ProfD", Components.interfaces.nsIFile);
|
|
||||||
|
|
||||||
// This makes file point to PROFILE_DIR/<scholar database file>
|
// This makes file point to PROFILE_DIR/<scholar dir>/<scholar database file>
|
||||||
file.append(SCHOLAR_CONFIG['DB_FILE']);
|
file.append(SCHOLAR_CONFIG['DB_FILE']);
|
||||||
|
|
||||||
_connection = store.openDatabase(file);
|
_connection = store.openDatabase(file);
|
||||||
|
|
|
@ -18,6 +18,9 @@ var Scholar = new function(){
|
||||||
|
|
||||||
// Privileged (public) methods
|
// Privileged (public) methods
|
||||||
this.init = init;
|
this.init = init;
|
||||||
|
this.getProfileDirectory = getProfileDirectory;
|
||||||
|
this.getScholarDirectory = getScholarDirectory;
|
||||||
|
this.getStorageDirectory = getStorageDirectory;
|
||||||
this.debug = debug;
|
this.debug = debug;
|
||||||
this.varDump = varDump;
|
this.varDump = varDump;
|
||||||
this.getString = getString;
|
this.getString = getString;
|
||||||
|
@ -51,6 +54,7 @@ var Scholar = new function(){
|
||||||
this.version
|
this.version
|
||||||
= gExtensionManager.getItemForID(SCHOLAR_CONFIG['GUID']).version;
|
= gExtensionManager.getItemForID(SCHOLAR_CONFIG['GUID']).version;
|
||||||
|
|
||||||
|
|
||||||
// Load in the localization stringbundle for use by getString(name)
|
// Load in the localization stringbundle for use by getString(name)
|
||||||
var src = 'chrome://scholar/locale/scholar.properties';
|
var src = 'chrome://scholar/locale/scholar.properties';
|
||||||
var localeService =
|
var localeService =
|
||||||
|
@ -71,6 +75,37 @@ var Scholar = new function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getProfileDirectory(){
|
||||||
|
return Components.classes["@mozilla.org/file/directory_service;1"]
|
||||||
|
.getService(Components.interfaces.nsIProperties)
|
||||||
|
.get("ProfD", Components.interfaces.nsIFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getScholarDirectory(){
|
||||||
|
var file = Scholar.getProfileDirectory();
|
||||||
|
|
||||||
|
file.append('scholar');
|
||||||
|
// If it doesn't exist, create
|
||||||
|
if (!file.exists() || !file.isDirectory()){
|
||||||
|
file.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0664);
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getStorageDirectory(){
|
||||||
|
var file = Scholar.getScholarDirectory();
|
||||||
|
|
||||||
|
file.append('storage');
|
||||||
|
// If it doesn't exist, create
|
||||||
|
if (!file.exists() || !file.isDirectory()){
|
||||||
|
file.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0664);
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Debug logging function
|
* Debug logging function
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue