mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-24 04:32:26 +01:00
use nsIDirectoryService to find the tmp directory
This commit is contained in:
@@ -522,8 +522,6 @@ liberator.IO = function () //{{{
|
|||||||
// FIXME: is there a reason the "TmpD" special directory isn't being used? -- djk
|
// FIXME: is there a reason the "TmpD" special directory isn't being used? -- djk
|
||||||
createTempFile: function ()
|
createTempFile: function ()
|
||||||
{
|
{
|
||||||
let file = Components.classes["@mozilla.org/file/local;1"]
|
|
||||||
.createInstance(Components.interfaces.nsILocalFile);
|
|
||||||
let tmpName = EXTENSION_NAME + ".tmp";
|
let tmpName = EXTENSION_NAME + ".tmp";
|
||||||
|
|
||||||
switch (EXTENSION_NAME)
|
switch (EXTENSION_NAME)
|
||||||
@@ -541,12 +539,10 @@ liberator.IO = function () //{{{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Should we by trying /tmp first like Vim?
|
let file = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||||
let dir = environmentService.get("TMPDIR") || environmentService.get("TMP")
|
.getService(Components.interfaces.nsIProperties)
|
||||||
|| environmentService.get("TEMP") || (WINDOWS ? "C:\\" : "/tmp/");
|
.get("TmpD", Components.interfaces.nsIFile);
|
||||||
|
file.append(tmpName);
|
||||||
file.initWithPath(dir);
|
|
||||||
file.appendRelativePath(tmpName);
|
|
||||||
file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0600);
|
file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0600);
|
||||||
|
|
||||||
if (file.exists())
|
if (file.exists())
|
||||||
|
|||||||
Reference in New Issue
Block a user