Bug 1248252 - Improper outdated octal constant syntax in M-C tree. Use '0o' prefix. r=dao

Be warned. Do not attemp to change the .js "test" source code in ./js
They are meant to check

 - the outdated 0666 octal constant is still parsed correctly,
 - the outdated 0666 octal constant raises syntax error flag
   in strict mode, etc.

So leave them alone.
This commit is contained in:
ISHIKAWA, Chiaki 2016-02-15 08:57:00 +01:00
parent 5dbe821fae
commit 72d38a6835
61 changed files with 124 additions and 124 deletions

View File

@ -121,8 +121,8 @@ function remove(path, recursive) {
/**
* Utility function to convert either an octal number or string
* into an octal number
* 0777 => 0777
* "0644" => 0644
* 0777 => 0o777
* "0644" => 0o644
*/
function Mode(mode, fallback) {
return isString(mode) ? parseInt(mode, 8) : mode || fallback;

View File

@ -89,7 +89,7 @@ HelperAppLauncherDialog.prototype = {
aLocalFile.leafName = aLocalFile.leafName.replace(/^(.*\()\d+\)/, "$1" + (collisionCount+1) + ")");
}
}
aLocalFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
aLocalFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
}
catch (e) {
dump("*** exception in makeFileUnique: " + e + "\n");
@ -100,7 +100,7 @@ HelperAppLauncherDialog.prototype = {
if (aLocalFile.leafName == "" || aLocalFile.isDirectory()) {
aLocalFile.append("unnamed");
if (aLocalFile.exists())
aLocalFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
aLocalFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
}
}
},

View File

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Equivalent to 0600 permissions; used for saved Sync Recovery Key.
// Equivalent to 0o600 permissions; used for saved Sync Recovery Key.
// This constant can be replaced when the equivalent values are available to
// chrome JS; see Bug 433295 and Bug 757351.
const PERMISSIONS_RWUSR = 0x180;

View File

@ -200,7 +200,7 @@ function createTemporarySaveDirectory() {
saveDir.append("testsavedir");
if (!saveDir.exists()) {
info("create testsavedir!");
saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0755);
saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
}
info("return from createTempSaveDir: " + saveDir.path);
return saveDir;

View File

@ -20,7 +20,7 @@ function createTemporarySaveDirectory() {
saveDir.append("testsavedir");
if (!saveDir.exists()) {
info("create testsavedir!");
saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0755);
saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
}
info("return from createTempSaveDir: " + saveDir.path);
return saveDir;

View File

@ -53,7 +53,7 @@ function test() {
.get("TmpD", Ci.nsIFile);
saveDir.append("testsavedir");
if (!saveDir.exists())
saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0755);
saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
return saveDir;
}

View File

@ -82,6 +82,6 @@ function createTemporarySaveDirectory() {
.get("TmpD", Ci.nsIFile);
saveDir.append("testsavedir");
if (!saveDir.exists())
saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0755);
saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
return saveDir;
}

View File

@ -24,7 +24,7 @@ function createTemporarySaveDirectory() {
.get("TmpD", Ci.nsIFile);
saveDir.append("testsavedir");
if (!saveDir.exists())
saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0755);
saveDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
return saveDir;
}
/**

View File

@ -30,7 +30,7 @@ function test() {
let dir2 = ds.get("TmpD", Ci.nsIFile);
let file = dir2.clone();
file.append("pbtest.file");
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
const kPrefName = "browser.open.lastDir";

View File

@ -141,7 +141,7 @@ add_task(function* test_recovery_inaccessible() {
yield File.setPermissions(Paths.recovery, { unixMode: 0 });
is((yield SessionFile.read()).source, SOURCE, "Recovered the correct source from the recovery file");
yield File.setPermissions(Paths.recovery, { unixMode: 0644 });
yield File.setPermissions(Paths.recovery, { unixMode: 0o644 });
});
add_task(function* test_clean() {

View File

@ -234,7 +234,7 @@ function writeToFileSync(file, data) {
createInstance(Components.interfaces.nsIFileOutputStream);
// use 0x02 | 0x10 to open file for appending.
foStream.init(file, 0x02 | 0x08 | 0x20, 0666, 0);
foStream.init(file, 0x02 | 0x08 | 0x20, 0o666, 0);
// write, create, truncate
// In a c file operation, we have no need to set file mode with or operation,
// directly using "r" or "w" usually.

View File

@ -192,7 +192,7 @@ function cleanup()
function createTempFile(name)
{
let file = FileUtils.getFile("TmpD", [name]);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
file.QueryInterface(Ci.nsILocalFile)
return file;
}
@ -202,7 +202,7 @@ function writeFile(file, content, callback)
let fout = Cc["@mozilla.org/network/file-output-stream;1"].
createInstance(Ci.nsIFileOutputStream);
fout.init(file.QueryInterface(Ci.nsILocalFile), 0x02 | 0x08 | 0x20,
0644, fout.DEFER_OPEN);
0o644, fout.DEFER_OPEN);
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
createInstance(Ci.nsIScriptableUnicodeConverter);

View File

@ -96,7 +96,7 @@ function downloadURL(url, file) {
let ostream = Cc["@mozilla.org/network/safe-file-output-stream;1"]
.createInstance(Ci.nsIFileOutputStream);
ostream.init(file, 0x04 | 0x08 | 0x20, 0600, 0);
ostream.init(file, 0x04 | 0x08 | 0x20, 0o600, 0);
ostream.write(data, data.length);
ostream.QueryInterface(Ci.nsISafeOutputStream).finish();
}

View File

@ -6,7 +6,7 @@ addMessageListener("file.create", function (message) {
.getService(Components.interfaces.nsIProperties)
.get("TmpD", Components.interfaces.nsIFile);
file.append("foo.txt");
file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0600);
file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0o600);
sendAsyncMessage("file.created", new File(file));
});

View File

@ -8,7 +8,7 @@ function createFileWithData(message) {
var outStream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
0666, 0);
0o666, 0);
outStream.write(message, message.length);
outStream.close();

View File

@ -11,7 +11,7 @@ function createFileWithData(fileData) {
fileNum++;
var outStream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
0666, 0);
0o666, 0);
if (willDelete) {
fileData = "some irrelevant test data\n";
}

View File

@ -46,7 +46,7 @@ function ParseFile(file) {
var fileStr = C["@mozilla.org/network/file-input-stream;1"]
.createInstance(nsIFileInputStream);
// Init for readonly reading
fileStr.init(file, 0x01, 0400, nsIFileInputStream.CLOSE_ON_EOF);
fileStr.init(file, 0x01, 0o400, nsIFileInputStream.CLOSE_ON_EOF);
return ParseXML(fileStr);
}

View File

@ -12,7 +12,7 @@ function testSteps()
const fileIOFlags = 0x02 | // PR_WRONLY
0x08 | // PR_CREATEFILE
0x20; // PR_TRUNCATE
const filePerms = 0664;
const filePerms = 0o664;
const fileData = "abcdefghijklmnopqrstuvwxyz";
const fileType = "text/plain";

View File

@ -12,7 +12,7 @@ outputDir.initWithFile(workingDir);
outputDir.append(outputName);
if (!outputDir.exists()) {
outputDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0777);
outputDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o777);
} else if (!outputDir.isDirectory()) {
do_throw(outputName + " is not a directory?")
}
@ -83,10 +83,10 @@ function testOutputStreams() {
var jsonFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
jsonFile.initWithFile(outputDir);
jsonFile.append("test.json");
jsonFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
jsonFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
var stream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
try {
stream.init(jsonFile, 0x04 | 0x08 | 0x20, 0600, 0); // write, create, truncate
stream.init(jsonFile, 0x04 | 0x08 | 0x20, 0o600, 0); // write, create, truncate
nativeJSON.encodeToStream(stream, charset, writeBOM, obj);
} finally {
stream.close();

View File

@ -22,7 +22,7 @@ function write_registry(version, info) {
var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"]
.createInstance(Components.interfaces.nsIFileOutputStream);
// write, create, truncate
foStream.init(registry, 0x02 | 0x08 | 0x20, 0666, 0);
foStream.init(registry, 0x02 | 0x08 | 0x20, 0o666, 0);
var charset = "UTF-8"; // Can be any character encoding name that Mozilla supports
var os = Cc["@mozilla.org/intl/converter-output-stream;1"].

View File

@ -26,7 +26,7 @@ function write_registry(version, info) {
var foStream = Components.classes["@mozilla.org/network/file-output-stream;1"]
.createInstance(Components.interfaces.nsIFileOutputStream);
// write, create, truncate
foStream.init(registry, 0x02 | 0x08 | 0x20, 0666, 0);
foStream.init(registry, 0x02 | 0x08 | 0x20, 0o666, 0);
var charset = "UTF-8"; // Can be any character encoding name that Mozilla supports
var os = Cc["@mozilla.org/intl/converter-output-stream;1"].

View File

@ -26,7 +26,7 @@ function write_registry(version, info) {
let foStream = Components.classes["@mozilla.org/network/file-output-stream;1"]
.createInstance(Components.interfaces.nsIFileOutputStream);
// write, create, truncate
foStream.init(registry, 0x02 | 0x08 | 0x20, 0666, 0);
foStream.init(registry, 0x02 | 0x08 | 0x20, 0o666, 0);
let charset = "UTF-8"; // Can be any character encoding name that Mozilla supports
let os = Cc["@mozilla.org/intl/converter-output-stream;1"].

View File

@ -11,7 +11,7 @@ function createFileWithData(fileData) {
fileNum++;
var outStream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
outStream.init(testFile, 0x02 | 0x08 | 0x20, // write, create, truncate
0666, 0);
0o666, 0);
if (willDelete) {
fileData = "some irrelevant test data\n";
}

View File

@ -30,7 +30,7 @@ add_task(function* do_test() {
// write our test data to it.
let ostream = Cc["@mozilla.org/network/file-output-stream;1"].
createInstance(Ci.nsIFileOutputStream);
ostream.init(file, -1, 0666, 0);
ostream.init(file, -1, 0o666, 0);
let conv = Cc["@mozilla.org/intl/converter-output-stream;1"].
createInstance(Ci.nsIConverterOutputStream);
conv.init(ostream, "UTF-8", 0, 0);

View File

@ -17,7 +17,7 @@ function run_test() {
// corrupt the file
var ostream = Cc["@mozilla.org/network/file-output-stream;1"].
createInstance(Ci.nsIFileOutputStream);
ostream.init(file, 0x02, 0666, 0);
ostream.init(file, 0x02, 0o666, 0);
var conv = Cc["@mozilla.org/intl/converter-output-stream;1"].
createInstance(Ci.nsIConverterOutputStream);
conv.init(ostream, "UTF-8", 0, 0);
@ -28,7 +28,7 @@ function run_test() {
// prepare an empty hostperm.1 file so that it can be used for importing
var hostperm = dir.clone();
hostperm.append("hostperm.1");
ostream.init(hostperm, 0x02 | 0x08, 0666, 0);
ostream.init(hostperm, 0x02 | 0x08, 0o666, 0);
ostream.close();
// remove all should not throw

View File

@ -130,7 +130,7 @@ function do_get_file_by_line(file, charset) {
let fis = Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(Ci.nsIFileInputStream);
fis.init(file, 0x1 /* READONLY */,
0444, Ci.nsIFileInputStream.CLOSE_ON_EOF);
0o444, Ci.nsIFileInputStream.CLOSE_ON_EOF);
let lis = Cc["@mozilla.org/intl/converter-input-stream;1"].
createInstance(Ci.nsIConverterInputStream);

View File

@ -19,7 +19,7 @@ function dumpToFile(aData) {
var outputStream = Cc["@mozilla.org/network/file-output-stream;1"].
createInstance(Ci.nsIFileOutputStream);
// WR_ONLY|CREAT|TRUNC
outputStream.init(outputFile, 0x02 | 0x08 | 0x20, 0644, null);
outputStream.init(outputFile, 0x02 | 0x08 | 0x20, 0o644, null);
var bos = Cc["@mozilla.org/binaryoutputstream;1"].
createInstance(Ci.nsIBinaryOutputStream);

View File

@ -1269,7 +1269,7 @@ function copyTempDouble(ptr) {
node.contentMode = MEMFS.CONTENT_FLEXIBLE;
}
},mount:function (mount) {
return MEMFS.create_node(null, '/', 0040000 | 0777, 0);
return MEMFS.create_node(null, '/', 0o040000 | 0o777, 0);
},create_node:function (parent, name, mode, dev) {
if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
// no supported
@ -1407,7 +1407,7 @@ function copyTempDouble(ptr) {
}
return entries;
},symlink:function (parent, newname, oldpath) {
var node = MEMFS.create_node(parent, newname, 0777 | 0120000, 0);
var node = MEMFS.create_node(parent, newname, 0o777 | 0o120000, 0);
node.link = oldpath;
return node;
},readlink:function (node) {
@ -1657,19 +1657,19 @@ function copyTempDouble(ptr) {
},isMountpoint:function (node) {
return node.mounted;
},isFile:function (mode) {
return (mode & 0170000) === 0100000;
return (mode & 0o170000) === 0o100000;
},isDir:function (mode) {
return (mode & 0170000) === 0040000;
return (mode & 0o170000) === 0o040000;
},isLink:function (mode) {
return (mode & 0170000) === 0120000;
return (mode & 0o170000) === 0o120000;
},isChrdev:function (mode) {
return (mode & 0170000) === 0020000;
return (mode & 0o170000) === 0o020000;
},isBlkdev:function (mode) {
return (mode & 0170000) === 0060000;
return (mode & 0o170000) === 0o060000;
},isFIFO:function (mode) {
return (mode & 0170000) === 0010000;
return (mode & 0o170000) === 0o010000;
},isSocket:function (mode) {
return (mode & 0140000) === 0140000;
return (mode & 0o140000) === 0o140000;
},flagModes:{"r":0,"rs":8192,"r+":2,"w":1537,"wx":3585,"xw":3585,"w+":1538,"wx+":3586,"xw+":3586,"a":521,"ax":2569,"xa":2569,"a+":522,"ax+":2570,"xa+":2570},modeStringToFlags:function (str) {
var flags = FS.flagModes[str];
if (typeof flags === 'undefined') {
@ -1836,21 +1836,21 @@ function copyTempDouble(ptr) {
}
return parent.node_ops.mknod(parent, name, mode, dev);
},create:function (path, mode) {
mode = mode !== undefined ? mode : 0666;
mode = mode !== undefined ? mode : 0o666;
mode &= 4095;
mode |= 0100000;
mode |= 0o100000;
return FS.mknod(path, mode, 0);
},mkdir:function (path, mode) {
mode = mode !== undefined ? mode : 0777;
mode &= 511 | 0001000;
mode |= 0040000;
mode = mode !== undefined ? mode : 0o777;
mode &= 511 | 0o001000;
mode |= 0o040000;
return FS.mknod(path, mode, 0);
},mkdev:function (path, mode, dev) {
if (typeof(dev) === 'undefined') {
dev = mode;
mode = 0666;
mode = 0o666;
}
mode |= 0020000;
mode |= 0o020000;
return FS.mknod(path, mode, dev);
},symlink:function (oldpath, newpath) {
var lookup = FS.lookupPath(newpath, { parent: true });
@ -2096,16 +2096,16 @@ function copyTempDouble(ptr) {
},open:function (path, flags, mode, fd_start, fd_end) {
path = PATH.normalize(path);
flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
mode = typeof mode === 'undefined' ? 0666 : mode;
mode = typeof mode === 'undefined' ? 0o666 : mode;
if ((flags & 512)) {
mode = (mode & 4095) | 0100000;
mode = (mode & 4095) | 0o100000;
} else {
mode = 0;
}
var node;
try {
var lookup = FS.lookupPath(path, {
follow: !(flags & 0200000)
follow: !(flags & 0o200000)
});
node = lookup.node;
path = lookup.path;
@ -2345,7 +2345,7 @@ function copyTempDouble(ptr) {
assert(stderr.fd === 3, 'invalid handle for stderr (' + stderr.fd + ')');
},staticInit:function () {
FS.nameTable = new Array(4096);
FS.root = FS.createNode(null, '/', 0040000 | 0777, 0);
FS.root = FS.createNode(null, '/', 0o040000 | 0o777, 0);
FS.mount(MEMFS, {}, '/');
FS.createDefaultDirectories();
FS.createDefaultDevices();
@ -2767,7 +2767,7 @@ function copyTempDouble(ptr) {
openRequest.onerror = onerror;
}};
var SOCKFS={mount:function (mount) {
return FS.createNode(null, '/', 0040000 | 0777, 0);
return FS.createNode(null, '/', 0o040000 | 0o777, 0);
},nextname:function () {
if (!SOCKFS.nextname.current) {
SOCKFS.nextname.current = 0;
@ -2791,7 +2791,7 @@ function copyTempDouble(ptr) {
};
// create the filesystem node to store the socket structure
var name = SOCKFS.nextname();
var node = FS.createNode(SOCKFS.root, name, 0140000, 0);
var node = FS.createNode(SOCKFS.root, name, 0o140000, 0);
node.sock = sock;
// and the wrapping stream that enables library functions such
// as read and write to indirectly interact with the socket

View File

@ -382,7 +382,7 @@ RTestURLList.prototype = {
var data = this.mCurrentURL.dir.clone();
data.append( this.mIsBaseline ? "baseline" : "verify");
if (!data.exists())
data.create(nsIFile.DIRECTORY_TYPE, 0777)
data.create(nsIFile.DIRECTORY_TYPE, 0o777)
data.append(basename);
dump("Writing regression data to " +

View File

@ -140,7 +140,7 @@ StatisticsReport.prototype = {
if(exists) {
writeFile.bind(this)();
} else {
fs.mkdir("test/reports/", 0777, writeFile.bind(this));
fs.mkdir("test/reports/", 0o777, writeFile.bind(this));
}
}.bind(this));

View File

@ -289,7 +289,7 @@ HelperAppLauncherDialog.prototype = {
aLocalFile.leafName = aLocalFile.leafName.replace(/^(.*\()\d+\)/, "$1" + (collisionCount+1) + ")");
}
}
aLocalFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
aLocalFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
}
catch (e) {
dump("*** exception in validateLeafName: " + e + "\n");
@ -300,7 +300,7 @@ HelperAppLauncherDialog.prototype = {
if (aLocalFile.leafName == "" || aLocalFile.isDirectory()) {
aLocalFile.append("unnamed");
if (aLocalFile.exists())
aLocalFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
aLocalFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
}
}
},

View File

@ -681,7 +681,7 @@ SessionStore.prototype = {
// Convert buffer to an encoded string and sync write to disk
let bytes = String.fromCharCode.apply(null, new Uint16Array(aBuffer));
let stream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
stream.init(aFile, 0x02 | 0x08 | 0x20, 0666, 0);
stream.init(aFile, 0x02 | 0x08 | 0x20, 0o666, 0);
stream.write(bytes, bytes.length);
stream.close();

View File

@ -27,7 +27,7 @@ function run_test() {
var target = tmpDir.clone();
target.append(entryName);
target.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, 6 * 64 + 4 * 8 + 0); // 0640
target.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, 0o640); // 0640
zipreader.extract(entryName, target);

View File

@ -32,7 +32,7 @@ function run_test() {
var tmp = tmpDir.clone();
tmp.append("temp-permissions");
tmp.createUnique(Ci.nsILocalFile.DIRECTORY_TYPE, 0755);
tmp.createUnique(Ci.nsILocalFile.DIRECTORY_TYPE, 0o755);
var file = tmp.clone();
file.append("tempfile");

View File

@ -102,13 +102,13 @@ function createMAR(outMAR, dataDir, files) {
// Ensure on non Windows platforms we encode the same permissions
// as the refernence MARs contain. On Windows this is also safe.
// The reference MAR files have permissions of 0664, so in case
// The reference MAR files have permissions of 0o664, so in case
// someone is running these tests locally with another permission
// (perhaps 0777), make sure that we encode them as 0664.
// (perhaps 0o777), make sure that we encode them as 0o664.
for (filePath of files) {
let f = dataDir.clone();
f.append(filePath);
f.permissions = 0664;
f.permissions = 0o664;
}
// Setup the command line arguments to create the MAR.

View File

@ -17,7 +17,7 @@ function run_test() {
let outDir = tempDir.clone();
outDir.append("out");
do_check_false(outDir.exists());
outDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0777);
outDir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o777);
// Get the ref files and the files that will be extracted.
let outFiles = [];

View File

@ -311,7 +311,7 @@ function run_test() {
savePrefFile.append("savePref.js");
if (savePrefFile.exists())
savePrefFile.remove(false);
savePrefFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
savePrefFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
ps.savePrefFile(savePrefFile);
ps.resetPrefs();

View File

@ -59,7 +59,7 @@ function makeBIS(stream)
function fileContents(file)
{
const PR_RDONLY = 0x01;
var fis = new FileInputStream(file, PR_RDONLY, 0444,
var fis = new FileInputStream(file, PR_RDONLY, 0o444,
Ci.nsIFileInputStream.CLOSE_ON_EOF);
var sis = new ScriptableInputStream(fis);
var contents = sis.read(file.fileSize);

View File

@ -42,7 +42,7 @@ function createTestDirectory()
.getService(Ci.nsIProperties)
.get("TmpD", Ci.nsIFile);
dir.append("index_handler_test_" + Math.random());
dir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0744);
dir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0o744);
// populate with test directories, files, etc.
// Files must be in expected order of display on the index page!
@ -249,7 +249,7 @@ function makeFile(name, isDirectory, parentDir, lst)
try
{
file.append(name);
file.create(type, 0755);
file.create(type, 0o755);
lst.push({name: name, isDirectory: isDirectory});
}
catch (e) { /* OS probably doesn't like file name, skip */ }

View File

@ -68,7 +68,7 @@ function async_write_file(aContractId, aDeferOpen)
getService(Ci.nsIProperties).
get("ProfD", Ci.nsIFile);
file.append("NetUtil-async-test-file.tmp");
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
// Then, we need an output stream to our output file.
let ostream = Cc[aContractId].createInstance(Ci.nsIFileOutputStream);
@ -123,7 +123,7 @@ function test_async_copy()
getService(Ci.nsIProperties).
get("ProfD", Ci.nsIFile);
file.append("NetUtil-asyncFetch-test-file.tmp");
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let ostream = Cc["@mozilla.org/network/file-output-stream;1"].
createInstance(Ci.nsIFileOutputStream);
@ -144,7 +144,7 @@ function test_async_copy()
getService(Ci.nsIProperties).
get("ProfD", Ci.nsIFile);
file.append("NetUtil-asyncFetch-test-file.tmp");
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let ostream = Cc["@mozilla.org/network/file-output-stream;1"].
createInstance(Ci.nsIFileOutputStream);
@ -409,7 +409,7 @@ function test_asyncFetch_with_nsIFile()
getService(Ci.nsIProperties).
get("ProfD", Ci.nsIFile);
file.append("NetUtil-asyncFetch-test-file.tmp");
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
// Write the test data to the file.
let ostream = Cc["@mozilla.org/network/file-output-stream;1"].

View File

@ -10,7 +10,7 @@ function run_test()
var fis = Cc["@mozilla.org/network/file-input-stream;1"]
.createInstance(Ci.nsIFileInputStream);
fis.init(do_get_file("effective_tld_names.dat"),
PR_RDONLY, 0444, Ci.nsIFileInputStream.CLOSE_ON_EOF);
PR_RDONLY, 0o444, Ci.nsIFileInputStream.CLOSE_ON_EOF);
var lis = Cc["@mozilla.org/intl/converter-input-stream;1"]
.createInstance(Ci.nsIConverterInputStream);

View File

@ -118,7 +118,7 @@ function run_test()
let ostream = Cc["@mozilla.org/network/file-output-stream;1"].
createInstance(Ci.nsIFileOutputStream);
ostream.init(tempFile, 0x02 | 0x08 | 0x20, // write, create, truncate
0666, 0);
0o666, 0);
let newData = "abcdefghijklmnopqrstuvwxyz";
ostream.write(newData, newData.length);
ostream.close();
@ -499,12 +499,12 @@ function create_temp_file(data) {
getService(Ci.nsIProperties).
get("ProfD", Ci.nsIFile);
file.append("fileinputstream-test-file.tmp");
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let ostream = Cc["@mozilla.org/network/file-output-stream;1"].
createInstance(Ci.nsIFileOutputStream);
ostream.init(file, 0x02 | 0x08 | 0x20, // write, create, truncate
0666, 0);
0o666, 0);
do_check_eq(ostream.write(data, data.length), data.length);
ostream.close();

View File

@ -180,7 +180,7 @@ function test_upload_file() {
var file = do_get_file("../unit/data/test_readline6.txt"); // file to upload
var dest = do_get_tempdir(); // file upload destination
dest.append("junk.dat");
dest.createUnique(dest.NORMAL_FILE_TYPE, 0600);
dest.createUnique(dest.NORMAL_FILE_TYPE, 0o600);
var uploadstream = new_file_input_stream(file, true);

View File

@ -128,7 +128,7 @@ function sync_operations(aDeferOpen)
getService(Ci.nsIProperties).
get("ProfD", Ci.nsIFile);
file.append(LEAF_NAME);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let ostream = Cc[OUTPUT_STREAM_CONTRACT_ID].
createInstance(Ci.nsIFileOutputStream);
@ -215,7 +215,7 @@ function do_test_zero_size_buffered(disableBuffering)
getService(Ci.nsIProperties).
get("ProfD", Ci.nsIFile);
file.append(LEAF_NAME);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let fstream = Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(Ci.nsIFileInputStream);

View File

@ -134,7 +134,7 @@ function exportToFile(parent, cert)
var fos = Components.classes["@mozilla.org/network/file-output-stream;1"].
createInstance(Components.interfaces.nsIFileOutputStream);
// flags: PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE
fos.init(file, 0x02 | 0x08 | 0x20, 00644, 0);
fos.init(file, 0x02 | 0x08 | 0x20, 0o0644, 0);
written = fos.write(content, content.length);
fos.close();
}

View File

@ -28,7 +28,7 @@ function run_test() {
// Assuming we're working with a clean slate, the file shouldn't exist
// until we create it.
ok(!stateFile.exists());
stateFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0x1a4); // 0x1a4 == 0644
stateFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0x1a4); // 0x1a4 == 0o644
ok(stateFile.exists());
// Initialize nsISiteSecurityService after do_get_profile() so it
// can read the state file.

View File

@ -252,7 +252,7 @@ certs.sort(compareCertificatesByHash);
// Write the output file.
var outFile = relativePathToFile("CNNICHashWhitelist.inc");
if (!outFile.exists()) {
outFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0644);
outFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644);
}
var outStream = Cc["@mozilla.org/network/file-output-stream;1"]
.createInstance(Ci.nsIFileOutputStream);

View File

@ -204,7 +204,7 @@ add_task(function* test_restorePromptsReupload() {
backupFile.append("t_b_e_" + Date.now() + ".json");
_("Backing up to file " + backupFile.path);
backupFile.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, 0600);
backupFile.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, 0o600);
yield BookmarkJSONUtils.exportToFile(backupFile);
_("Create a different record and sync.");

View File

@ -52,7 +52,7 @@ MozillaFileLogger.init = function(path) {
MozillaFileLogger._file.initWithPath(path);
MozillaFileLogger._foStream = Cc[FOSTREAM_CID].createInstance(Ci.nsIFileOutputStream);
MozillaFileLogger._foStream.init(this._file, PR_WRITE_ONLY | PR_CREATE_FILE | PR_APPEND,
0664, 0);
0o664, 0);
}
MozillaFileLogger.getLogCallback = function() {

View File

@ -79,7 +79,7 @@ MozFileLogger.init = function(path) {
MozFileLogger._file.initWithPath(path);
MozFileLogger._foStream = Cc[FOSTREAM_CID].createInstance(Ci.nsIFileOutputStream);
MozFileLogger._foStream.init(this._file, PR_WRITE_ONLY | PR_CREATE_FILE | PR_APPEND,
0664, 0);
0o664, 0);
}
MozFileLogger.getLogCallback = function() {

View File

@ -19,6 +19,6 @@ add_task(function* test_private_temp() {
var targetFile = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);
targetFile.initWithPath(download.target.path);
// 488 is the decimal value of 0700.
// 488 is the decimal value of 0o700.
equal(targetFile.parent.permissions, 448);
});

View File

@ -14,7 +14,7 @@
/**
* Helper function for test logging: prints a POSIX file permission mode as an
* octal number, with a leading '0' per C (not JS) convention. When the
* numeric value is 0777 or lower, it is padded on the left with zeroes to
* numeric value is 0o777 or lower, it is padded on the left with zeroes to
* four digits wide.
* Sample outputs: 0022, 0644, 04755.
*/

View File

@ -68,7 +68,7 @@ function run_test() {
// XXX We could, of course, create an actual executable in the directory:
//executable.append("localhandler");
//if (!executable.exists())
// executable.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0755);
// executable.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o755);
var localHandler = {
name: "Local Handler",

View File

@ -144,7 +144,7 @@ INIProcessor.prototype = {
let safeStream = Cc["@mozilla.org/network/safe-file-output-stream;1"].
createInstance(Ci.nsIFileOutputStream);
safeStream.init(aFile, MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE,
0600, null);
0o600, null);
var outputStream = Cc["@mozilla.org/network/buffered-output-stream;1"].
createInstance(Ci.nsIBufferedOutputStream);

View File

@ -22,11 +22,11 @@ function create_file(fileName)
{
var outFile = getTempDir();
outFile.append(fileName);
outFile.createUnique(outFile.NORMAL_FILE_TYPE, 0600);
outFile.createUnique(outFile.NORMAL_FILE_TYPE, 0o600);
var stream = Cc["@mozilla.org/network/file-output-stream;1"]
.createInstance(Ci.nsIFileOutputStream);
stream.init(outFile, 0x02 | 0x08 | 0x20, 0600, 0);
stream.init(outFile, 0x02 | 0x08 | 0x20, 0o600, 0);
stream.write("foo", 3);
stream.close();

View File

@ -9,7 +9,7 @@ function run_test() {
var targetFile = testDir.clone();
targetFile.append("target.txt");
if (!targetFile.exists())
targetFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0644);
targetFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644);
var link = testDir.clone();
link.append("link");

View File

@ -19,7 +19,7 @@ function run_test()
tempFile.append("test.txt");
try {
tempFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
tempFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600);
do_throw("Creating an item in a folder with a very long name should throw");
}
catch (e if (e instanceof Ci.nsIException &&

View File

@ -13,7 +13,7 @@ function createUNIXHiddenFile() {
// we don't care if this already exists because we don't care
// about the file's contents (just the name)
if (!hiddenUnixFile.exists())
hiddenUnixFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
hiddenUnixFile.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
return hiddenUnixFile.exists();
}

View File

@ -68,7 +68,7 @@ function test_file_modification_time()
file.remove(true);
var now = Date.now();
file.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0644);
file.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644);
do_check_true(file.exists());
// Modification time may be out by up to 2 seconds on FAT filesystems. Test
@ -108,7 +108,7 @@ function test_directory_modification_time()
dir.remove(true);
var now = Date.now();
dir.create(Ci.nsIFile.DIRECTORY_TYPE, 0755);
dir.create(Ci.nsIFile.DIRECTORY_TYPE, 0o755);
do_check_true(dir.exists());
// Modification time may be out by up to 2 seconds on FAT filesystems. Test
@ -142,7 +142,7 @@ function test_diskSpaceAvailable()
file.append("testfile");
if (file.exists())
file.remove(true);
file.create(Ci.nsIFile.NORMAL_FILE_TYPE, parseInt("644", 8));
file.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644);
bytes = file.diskSpaceAvailable;
do_check_true(bytes > 0);

View File

@ -69,13 +69,13 @@ function setupTestDir(testDir, relative) {
}
do_check_true(!testDir.exists());
testDir.create(nsIFile.DIRECTORY_TYPE, 0777);
testDir.create(nsIFile.DIRECTORY_TYPE, 0o777);
targetDir.create(nsIFile.DIRECTORY_TYPE, 0777);
targetDir.create(nsIFile.DIRECTORY_TYPE, 0o777);
var targetFile = testDir.clone();
targetFile.append(FILE_TARGET);
targetFile.create(nsIFile.NORMAL_FILE_TYPE, 0666);
targetFile.create(nsIFile.NORMAL_FILE_TYPE, 0o666);
var imaginary = testDir.clone();
imaginary.append(DOES_NOT_EXIST);

View File

@ -23,7 +23,7 @@ function run_test()
let tempDir = Services.dirsvc.get("TmpD", Ci.nsILocalFile);
tempDir.append("shortcutTesting");
tempDir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0666);
tempDir.createUnique(Ci.nsIFile.DIRECTORY_TYPE, 0o666);
test_create_noargs(tempDir);
test_create_notarget(tempDir);
@ -43,7 +43,7 @@ function test_create_noargs(tempDir)
{
let shortcutFile = tempDir.clone();
shortcutFile.append("shouldNeverExist.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let win = shortcutFile.QueryInterface(Ci.nsILocalFileWin);
@ -63,7 +63,7 @@ function test_create_notarget(tempDir)
{
let shortcutFile = tempDir.clone();
shortcutFile.append("shouldNeverExist2.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let win = shortcutFile.QueryInterface(Ci.nsILocalFileWin);
@ -86,11 +86,11 @@ function test_create_targetonly(tempDir)
{
let shortcutFile = tempDir.clone();
shortcutFile.append("createdShortcut.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let targetFile = tempDir.clone();
targetFile.append("shortcutTarget.exe");
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let win = shortcutFile.QueryInterface(Ci.nsILocalFileWin);
@ -104,11 +104,11 @@ function test_create_normal(tempDir)
{
let shortcutFile = tempDir.clone();
shortcutFile.append("createdShortcut.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let targetFile = tempDir.clone();
targetFile.append("shortcutTarget.exe");
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let win = shortcutFile.QueryInterface(Ci.nsILocalFileWin);
@ -125,11 +125,11 @@ function test_create_unicode(tempDir)
{
let shortcutFile = tempDir.clone();
shortcutFile.append("createdShortcut.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let targetFile = tempDir.clone();
targetFile.append("ṩhогТϾừ†Target.exe");
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let win = shortcutFile.QueryInterface(Ci.nsILocalFileWin);
@ -146,11 +146,11 @@ function test_update_noargs(tempDir)
{
let shortcutFile = tempDir.clone();
shortcutFile.append("createdShortcut.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let targetFile = tempDir.clone();
targetFile.append("shortcutTarget.exe");
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let win = shortcutFile.QueryInterface(Ci.nsILocalFileWin);
@ -169,11 +169,11 @@ function test_update_notarget(tempDir)
{
let shortcutFile = tempDir.clone();
shortcutFile.append("createdShortcut.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let targetFile = tempDir.clone();
targetFile.append("shortcutTarget.exe");
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let win = shortcutFile.QueryInterface(Ci.nsILocalFileWin);
@ -195,11 +195,11 @@ function test_update_targetonly(tempDir)
{
let shortcutFile = tempDir.clone();
shortcutFile.append("createdShortcut.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let targetFile = tempDir.clone();
targetFile.append("shortcutTarget.exe");
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let win = shortcutFile.QueryInterface(Ci.nsILocalFileWin);
@ -210,7 +210,7 @@ function test_update_targetonly(tempDir)
let newTargetFile = tempDir.clone();
newTargetFile.append("shortcutTarget.exe");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
win.setShortcut(newTargetFile);
@ -222,11 +222,11 @@ function test_update_normal(tempDir)
{
let shortcutFile = tempDir.clone();
shortcutFile.append("createdShortcut.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let targetFile = tempDir.clone();
targetFile.append("shortcutTarget.exe");
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let win = shortcutFile.QueryInterface(Ci.nsILocalFileWin);
@ -237,7 +237,7 @@ function test_update_normal(tempDir)
let newTargetFile = tempDir.clone();
newTargetFile.append("shortcutTarget.exe");
newTargetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
newTargetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
win.setShortcut(newTargetFile,
do_get_profile(),
@ -252,11 +252,11 @@ function test_update_unicode(tempDir)
{
let shortcutFile = tempDir.clone();
shortcutFile.append("createdShortcut.lnk");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let targetFile = tempDir.clone();
targetFile.append("shortcutTarget.exe");
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
targetFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
let win = shortcutFile.QueryInterface(Ci.nsILocalFileWin);
@ -267,7 +267,7 @@ function test_update_unicode(tempDir)
let newTargetFile = tempDir.clone();
newTargetFile.append("ṩhогТϾừ†Target.exe");
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
shortcutFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o666);
win.setShortcut(newTargetFile,
do_get_profile(), // XXX: This should probably be unicode