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:
Dan Stillman 2006-07-27 08:45:48 +00:00
parent 46f77ec8ab
commit 4959535aff
2 changed files with 38 additions and 5 deletions

View file

@ -359,12 +359,10 @@ Scholar.DB = new function(){
var store = Components.classes["@mozilla.org/storage/service;1"].
getService(Components.interfaces.mozIStorageService);
// Get the profile directory
var file = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties)
.get("ProfD", Components.interfaces.nsIFile);
// Get the storage directory
var file = Scholar.getScholarDirectory();
// 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']);
_connection = store.openDatabase(file);

View file

@ -18,6 +18,9 @@ var Scholar = new function(){
// Privileged (public) methods
this.init = init;
this.getProfileDirectory = getProfileDirectory;
this.getScholarDirectory = getScholarDirectory;
this.getStorageDirectory = getStorageDirectory;
this.debug = debug;
this.varDump = varDump;
this.getString = getString;
@ -51,6 +54,7 @@ var Scholar = new function(){
this.version
= gExtensionManager.getItemForID(SCHOLAR_CONFIG['GUID']).version;
// Load in the localization stringbundle for use by getString(name)
var src = 'chrome://scholar/locale/scholar.properties';
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
*