Zotero.getStylesDirectory(), Zotero.getTranslatorsDirectory(), and Zotero.File.createDirectoryIfMissing(dir)
This commit is contained in:
parent
5baddfa66e
commit
0b3d01a187
|
@ -164,6 +164,16 @@ Zotero.File = new function(){
|
|||
}
|
||||
|
||||
|
||||
this.createDirectoryIfMissing = function (dir) {
|
||||
if (!dir.exists() || !dir.isDirectory()) {
|
||||
if (dir.exists() && !dir.isDirectory()) {
|
||||
dir.remove(null);
|
||||
}
|
||||
dir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Strip potentially invalid characters
|
||||
// See http://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words
|
||||
function getValidFileName(fileName) {
|
||||
|
|
|
@ -345,16 +345,12 @@ var Zotero = new function(){
|
|||
else {
|
||||
var file = Zotero.getProfileDirectory();
|
||||
file.append('zotero');
|
||||
|
||||
// If it doesn't exist, create
|
||||
if (!file.exists() || !file.isDirectory()){
|
||||
file.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
|
||||
}
|
||||
Zotero.File.createDirectoryIfMissing(file);
|
||||
}
|
||||
Zotero.debug("Using data directory " + file.path);
|
||||
|
||||
_zoteroDirectory = file;
|
||||
return file;
|
||||
return file.clone();
|
||||
}
|
||||
|
||||
|
||||
|
@ -362,10 +358,7 @@ var Zotero = new function(){
|
|||
var file = Zotero.getZoteroDirectory();
|
||||
|
||||
file.append('storage');
|
||||
// If it doesn't exist, create
|
||||
if (!file.exists() || !file.isDirectory()){
|
||||
file.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
|
||||
}
|
||||
Zotero.File.createDirectoryIfMissing(file);
|
||||
return file;
|
||||
}
|
||||
|
||||
|
@ -385,16 +378,27 @@ var Zotero = new function(){
|
|||
function getTempDirectory() {
|
||||
var tmp = this.getZoteroDirectory();
|
||||
tmp.append('tmp');
|
||||
if (!tmp.exists() || !tmp.isDirectory()) {
|
||||
if (tmp.exists() && !tmp.isDirectory()) {
|
||||
tmp.remove(null);
|
||||
}
|
||||
tmp.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
|
||||
}
|
||||
Zotero.File.createDirectoryIfMissing(tmp);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
this.getStylesDirectory = function () {
|
||||
var dir = this.getZoteroDirectory();
|
||||
dir.append('styles');
|
||||
Zotero.File.createDirectoryIfMissing(dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
|
||||
this.getTranslatorsDirectory = function () {
|
||||
var dir = this.getZoteroDirectory();
|
||||
dir.append('translators');
|
||||
Zotero.File.createDirectoryIfMissing(dir);
|
||||
return dir;
|
||||
}
|
||||
|
||||
|
||||
function chooseZoteroDirectory(forceRestartNow, useProfileDir) {
|
||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||
.getService(Components.interfaces.nsIWindowMediator);
|
||||
|
|
Loading…
Reference in New Issue
Block a user