www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 4959535aff418fb7207565da1e03963e762f850f
parent 46f77ec8abc93c2083fce4bc85ba398e298bf11d
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu, 27 Jul 2006 08:45:48 +0000

Scholar DB now stored in scholar subfolder of profile directory

New methods for retrieving profile directory, scholar subdirectory and scholar/storage subsubdirectory


Diffstat:
Mchrome/chromeFiles/content/scholar/xpcom/db.js | 8+++-----
Mchrome/chromeFiles/content/scholar/xpcom/scholar.js | 35+++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/xpcom/db.js b/chrome/chromeFiles/content/scholar/xpcom/db.js @@ -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); diff --git a/chrome/chromeFiles/content/scholar/xpcom/scholar.js b/chrome/chromeFiles/content/scholar/xpcom/scholar.js @@ -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 *