Backed out changeset 8e52d4dcbaeb (bug 1379256) for failing xpcshell's toolkit/components/osfile/tests/xpcshell/test_read_write.js. r=backout

This commit is contained in:
Sebastian Hengst 2017-08-12 13:48:54 +02:00
Родитель 7a1209abe1
Коммит 5510675246
37 изменённых файлов: 683 добавлений и 517 удалений

Просмотреть файл

@ -2,14 +2,31 @@
module.exports = {
"rules": {
"brace-style": "off",
"comma-spacing": "off",
"consistent-return": "off",
"eol-last": "off",
"func-call-spacing": "off",
"key-spacing": "off",
"keyword-spacing": "off",
"no-else-return": "off",
"no-extra-semi": "off",
"no-irregular-whitespace": "off",
"no-lone-blocks": "off",
"no-lonely-if": "off",
"no-multi-spaces": "off",
"no-redeclare": "off",
"no-self-assign": "off",
"no-shadow": "off",
"no-trailing-spaces": "off",
"no-undef": "off",
"no-unsafe-negation": "off",
"no-unused-vars": "off",
"no-useless-return": "off",
"object-shorthand": "off",
"quotes": "off",
"space-before-function-paren": "off",
"space-infix-ops": "off",
"spaced-comment": "off",
}
};

Просмотреть файл

@ -68,7 +68,7 @@ var Native = Cu.import("resource://gre/modules/osfile/osfile_native.jsm", {});
// Here, we make them lazy loaders.
function lazyPathGetter(constProp, dirKey) {
return function() {
return function () {
let path;
try {
path = Services.dirsvc.get(dirKey, Ci.nsIFile).path;
@ -436,7 +436,7 @@ var Scheduler = this.Scheduler = {
// The last object inside the args may be an options object.
let options = null;
if (args && args.length >= 1 && typeof args[args.length - 1] === "object") {
if (args && args.length >= 1 && typeof args[args.length-1] === "object") {
options = args[args.length - 1];
}
@ -512,7 +512,7 @@ const PREF_OSFILE_LOG_REDIRECT = "toolkit.osfile.log.redirect";
function readDebugPref(prefName, oldPref = false) {
// If neither pref nor oldPref were set, default it to false.
return Services.prefs.getBoolPref(prefName, oldPref);
}
};
/**
* Listen to PREF_OSFILE_LOG changes and update gShouldLog flag
@ -682,7 +682,7 @@ File.prototype = {
[this._fdmsg,
Type.void_t.in_ptr.toMsg(buffer),
options],
buffer/* Ensure that |buffer| is not gc-ed*/);
buffer/*Ensure that |buffer| is not gc-ed*/);
},
/**
@ -1190,10 +1190,10 @@ File.writeAtomic = function writeAtomic(path, buffer, options = {}) {
// As options.tmpPath is a path, we need to encode it as |Type.path| message
if ("tmpPath" in options) {
options.tmpPath = Type.path.toMsg(options.tmpPath);
}
};
if (isTypedArray(buffer) && (!("bytes" in options))) {
options.bytes = buffer.byteLength;
}
};
let refObj = {};
TelemetryStopwatch.start("OSFILE_WRITEATOMIC_JANK_MS", refObj);
let promise = Scheduler.post("writeAtomic",
@ -1270,10 +1270,10 @@ var DirectoryIterator = function DirectoryIterator(path, options) {
this._isClosed = false;
};
DirectoryIterator.prototype = {
iterator: function() {
iterator: function () {
return this;
},
__iterator__: function() {
__iterator__: function () {
return this;
},

Просмотреть файл

@ -85,7 +85,7 @@ if (this.Components) {
*/
add: function(resource, info) {
let id = this._idgen++;
this._map.set(id, {resource: resource, info: info});
this._map.set(id, {resource:resource, info:info});
return id;
},
/**

Просмотреть файл

@ -67,7 +67,7 @@ var EXPORTED_SYMBOLS = [
"OS" // Warning: this exported symbol will disappear
];
// //////////////////// Configuration of OS.File
////////////////////// Configuration of OS.File
var Config = {
/**
@ -84,7 +84,7 @@ var Config = {
};
exports.Config = Config;
// //////////////////// OS Constants
////////////////////// OS Constants
if (typeof Components != "undefined") {
// On the main thread, OS.Constants is defined by a xpcom
@ -96,7 +96,7 @@ if (typeof Components != "undefined") {
exports.Constants = OS.Constants;
// /////////////////// Utilities
///////////////////// Utilities
// Define a lazy getter for a property
var defineLazyGetter = function defineLazyGetter(object, name, getter) {
@ -115,7 +115,7 @@ var defineLazyGetter = function defineLazyGetter(object, name, getter) {
exports.defineLazyGetter = defineLazyGetter;
// /////////////////// Logging
///////////////////// Logging
/**
* The default implementation of the logger.
@ -156,21 +156,21 @@ var stringifyArg = function stringifyArg(arg) {
if (argToString === "[object Object]") {
return JSON.stringify(arg, function(key, value) {
if (isTypedArray(value)) {
return "[" + value.constructor.name + " " + value.byteOffset + " " + value.byteLength + "]";
return "["+ value.constructor.name + " " + value.byteOffset + " " + value.byteLength + "]";
}
if (isArrayBuffer(arg)) {
return "[" + value.constructor.name + " " + value.byteLength + "]";
}
return value;
});
}
} else {
return argToString;
}
}
return arg;
};
var LOG = function(...args) {
var LOG = function (...args) {
if (!Config.DEBUG) {
// If logging is deactivated, don't log
return;
@ -204,7 +204,7 @@ exports.LOG = LOG;
* @param {Array} refs An optional array of field names to be passed by
* reference instead of copying.
*/
var clone = function(object, refs = []) {
var clone = function (object, refs = []) {
let result = {};
// Make a reference between result[key] and object[key].
let refer = function refer(result, key, object) {
@ -230,7 +230,7 @@ var clone = function(object, refs = []) {
exports.clone = clone;
// /////////////////// Abstractions above js-ctypes
///////////////////// Abstractions above js-ctypes
/**
* Abstraction above js-ctypes types.
@ -251,7 +251,7 @@ function Type(name, implementation) {
+ name);
}
if (!(implementation instanceof ctypes.CType)) {
throw new TypeError("Type expects as second argument a ctypes.CType" +
throw new TypeError("Type expects as second argument a ctypes.CType"+
", got: " + implementation);
}
Object.defineProperty(this, "name", { value: name });
@ -431,7 +431,7 @@ exports.isArrayBuffer = isArrayBuffer;
*/
function PtrType(name, implementation, targetType) {
Type.call(this, name, implementation);
if (targetType == null || !(targetType instanceof Type)) {
if (targetType == null || !targetType instanceof Type) {
throw new TypeError("targetType must be an instance of Type");
}
/**
@ -534,7 +534,7 @@ var projectValue = function projectValue(x) {
function projector(type, signed) {
LOG("Determining best projection for", type,
"(size: ", type.size, ")", signed ? "signed" : "unsigned");
"(size: ", type.size, ")", signed?"signed":"unsigned");
if (type instanceof Type) {
type = type.implementation;
}
@ -554,14 +554,14 @@ function projector(type, signed) {
if (signed) {
LOG("Projected as a large signed integer");
return projectLargeInt;
}
} else {
LOG("Projected as a large unsigned integer");
return projectLargeUInt;
}
}
LOG("Projected as a regular number");
return projectValue;
}
};
exports.projectValue = projectValue;
/**
@ -645,7 +645,7 @@ function IntType(name, implementation, signed) {
Type.call(this, name, implementation);
this.importFromC = projector(implementation, signed);
this.project = this.importFromC;
}
};
IntType.prototype = Object.create(Type.prototype);
IntType.prototype.toMsg = function toMsg(value) {
if (typeof value == "number") {
@ -862,7 +862,7 @@ HollowStructure.prototype = {
" at offset " + offset +
" without exceeding its size of " + this.size);
}
let field = {name: name, type: type};
let field = {name: name, type:type};
this.offset_to_field_info[offset] = field;
},
@ -960,7 +960,7 @@ exports.HollowStructure = HollowStructure;
function Library(name, ...candidates) {
this.name = name;
this._candidates = candidates;
}
};
Library.prototype = Object.freeze({
/**
* The native library as a js-ctypes object.
@ -1107,7 +1107,7 @@ exports.Library = Library;
* and any type conversion required.
*/
var declareFFI = function declareFFI(lib, symbol, abi,
returnType /* , argTypes ...*/) {
returnType /*, argTypes ...*/) {
LOG("Attempting to declare FFI ", symbol);
// We guard agressively, to avoid any late surprise
if (typeof symbol != "string") {
@ -1242,10 +1242,10 @@ function normalizeBufferArgs(candidate, bytes) {
"bytes");
}
return bytes;
}
};
exports.normalizeBufferArgs = normalizeBufferArgs;
// /////////////////// OS interactions
///////////////////// OS interactions
/**
* An OS error.
@ -1269,7 +1269,7 @@ OSError.prototype = Object.create(Error.prototype);
exports.OSError = OSError;
// /////////////////// Temporary boilerplate
///////////////////// Temporary boilerplate
// Boilerplate, to simplify the transition to require()
// Do not rely upon this symbol, it will disappear with
// bug 883050.
@ -1306,7 +1306,7 @@ Object.defineProperty(exports.OS.Shared, "TEST", {
});
// /////////////////// Permanent boilerplate
///////////////////// Permanent boilerplate
if (typeof Components != "undefined") {
this.EXPORTED_SYMBOLS = EXPORTED_SYMBOLS;
for (let symbol of EXPORTED_SYMBOLS) {

Просмотреть файл

@ -81,9 +81,9 @@ AbstractFile.prototype = {
}
if (pos == bytes) {
return buffer;
}
} else {
return buffer.subarray(0, pos);
}
},
/**
@ -132,12 +132,12 @@ AbstractFile.prototype = {
*/
AbstractFile.openUnique = function openUnique(path, options = {}) {
let mode = {
create: true
create : true
};
let dirName = Path.dirname(path);
let leafName = Path.basename(path);
let lastDotCharacter = leafName.lastIndexOf(".");
let lastDotCharacter = leafName.lastIndexOf('.');
let fileName = leafName.substring(0, lastDotCharacter != -1 ? lastDotCharacter : leafName.length);
let suffix = (lastDotCharacter != -1 ? leafName.substring(lastDotCharacter) : "");
let uniquePath = "";

Просмотреть файл

@ -51,8 +51,8 @@ exports.declareFFI = declareFFI;
var LazyBindings = {};
libc.declareLazy(LazyBindings, "strerror",
"strerror", ctypes.default_abi,
/* return*/ ctypes.char.ptr,
/* errnum*/ ctypes.int);
/*return*/ ctypes.char.ptr,
/*errnum*/ ctypes.int);
/**
* A File-related error.
@ -88,7 +88,7 @@ OSError.prototype = Object.create(SharedAll.OSError.prototype);
OSError.prototype.toString = function toString() {
return "Unix error " + this.unixErrno +
" during operation " + this.operation +
(this.path ? " on file " + this.path : "") +
(this.path? " on file " + this.path : "") +
" (" + LazyBindings.strerror(this.unixErrno).readString() + ")";
};
OSError.prototype.toMsg = function toMsg() {
@ -366,7 +366,7 @@ var EXPORTED_SYMBOLS = [
"POS_END"
];
// ////////// Boilerplate
//////////// Boilerplate
if (typeof Components != "undefined") {
this.EXPORTED_SYMBOLS = EXPORTED_SYMBOLS;
for (let symbol of EXPORTED_SYMBOLS) {

Просмотреть файл

@ -241,7 +241,8 @@
// Finalizer-related functions
libc.declareLazy(SysFile, "_close",
"close", ctypes.default_abi,
/* return */ctypes.int, ctypes.int);
/*return */ctypes.int,
/*fd*/ ctypes.int);
SysFile.close = function close(fd) {
// Detach the finalizer and call |_close|.
@ -250,7 +251,8 @@
libc.declareLazy(SysFile, "_close_dir",
"closedir", ctypes.default_abi,
/* return */ctypes.int, Type.DIR.in_ptr.implementation);
/*return */ctypes.int,
/*dirp*/ Type.DIR.in_ptr.implementation);
SysFile.closedir = function closedir(fd) {
// Detach the finalizer and call |_close_dir|.
@ -271,35 +273,48 @@
default_lib.declareLazyWithFallback(libc, SysFile, "free",
"free", ctypes.default_abi,
/* return*/ ctypes.void_t, ctypes.voidptr_t);
/*return*/ ctypes.void_t,
/*ptr*/ ctypes.voidptr_t);
}
// Other functions
libc.declareLazyFFI(SysFile, "access",
libc.declareLazyFFI(SysFile, "access",
"access", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing, Type.path, Type.int);
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*mode*/ Type.int);
libc.declareLazyFFI(SysFile, "chdir",
libc.declareLazyFFI(SysFile, "chdir",
"chdir", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing, Type.path);
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path);
libc.declareLazyFFI(SysFile, "chmod",
libc.declareLazyFFI(SysFile, "chmod",
"chmod", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing, Type.path, Type.mode_t);
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*mode*/ Type.mode_t);
libc.declareLazyFFI(SysFile, "chown",
libc.declareLazyFFI(SysFile, "chown",
"chown", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing, Type.path, Type.uid_t, Type.gid_t);
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*uid*/ Type.uid_t,
/*gid*/ Type.gid_t);
libc.declareLazyFFI(SysFile, "copyfile",
libc.declareLazyFFI(SysFile, "copyfile",
"copyfile", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing,
/* source*/ Type.path, Type.path, Type.void_t.in_ptr, Type.uint32_t);
/*return*/ Type.negativeone_or_nothing,
/*source*/ Type.path,
/*dest*/ Type.path,
/*state*/ Type.void_t.in_ptr, // Ignored atm
/*flags*/ Type.uint32_t);
libc.declareLazyFFI(SysFile, "dup",
libc.declareLazyFFI(SysFile, "dup",
"dup", ctypes.default_abi,
/* return*/ Type.negativeone_or_fd, Type.fd);
/*return*/ Type.negativeone_or_fd,
/*fd*/ Type.fd);
if ("OSFILE_SIZEOF_DIR" in Const) {
// On platforms for which |dirfd| is a macro
@ -309,191 +324,239 @@
};
} else {
// On platforms for which |dirfd| is a function
libc.declareLazyFFI(SysFile, "dirfd",
libc.declareLazyFFI(SysFile, "dirfd",
"dirfd", ctypes.default_abi,
/* return*/ Type.negativeone_or_fd, Type.DIR.in_ptr);
/*return*/ Type.negativeone_or_fd,
/*dir*/ Type.DIR.in_ptr);
}
libc.declareLazyFFI(SysFile, "chdir",
libc.declareLazyFFI(SysFile, "chdir",
"chdir", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing, Type.path);
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path);
libc.declareLazyFFI(SysFile, "fchdir",
libc.declareLazyFFI(SysFile, "fchdir",
"fchdir", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing, Type.fd);
/*return*/ Type.negativeone_or_nothing,
/*fd*/ Type.fd);
libc.declareLazyFFI(SysFile, "fchmod",
libc.declareLazyFFI(SysFile, "fchmod",
"fchmod", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing, Type.fd, Type.mode_t);
/*return*/ Type.negativeone_or_nothing,
/*fd*/ Type.fd,
/*mode*/ Type.mode_t);
libc.declareLazyFFI(SysFile, "fchown",
libc.declareLazyFFI(SysFile, "fchown",
"fchown", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing, Type.fd, Type.uid_t, Type.gid_t);
/*return*/ Type.negativeone_or_nothing,
/*fd*/ Type.fd,
/*uid_t*/ Type.uid_t,
/*gid_t*/ Type.gid_t);
libc.declareLazyFFI(SysFile, "fsync",
libc.declareLazyFFI(SysFile, "fsync",
"fsync", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing, Type.fd);
/*return*/ Type.negativeone_or_nothing,
/*fd*/ Type.fd);
libc.declareLazyFFI(SysFile, "getcwd",
libc.declareLazyFFI(SysFile, "getcwd",
"getcwd", ctypes.default_abi,
/* return*/ Type.out_path, Type.out_path, Type.size_t);
/*return*/ Type.out_path,
/*buf*/ Type.out_path,
/*size*/ Type.size_t);
libc.declareLazyFFI(SysFile, "getwd",
libc.declareLazyFFI(SysFile, "getwd",
"getwd", ctypes.default_abi,
/* return*/ Type.out_path, Type.out_path);
/*return*/ Type.out_path,
/*buf*/ Type.out_path);
// Two variants of |getwd| which allocate the memory
// dynamically.
// Linux/Android version
libc.declareLazyFFI(SysFile, "get_current_dir_name",
libc.declareLazyFFI(SysFile, "get_current_dir_name",
"get_current_dir_name", ctypes.default_abi,
/* return*/ Type.out_path.releaseWithLazy(() =>
/*return*/ Type.out_path.releaseWithLazy(() =>
SysFile.free
));
// MacOS/BSD version (will return NULL on Linux/Android)
libc.declareLazyFFI(SysFile, "getwd_auto",
libc.declareLazyFFI(SysFile, "getwd_auto",
"getwd", ctypes.default_abi,
/* return*/ Type.out_path.releaseWithLazy(() =>
/*return*/ Type.out_path.releaseWithLazy(() =>
SysFile.free
), Type.void_t.out_ptr);
),
/*buf*/ Type.void_t.out_ptr);
libc.declareLazyFFI(SysFile, "fdatasync",
libc.declareLazyFFI(SysFile, "fdatasync",
"fdatasync", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing, Type.fd); // Note: MacOS/BSD-specific
/*return*/ Type.negativeone_or_nothing,
/*fd*/ Type.fd); // Note: MacOS/BSD-specific
libc.declareLazyFFI(SysFile, "ftruncate",
libc.declareLazyFFI(SysFile, "ftruncate",
"ftruncate", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing, Type.fd,
/* length*/ Type.off_t);
/*return*/ Type.negativeone_or_nothing,
/*fd*/ Type.fd,
/*length*/ Type.off_t);
libc.declareLazyFFI(SysFile, "lchown",
libc.declareLazyFFI(SysFile, "lchown",
"lchown", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing, Type.path, Type.uid_t, Type.gid_t);
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*uid_t*/ Type.uid_t,
/*gid_t*/ Type.gid_t);
libc.declareLazyFFI(SysFile, "link",
libc.declareLazyFFI(SysFile, "link",
"link", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing,
/* source*/ Type.path, Type.path);
/*return*/ Type.negativeone_or_nothing,
/*source*/ Type.path,
/*dest*/ Type.path);
libc.declareLazyFFI(SysFile, "lseek",
libc.declareLazyFFI(SysFile, "lseek",
"lseek", ctypes.default_abi,
/* return*/ Type.off_t, Type.fd,
/* offset*/ Type.off_t,
/* whence*/ Type.int);
/*return*/ Type.off_t,
/*fd*/ Type.fd,
/*offset*/ Type.off_t,
/*whence*/ Type.int);
libc.declareLazyFFI(SysFile, "mkdir",
libc.declareLazyFFI(SysFile, "mkdir",
"mkdir", ctypes.default_abi,
/* return*/ Type.int,
/* path*/ Type.path,
/* mode*/ Type.int);
/*return*/ Type.int,
/*path*/ Type.path,
/*mode*/ Type.int);
libc.declareLazyFFI(SysFile, "mkstemp",
"mkstemp", ctypes.default_abi, Type.fd,
/* template*/ Type.out_path);
libc.declareLazyFFI(SysFile, "mkstemp",
"mkstemp", ctypes.default_abi,
/*return*/ Type.fd,
/*template*/ Type.out_path);
libc.declareLazyFFI(SysFile, "open",
libc.declareLazyFFI(SysFile, "open",
"open", ctypes.default_abi,
/* return*/ Type.negativeone_or_fd, Type.path,
/* oflags*/ Type.int, Type.int);
/*return*/ Type.negativeone_or_fd,
/*path*/ Type.path,
/*oflags*/ Type.int,
/*mode*/ Type.int);
if (OS.Constants.Sys.Name == "NetBSD") {
libc.declareLazyFFI(SysFile, "opendir",
libc.declareLazyFFI(SysFile, "opendir",
"__opendir30", ctypes.default_abi,
/* return*/ Type.null_or_DIR_ptr, Type.path);
/*return*/ Type.null_or_DIR_ptr,
/*path*/ Type.path);
} else {
libc.declareLazyFFI(SysFile, "opendir",
libc.declareLazyFFI(SysFile, "opendir",
"opendir", ctypes.default_abi,
/* return*/ Type.null_or_DIR_ptr, Type.path);
/*return*/ Type.null_or_DIR_ptr,
/*path*/ Type.path);
}
libc.declareLazyFFI(SysFile, "pread",
libc.declareLazyFFI(SysFile, "pread",
"pread", ctypes.default_abi,
/* return*/ Type.negativeone_or_ssize_t, Type.fd, Type.void_t.out_ptr,
/* nbytes*/ Type.size_t,
/* offset*/ Type.off_t);
/*return*/ Type.negativeone_or_ssize_t,
/*fd*/ Type.fd,
/*buf*/ Type.void_t.out_ptr,
/*nbytes*/ Type.size_t,
/*offset*/ Type.off_t);
libc.declareLazyFFI(SysFile, "pwrite",
libc.declareLazyFFI(SysFile, "pwrite",
"pwrite", ctypes.default_abi,
/* return*/ Type.negativeone_or_ssize_t, Type.fd, Type.void_t.in_ptr,
/* nbytes*/ Type.size_t,
/* offset*/ Type.off_t);
/*return*/ Type.negativeone_or_ssize_t,
/*fd*/ Type.fd,
/*buf*/ Type.void_t.in_ptr,
/*nbytes*/ Type.size_t,
/*offset*/ Type.off_t);
libc.declareLazyFFI(SysFile, "read",
libc.declareLazyFFI(SysFile, "read",
"read", ctypes.default_abi,
/* return*/Type.negativeone_or_ssize_t, Type.fd, Type.void_t.out_ptr,
/* nbytes*/Type.size_t);
/*return*/Type.negativeone_or_ssize_t,
/*fd*/ Type.fd,
/*buf*/ Type.void_t.out_ptr,
/*nbytes*/Type.size_t);
libc.declareLazyFFI(SysFile, "posix_fadvise",
libc.declareLazyFFI(SysFile, "posix_fadvise",
"posix_fadvise", ctypes.default_abi,
/* return*/ Type.int, Type.fd,
/* offset*/ Type.off_t, Type.off_t,
/* advise*/ Type.int);
/*return*/ Type.int,
/*fd*/ Type.fd,
/*offset*/ Type.off_t,
/*len*/ Type.off_t,
/*advise*/ Type.int);
if (Const._DARWIN_FEATURE_64_BIT_INODE) {
// Special case for MacOS X 10.5+
// Symbol name "readdir" still exists but is used for a
// deprecated function that does not match the
// constants of |Const|.
libc.declareLazyFFI(SysFile, "readdir",
libc.declareLazyFFI(SysFile, "readdir",
"readdir$INODE64", ctypes.default_abi,
/* return*/ Type.null_or_dirent_ptr, Type.DIR.in_ptr); // For MacOS X
/*return*/ Type.null_or_dirent_ptr,
/*dir*/ Type.DIR.in_ptr); // For MacOS X
} else if (OS.Constants.Sys.Name == "NetBSD") {
libc.declareLazyFFI(SysFile, "readdir",
libc.declareLazyFFI(SysFile, "readdir",
"__readdir30", ctypes.default_abi,
/* return*/Type.null_or_dirent_ptr, Type.DIR.in_ptr); // Other Unices
/*return*/Type.null_or_dirent_ptr,
/*dir*/ Type.DIR.in_ptr); // Other Unices
} else {
libc.declareLazyFFI(SysFile, "readdir",
libc.declareLazyFFI(SysFile, "readdir",
"readdir", ctypes.default_abi,
/* return*/Type.null_or_dirent_ptr, Type.DIR.in_ptr); // Other Unices
/*return*/Type.null_or_dirent_ptr,
/*dir*/ Type.DIR.in_ptr); // Other Unices
}
libc.declareLazyFFI(SysFile, "rename",
libc.declareLazyFFI(SysFile, "rename",
"rename", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing, Type.path, Type.path);
/*return*/ Type.negativeone_or_nothing,
/*old*/ Type.path,
/*new*/ Type.path);
libc.declareLazyFFI(SysFile, "rmdir",
libc.declareLazyFFI(SysFile, "rmdir",
"rmdir", ctypes.default_abi,
/* return*/ Type.int, Type.path);
/*return*/ Type.int,
/*path*/ Type.path);
libc.declareLazyFFI(SysFile, "splice",
libc.declareLazyFFI(SysFile, "splice",
"splice", ctypes.default_abi,
/* return*/ Type.long, Type.fd,
/* off_in*/ Type.off_t.in_ptr,
/* fd_out*/ Type.fd,
/* off_out*/Type.off_t.in_ptr, Type.size_t, Type.unsigned_int); // Linux/Android-specific
/*return*/ Type.long,
/*fd_in*/ Type.fd,
/*off_in*/ Type.off_t.in_ptr,
/*fd_out*/ Type.fd,
/*off_out*/Type.off_t.in_ptr,
/*len*/ Type.size_t,
/*flags*/ Type.unsigned_int); // Linux/Android-specific
libc.declareLazyFFI(SysFile, "statfs",
libc.declareLazyFFI(SysFile, "statfs",
"statfs", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing, Type.path, Type.statvfs.out_ptr); // Android,B2G
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*buf*/ Type.statvfs.out_ptr); // Android,B2G
libc.declareLazyFFI(SysFile, "statvfs",
libc.declareLazyFFI(SysFile, "statvfs",
"statvfs", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing, Type.path, Type.statvfs.out_ptr); // Other platforms
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*buf*/ Type.statvfs.out_ptr); // Other platforms
libc.declareLazyFFI(SysFile, "symlink",
libc.declareLazyFFI(SysFile, "symlink",
"symlink", ctypes.default_abi,
/* return*/ Type.negativeone_or_nothing,
/* source*/ Type.path, Type.path);
/*return*/ Type.negativeone_or_nothing,
/*source*/ Type.path,
/*dest*/ Type.path);
libc.declareLazyFFI(SysFile, "truncate",
libc.declareLazyFFI(SysFile, "truncate",
"truncate", ctypes.default_abi,
/* return*/Type.negativeone_or_nothing, Type.path,
/* length*/ Type.off_t);
/*return*/Type.negativeone_or_nothing,
/*path*/ Type.path,
/*length*/ Type.off_t);
libc.declareLazyFFI(SysFile, "unlink",
libc.declareLazyFFI(SysFile, "unlink",
"unlink", ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* path */ Type.path);
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path);
libc.declareLazyFFI(SysFile, "write",
libc.declareLazyFFI(SysFile, "write",
"write", ctypes.default_abi,
/* return */ Type.negativeone_or_ssize_t,
/* fd */ Type.fd,
/* buf */ Type.void_t.in_ptr,
/* nbytes */ Type.size_t);
/*return*/ Type.negativeone_or_ssize_t,
/*fd*/ Type.fd,
/*buf*/ Type.void_t.in_ptr,
/*nbytes*/ Type.size_t);
// Weird cases that require special treatment
@ -501,23 +564,23 @@
// 32-bits and 64-bits versions of |stat|, |lstat|, |fstat|.
if (Const._DARWIN_FEATURE_64_BIT_INODE) {
// MacOS X 64-bits
libc.declareLazyFFI(SysFile, "stat",
libc.declareLazyFFI(SysFile, "stat",
"stat$INODE64", ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* path */ Type.path,
/* buf */ Type.stat.out_ptr
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*buf*/ Type.stat.out_ptr
);
libc.declareLazyFFI(SysFile, "lstat",
libc.declareLazyFFI(SysFile, "lstat",
"lstat$INODE64", ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* path */ Type.path,
/* buf */ Type.stat.out_ptr
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*buf*/ Type.stat.out_ptr
);
libc.declareLazyFFI(SysFile, "fstat",
libc.declareLazyFFI(SysFile, "fstat",
"fstat$INODE64", ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* path */ Type.fd,
/* buf */ Type.stat.out_ptr
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.fd,
/*buf*/ Type.stat.out_ptr
);
} else if (Const._STAT_VER != undefined) {
const ver = Const._STAT_VER;
@ -535,24 +598,24 @@
}
let Stat = {};
libc.declareLazyFFI(Stat, "xstat",
libc.declareLazyFFI(Stat, "xstat",
xstat_name, ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* _stat_ver */ Type.int,
/* path */ Type.path,
/* buf */ Type.stat.out_ptr);
libc.declareLazyFFI(Stat, "lxstat",
/*return*/ Type.negativeone_or_nothing,
/*_stat_ver*/ Type.int,
/*path*/ Type.path,
/*buf*/ Type.stat.out_ptr);
libc.declareLazyFFI(Stat, "lxstat",
lxstat_name, ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* _stat_ver */ Type.int,
/* path */ Type.path,
/* buf */ Type.stat.out_ptr);
/*return*/ Type.negativeone_or_nothing,
/*_stat_ver*/ Type.int,
/*path*/ Type.path,
/*buf*/ Type.stat.out_ptr);
libc.declareLazyFFI(Stat, "fxstat",
fxstat_name, ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* _stat_ver */ Type.int,
/* fd */ Type.fd,
/* buf */ Type.stat.out_ptr);
/*return*/ Type.negativeone_or_nothing,
/*_stat_ver*/ Type.int,
/*fd*/ Type.fd,
/*buf*/ Type.stat.out_ptr);
SysFile.stat = function stat(path, buf) {
@ -568,43 +631,43 @@
};
} else if (OS.Constants.Sys.Name == "NetBSD") {
// NetBSD 5.0 and newer
libc.declareLazyFFI(SysFile, "stat",
libc.declareLazyFFI(SysFile, "stat",
"__stat50", ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* path */ Type.path,
/* buf */ Type.stat.out_ptr
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*buf*/ Type.stat.out_ptr
);
libc.declareLazyFFI(SysFile, "lstat",
libc.declareLazyFFI(SysFile, "lstat",
"__lstat50", ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* path */ Type.path,
/* buf */ Type.stat.out_ptr
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*buf*/ Type.stat.out_ptr
);
libc.declareLazyFFI(SysFile, "fstat",
libc.declareLazyFFI(SysFile, "fstat",
"__fstat50", ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* fd */ Type.fd,
/* buf */ Type.stat.out_ptr
/*return*/ Type.negativeone_or_nothing,
/*fd*/ Type.fd,
/*buf*/ Type.stat.out_ptr
);
} else {
// Mac OS X 32-bits, other Unix
libc.declareLazyFFI(SysFile, "stat",
libc.declareLazyFFI(SysFile, "stat",
"stat", ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* path */ Type.path,
/* buf */ Type.stat.out_ptr
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*buf*/ Type.stat.out_ptr
);
libc.declareLazyFFI(SysFile, "lstat",
libc.declareLazyFFI(SysFile, "lstat",
"lstat", ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* path */ Type.path,
/* buf */ Type.stat.out_ptr
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*buf*/ Type.stat.out_ptr
);
libc.declareLazyFFI(SysFile, "fstat",
libc.declareLazyFFI(SysFile, "fstat",
"fstat", ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* fd */ Type.fd,
/* buf */ Type.stat.out_ptr
/*return*/ Type.negativeone_or_nothing,
/*fd*/ Type.fd,
/*buf*/ Type.stat.out_ptr
);
}
@ -614,8 +677,8 @@
let Pipe = {};
libc.declareLazyFFI(Pipe, "_pipe",
"pipe", ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* fds */ new SharedAll.Type("two file descriptors",
/*return*/ Type.negativeone_or_nothing,
/*fds*/ new SharedAll.Type("two file descriptors",
ctypes.ArrayType(ctypes.int, 2)));
// A shared per-thread buffer used to communicate with |pipe|
@ -634,31 +697,31 @@
if (OS.Constants.Sys.Name == "NetBSD") {
libc.declareLazyFFI(SysFile, "utimes",
"__utimes50", ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* path */ Type.path,
/* timeval[2] */ Type.timevals.out_ptr
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*timeval[2]*/ Type.timevals.out_ptr
);
} else {
libc.declareLazyFFI(SysFile, "utimes",
"utimes", ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* path */ Type.path,
/* timeval[2] */ Type.timevals.out_ptr
/*return*/ Type.negativeone_or_nothing,
/*path*/ Type.path,
/*timeval[2]*/ Type.timevals.out_ptr
);
}
if (OS.Constants.Sys.Name == "NetBSD") {
libc.declareLazyFFI(SysFile, "futimes",
"__futimes50", ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* fd */ Type.fd,
/* timeval[2] */ Type.timevals.out_ptr
/*return*/ Type.negativeone_or_nothing,
/*fd*/ Type.fd,
/*timeval[2]*/ Type.timevals.out_ptr
);
} else {
libc.declareLazyFFI(SysFile, "futimes",
"futimes", ctypes.default_abi,
/* return */ Type.negativeone_or_nothing,
/* fd */ Type.fd,
/* timeval[2] */ Type.timevals.out_ptr
/*return*/ Type.negativeone_or_nothing,
/*fd*/ Type.fd,
/*timeval[2]*/ Type.timevals.out_ptr
);
}
};

Просмотреть файл

@ -77,7 +77,7 @@
if (this._closeResult) {
throw this._closeResult;
}
return;
};
/**
@ -98,7 +98,7 @@
File.prototype._read = function _read(buffer, nbytes, options = {}) {
// Populate the page cache with data from a file so the subsequent reads
// from that file will not block on disk I/O.
if (typeof(UnixFile.posix_fadvise) === "function" &&
if (typeof(UnixFile.posix_fadvise) === 'function' &&
(options.sequential || !("sequential" in options))) {
UnixFile.posix_fadvise(this.fd, 0, nbytes,
OS.Constants.libc.POSIX_FADV_SEQUENTIAL);
@ -338,9 +338,9 @@
File.exists = function Unix_exists(path) {
if (UnixFile.access(path, Const.F_OK) == -1) {
return false;
}
} else {
return true;
}
};
/**
@ -396,7 +396,7 @@
let fileSystemInfo = new Type.statvfs.implementation();
let fileSystemInfoPtr = fileSystemInfo.address();
throw_on_negative("statvfs", (UnixFile.statvfs || UnixFile.statfs)(sourcePath, fileSystemInfoPtr));
throw_on_negative("statvfs", (UnixFile.statvfs || UnixFile.statfs)(sourcePath, fileSystemInfoPtr));
let bytes = new Type.uint64_t.implementation(
fileSystemInfo.f_frsize * fileSystemInfo.f_bavail);
@ -602,7 +602,7 @@
"pump",
UnixFile.splice(pipe_read, null,
dest_fd, null, bytes_read,
(bytes_read == chunk_size) ? Const.SPLICE_F_MORE : 0
(bytes_read == chunk_size)?Const.SPLICE_F_MORE:0
));
if (!bytes_written) {
// This should never happen
@ -649,9 +649,9 @@
// Need to open the output file with |append:false|, or else |splice|
// won't work.
if (options.noOverwrite) {
dest = File.open(destPath, {create: true, append: false});
dest = File.open(destPath, {create:true, append:false});
} else {
dest = File.open(destPath, {trunc: true, append: false});
dest = File.open(destPath, {trunc:true, append:false});
}
if (options.unixUserland) {
result = pump_userland(source, dest, options);
@ -853,7 +853,7 @@
let gStatData = new Type.stat.implementation();
let gStatDataPtr = gStatData.address();
let MODE_MASK = 4095 /* = 07777*/;
let MODE_MASK = 4095 /*= 07777*/;
File.Info = function Info(stat, path) {
let isDir = (stat.st_mode & Const.S_IFMT) == Const.S_IFDIR;
let isSymLink = (stat.st_mode & Const.S_IFMT) == Const.S_IFLNK;
@ -1163,7 +1163,7 @@
"|Date| instance or number");
}
return date;
}
};
/**
* Helper used by both versions of setPermissions.

Просмотреть файл

@ -51,10 +51,14 @@ var Scope = {};
// Define Error
libc.declareLazy(Scope, "FormatMessage",
"FormatMessageW", ctypes.winapi_abi,
/* return*/ ctypes.uint32_t, ctypes.uint32_t,
/* source*/ ctypes.voidptr_t, ctypes.uint32_t,
/* langid*/ ctypes.uint32_t, ctypes.char16_t.ptr, ctypes.uint32_t,
/* Arguments*/ctypes.voidptr_t);
/*return*/ ctypes.uint32_t,
/*flags*/ ctypes.uint32_t,
/*source*/ ctypes.voidptr_t,
/*msgid*/ ctypes.uint32_t,
/*langid*/ ctypes.uint32_t,
/*buf*/ ctypes.char16_t.ptr,
/*size*/ ctypes.uint32_t,
/*Arguments*/ctypes.voidptr_t);
/**
* A File-related error.
@ -95,8 +99,10 @@ OSError.prototype.toString = function toString() {
Const.FORMAT_MESSAGE_IGNORE_INSERTS,
null,
/* The error number */ this.winLastError,
/* Default language */ 0, buf,
/* Minimum size of buffer */ 1024, null
/* Default language */ 0,
/* Output buffer*/ buf,
/* Minimum size of buffer */ 1024,
/* Format args*/ null
);
if (!result) {
buf = "additional error " +
@ -104,7 +110,7 @@ OSError.prototype.toString = function toString() {
" while fetching system error message";
}
return "Win error " + this.winLastError + " during operation "
+ this.operation + (this.path ? " on file " + this.path : "") +
+ this.operation + (this.path? " on file " + this.path : "") +
" (" + buf.readString() + ")";
};
OSError.prototype.toMsg = function toMsg() {
@ -410,7 +416,7 @@ var EXPORTED_SYMBOLS = [
"POS_END"
];
// ////////// Boilerplate
//////////// Boilerplate
if (typeof Components != "undefined") {
this.EXPORTED_SYMBOLS = EXPORTED_SYMBOLS;
for (let symbol of EXPORTED_SYMBOLS) {

Просмотреть файл

@ -201,177 +201,231 @@
// finalizer
libc.declareLazy(SysFile, "_CloseHandle",
"CloseHandle", ctypes.winapi_abi,
/* return */ctypes.bool,
/* handle*/ ctypes.voidptr_t);
/*return */ctypes.bool,
/*handle*/ ctypes.voidptr_t);
SysFile.CloseHandle = function(fd) {
if (fd == INVALID_HANDLE) {
return true;
}
} else {
return fd.dispose(); // Returns the value of |CloseHandle|.
}
};
libc.declareLazy(SysFile, "_FindClose",
"FindClose", ctypes.winapi_abi,
/* return */ctypes.bool,
/* handle*/ ctypes.voidptr_t);
/*return */ctypes.bool,
/*handle*/ ctypes.voidptr_t);
SysFile.FindClose = function(handle) {
if (handle == INVALID_HANDLE) {
return true;
}
} else {
return handle.dispose(); // Returns the value of |FindClose|.
}
};
// Declare libc functions as functions of |OS.Win.File|
libc.declareLazyFFI(SysFile, "CopyFile",
"CopyFileW", ctypes.winapi_abi,
/* return*/ Type.zero_or_nothing,
/* sourcePath*/ Type.path, Type.path,
/* bailIfExist*/Type.bool);
/*return*/ Type.zero_or_nothing,
/*sourcePath*/ Type.path,
/*destPath*/ Type.path,
/*bailIfExist*/Type.bool);
libc.declareLazyFFI(SysFile, "CreateDirectory",
"CreateDirectoryW", ctypes.winapi_abi,
/* return*/ Type.zero_or_nothing, Type.char16_t.in_ptr,
/* security*/Type.SECURITY_ATTRIBUTES.in_ptr);
/*return*/ Type.zero_or_nothing,
/*name*/ Type.char16_t.in_ptr,
/*security*/Type.SECURITY_ATTRIBUTES.in_ptr);
libc.declareLazyFFI(SysFile, "CreateFile",
"CreateFileW", ctypes.winapi_abi, Type.file_HANDLE, Type.path, Type.DWORD_FLAGS, Type.DWORD_FLAGS,
/* security*/Type.SECURITY_ATTRIBUTES.in_ptr,
/* creation*/Type.DWORD_FLAGS, Type.DWORD_FLAGS,
/* template*/Type.HANDLE);
"CreateFileW", ctypes.winapi_abi,
/*return*/ Type.file_HANDLE,
/*name*/ Type.path,
/*access*/ Type.DWORD_FLAGS,
/*share*/ Type.DWORD_FLAGS,
/*security*/Type.SECURITY_ATTRIBUTES.in_ptr,
/*creation*/Type.DWORD_FLAGS,
/*flags*/ Type.DWORD_FLAGS,
/*template*/Type.HANDLE);
libc.declareLazyFFI(SysFile, "DeleteFile",
"DeleteFileW", ctypes.winapi_abi,
/* return*/ Type.zero_or_nothing, Type.path);
/*return*/ Type.zero_or_nothing,
/*path*/ Type.path);
libc.declareLazyFFI(SysFile, "FileTimeToSystemTime",
"FileTimeToSystemTime", ctypes.winapi_abi,
/* return*/ Type.zero_or_nothing,
/* filetime*/Type.FILETIME.in_ptr,
/* systime*/ Type.SystemTime.out_ptr);
/*return*/ Type.zero_or_nothing,
/*filetime*/Type.FILETIME.in_ptr,
/*systime*/ Type.SystemTime.out_ptr);
libc.declareLazyFFI(SysFile, "SystemTimeToFileTime",
"SystemTimeToFileTime", ctypes.winapi_abi, Type.zero_or_nothing, Type.SystemTime.in_ptr,
/* filetime*/ Type.FILETIME.out_ptr);
"SystemTimeToFileTime", ctypes.winapi_abi,
/*return*/ Type.zero_or_nothing,
/*systime*/ Type.SystemTime.in_ptr,
/*filetime*/ Type.FILETIME.out_ptr);
libc.declareLazyFFI(SysFile, "FindFirstFile",
"FindFirstFileW", ctypes.winapi_abi,
/* return*/ Type.find_HANDLE,
/* pattern*/Type.path, Type.FindData.out_ptr);
/*return*/ Type.find_HANDLE,
/*pattern*/Type.path,
/*data*/ Type.FindData.out_ptr);
libc.declareLazyFFI(SysFile, "FindNextFile",
"FindNextFileW", ctypes.winapi_abi,
/* return*/ Type.zero_or_nothing, Type.find_HANDLE, Type.FindData.out_ptr);
/*return*/ Type.zero_or_nothing,
/*prev*/ Type.find_HANDLE,
/*data*/ Type.FindData.out_ptr);
libc.declareLazyFFI(SysFile, "FormatMessage",
"FormatMessageW", ctypes.winapi_abi,
/* return*/ Type.DWORD, Type.DWORD_FLAGS,
/* source*/ Type.void_t.in_ptr, Type.DWORD_FLAGS,
/* langid*/ Type.DWORD_FLAGS, Type.out_wstring, Type.DWORD,
/* Arguments*/Type.void_t.in_ptr
/*return*/ Type.DWORD,
/*flags*/ Type.DWORD_FLAGS,
/*source*/ Type.void_t.in_ptr,
/*msgid*/ Type.DWORD_FLAGS,
/*langid*/ Type.DWORD_FLAGS,
/*buf*/ Type.out_wstring,
/*size*/ Type.DWORD,
/*Arguments*/Type.void_t.in_ptr
);
libc.declareLazyFFI(SysFile, "GetCurrentDirectory",
"GetCurrentDirectoryW", ctypes.winapi_abi,
/* return*/ Type.zero_or_DWORD,
/* length*/ Type.DWORD, Type.out_path
/*return*/ Type.zero_or_DWORD,
/*length*/ Type.DWORD,
/*buf*/ Type.out_path
);
libc.declareLazyFFI(SysFile, "GetFullPathName",
"GetFullPathNameW", ctypes.winapi_abi, Type.zero_or_DWORD,
/* fileName*/ Type.path, Type.DWORD, Type.out_path,
/* filePart*/ Type.DWORD
"GetFullPathNameW", ctypes.winapi_abi,
/*return*/ Type.zero_or_DWORD,
/*fileName*/ Type.path,
/*length*/ Type.DWORD,
/*buf*/ Type.out_path,
/*filePart*/ Type.DWORD
);
libc.declareLazyFFI(SysFile, "GetDiskFreeSpaceEx",
"GetDiskFreeSpaceExW", ctypes.winapi_abi,
/* return*/ Type.zero_or_nothing,
/* directoryName*/ Type.path,
/* freeBytesForUser*/ Type.uint64_t.out_ptr,
/* totalBytesForUser*/ Type.uint64_t.out_ptr,
/* freeTotalBytesOnDrive*/ Type.uint64_t.out_ptr);
/*return*/ Type.zero_or_nothing,
/*directoryName*/ Type.path,
/*freeBytesForUser*/ Type.uint64_t.out_ptr,
/*totalBytesForUser*/ Type.uint64_t.out_ptr,
/*freeTotalBytesOnDrive*/ Type.uint64_t.out_ptr);
libc.declareLazyFFI(SysFile, "GetFileInformationByHandle",
"GetFileInformationByHandle", ctypes.winapi_abi,
/* return*/ Type.zero_or_nothing,
/* handle*/ Type.HANDLE, Type.FILE_INFORMATION.out_ptr);
/*return*/ Type.zero_or_nothing,
/*handle*/ Type.HANDLE,
/*info*/ Type.FILE_INFORMATION.out_ptr);
libc.declareLazyFFI(SysFile, "MoveFileEx",
"MoveFileExW", ctypes.winapi_abi, Type.zero_or_nothing,
/* sourcePath*/ Type.path,
/* destPath*/ Type.path, Type.DWORD
"MoveFileExW", ctypes.winapi_abi,
/*return*/ Type.zero_or_nothing,
/*sourcePath*/ Type.path,
/*destPath*/ Type.path,
/*flags*/ Type.DWORD
);
libc.declareLazyFFI(SysFile, "ReadFile",
"ReadFile", ctypes.winapi_abi,
/* return*/ Type.zero_or_nothing, Type.HANDLE,
/* buffer*/ Type.voidptr_t,
/* nbytes*/ Type.DWORD,
/* nbytes_read*/Type.DWORD.out_ptr,
/* overlapped*/Type.void_t.inout_ptr // FIXME: Implement?
/*return*/ Type.zero_or_nothing,
/*file*/ Type.HANDLE,
/*buffer*/ Type.voidptr_t,
/*nbytes*/ Type.DWORD,
/*nbytes_read*/Type.DWORD.out_ptr,
/*overlapped*/Type.void_t.inout_ptr // FIXME: Implement?
);
libc.declareLazyFFI(SysFile, "RemoveDirectory",
"RemoveDirectoryW", ctypes.winapi_abi,
/* return*/ Type.zero_or_nothing, Type.path);
/*return*/ Type.zero_or_nothing,
/*path*/ Type.path);
libc.declareLazyFFI(SysFile, "SetCurrentDirectory",
"SetCurrentDirectoryW", ctypes.winapi_abi,
/* return*/ Type.zero_or_nothing, Type.path
/*return*/ Type.zero_or_nothing,
/*path*/ Type.path
);
libc.declareLazyFFI(SysFile, "SetEndOfFile",
"SetEndOfFile", ctypes.winapi_abi,
/* return*/ Type.zero_or_nothing, Type.HANDLE);
/*return*/ Type.zero_or_nothing,
/*file*/ Type.HANDLE);
libc.declareLazyFFI(SysFile, "SetFilePointer",
"SetFilePointer", ctypes.winapi_abi,
/* return*/ Type.DWORD, Type.HANDLE,
/* distlow*/Type.long,
/* disthi*/ Type.long.in_ptr,
/* method*/ Type.DWORD);
/*return*/ Type.DWORD,
/*file*/ Type.HANDLE,
/*distlow*/Type.long,
/*disthi*/ Type.long.in_ptr,
/*method*/ Type.DWORD);
libc.declareLazyFFI(SysFile, "SetFileTime",
"SetFileTime", ctypes.winapi_abi, Type.zero_or_nothing, Type.HANDLE,
/* creation*/ Type.FILETIME.in_ptr, Type.FILETIME.in_ptr, Type.FILETIME.in_ptr);
"SetFileTime", ctypes.winapi_abi,
/*return*/ Type.zero_or_nothing,
/*file*/ Type.HANDLE,
/*creation*/ Type.FILETIME.in_ptr,
/*access*/ Type.FILETIME.in_ptr,
/*write*/ Type.FILETIME.in_ptr);
libc.declareLazyFFI(SysFile, "WriteFile",
"WriteFile", ctypes.winapi_abi,
/* return*/ Type.zero_or_nothing, Type.HANDLE,
/* buffer*/ Type.voidptr_t,
/* nbytes*/ Type.DWORD,
/* nbytes_wr*/Type.DWORD.out_ptr,
/* overlapped*/Type.void_t.inout_ptr // FIXME: Implement?
/*return*/ Type.zero_or_nothing,
/*file*/ Type.HANDLE,
/*buffer*/ Type.voidptr_t,
/*nbytes*/ Type.DWORD,
/*nbytes_wr*/Type.DWORD.out_ptr,
/*overlapped*/Type.void_t.inout_ptr // FIXME: Implement?
);
libc.declareLazyFFI(SysFile, "FlushFileBuffers",
"FlushFileBuffers", ctypes.winapi_abi,
/* return*/ Type.zero_or_nothing, Type.HANDLE);
/*return*/ Type.zero_or_nothing,
/*file*/ Type.HANDLE);
libc.declareLazyFFI(SysFile, "GetFileAttributes",
"GetFileAttributesW", ctypes.winapi_abi, Type.DWORD_FLAGS,
/* fileName*/ Type.path);
"GetFileAttributesW", ctypes.winapi_abi,
/*return*/ Type.DWORD_FLAGS,
/*fileName*/ Type.path);
libc.declareLazyFFI(SysFile, "SetFileAttributes",
"SetFileAttributesW", ctypes.winapi_abi, Type.zero_or_nothing, Type.path,
/* fileAttributes*/ Type.DWORD_FLAGS);
"SetFileAttributesW", ctypes.winapi_abi,
/*return*/ Type.zero_or_nothing,
/*fileName*/ Type.path,
/*fileAttributes*/ Type.DWORD_FLAGS);
advapi32.declareLazyFFI(SysFile, "GetNamedSecurityInfo",
"GetNamedSecurityInfoW", ctypes.winapi_abi, Type.DWORD, Type.path, Type.DWORD,
/* securityInfo*/ Type.DWORD, Type.PSID.out_ptr, Type.PSID.out_ptr, Type.PACL.out_ptr, Type.PACL.out_ptr,
/* securityDesc*/ Type.PSECURITY_DESCRIPTOR.out_ptr);
"GetNamedSecurityInfoW", ctypes.winapi_abi,
/*return*/ Type.DWORD,
/*objectName*/ Type.path,
/*objectType*/ Type.DWORD,
/*securityInfo*/ Type.DWORD,
/*sidOwner*/ Type.PSID.out_ptr,
/*sidGroup*/ Type.PSID.out_ptr,
/*dacl*/ Type.PACL.out_ptr,
/*sacl*/ Type.PACL.out_ptr,
/*securityDesc*/ Type.PSECURITY_DESCRIPTOR.out_ptr);
advapi32.declareLazyFFI(SysFile, "SetNamedSecurityInfo",
"SetNamedSecurityInfoW", ctypes.winapi_abi, Type.DWORD, Type.path, Type.DWORD,
/* securityInfo*/ Type.DWORD, Type.PSID, Type.PSID, Type.PACL, Type.PACL);
"SetNamedSecurityInfoW", ctypes.winapi_abi,
/*return*/ Type.DWORD,
/*objectName*/ Type.path,
/*objectType*/ Type.DWORD,
/*securityInfo*/ Type.DWORD,
/*sidOwner*/ Type.PSID,
/*sidGroup*/ Type.PSID,
/*dacl*/ Type.PACL,
/*sacl*/ Type.PACL);
libc.declareLazyFFI(SysFile, "LocalFree",
"LocalFree", ctypes.winapi_abi, Type.HLOCAL, Type.HLOCAL);
"LocalFree", ctypes.winapi_abi,
/*return*/ Type.HLOCAL,
/*mem*/ Type.HLOCAL);
};
exports.OS.Win = {

Просмотреть файл

@ -95,7 +95,7 @@
if (this._closeResult) {
throw this._closeResult;
}
return;
};
/**
@ -374,7 +374,7 @@
access = options.winAccess;
disposition = options.winDisposition;
} else if (("winAccess" in options && !("winDisposition" in options))
|| (!("winAccess" in options) && "winDisposition" in options)) {
||(!("winAccess" in options) && "winDisposition" in options)) {
throw new TypeError("OS.File.open requires either both options " +
"winAccess and winDisposition or neither");
} else {
@ -538,7 +538,7 @@
// Removing last component if it's empty
// An empty last component is caused by trailing slashes in path
// This is always the case with root directories
if ( splitPath.components[splitPath.components.length - 1].length === 0 ) {
if( splitPath.components[splitPath.components.length - 1].length === 0 ) {
splitPath.components.pop();
}
// One component consisting of a drive letter implies a directory root.
@ -635,16 +635,16 @@
let sd = new ctypes.voidptr_t();
WinFile.GetNamedSecurityInfo(destPath, Const.SE_FILE_OBJECT,
Const.DACL_SECURITY_INFORMATION,
null /* sidOwner*/, null /* sidGroup*/,
dacl.address(), null /* sacl*/,
null /*sidOwner*/, null /*sidGroup*/,
dacl.address(), null /*sacl*/,
sd.address());
// dacl will be set only if the function succeeds.
if (!dacl.isNull()) {
WinFile.SetNamedSecurityInfo(destPath, Const.SE_FILE_OBJECT,
Const.DACL_SECURITY_INFORMATION |
Const.UNPROTECTED_DACL_SECURITY_INFORMATION,
null /* sidOwner*/, null /* sidGroup*/,
dacl, null /* sacl*/);
null /*sidOwner*/, null /*sidGroup*/,
dacl, null /*sacl*/);
}
// sd will be set only if the function succeeds.
if (!sd.isNull()) {
@ -655,7 +655,7 @@
/**
* Gets the number of bytes available on disk to the current user.
*
* @param {string} sourcePath Platform-specific path to a directory on
* @param {string} sourcePath Platform-specific path to a directory on
* the disk to query for free available bytes.
*
* @return {number} The number of bytes available for the current user.
@ -693,7 +693,7 @@
// JS counts from local time, so we need to go through UTC.
let utc = Date.UTC(gSystemTime.wYear,
gSystemTime.wMonth - 1
/* Windows counts months from 1, JS from 0*/,
/*Windows counts months from 1, JS from 0*/,
gSystemTime.wDay, gSystemTime.wHour,
gSystemTime.wMinute, gSystemTime.wSecond,
gSystemTime.wMilliSeconds);
@ -810,15 +810,15 @@
if (WinFile.FindNextFile(this._handle, this._findDataPtr)) {
return this._findData;
}
} else {
let error = ctypes.winLastError;
this.close();
if (error == Const.ERROR_NO_MORE_FILES) {
return null;
}
} else {
throw new File.Error("iter (FindNextFile)", error, this._path);
}
}
},
/**

Просмотреть файл

@ -114,7 +114,7 @@ var normalize = function(path) {
}
path.split("/").forEach(function(v) {
switch (v) {
case "": case ".":// fallthrough
case "": case ".":// fallthrough
break;
case "..":
if (stack.length == 0) {
@ -123,11 +123,13 @@ var normalize = function(path) {
} else {
stack.push("..");
}
} else if (stack[stack.length - 1] == "..") {
} else {
if (stack[stack.length - 1] == "..") {
stack.push("..");
} else {
stack.pop();
}
}
break;
default:
stack.push(v);
@ -161,10 +163,10 @@ exports.split = split;
* Returns the file:// URI file path of the given local file path.
*/
// The case of %3b is designed to match Services.io, but fundamentally doesn't matter.
var toFileURIExtraEncodings = {";": "%3b", "?": "%3F", "#": "%23"};
var toFileURIExtraEncodings = {';': '%3b', '?': '%3F', '#': '%23'};
var toFileURI = function toFileURI(path) {
// Per https://url.spec.whatwg.org we should not encode [] in the path
let dontNeedEscaping = {"%5B": "[", "%5D": "]"};
let dontNeedEscaping = {'%5B': '[', '%5D': ']'};
let uri = encodeURI(this.normalize(path)).replace(/%(5B|5D)/gi,
match => dontNeedEscaping[match]);
@ -182,7 +184,7 @@ exports.toFileURI = toFileURI;
*/
var fromFileURI = function fromFileURI(uri) {
let url = new URL(uri);
if (url.protocol != "file:") {
if (url.protocol != 'file:') {
throw new Error("fromFileURI expects a file URI");
}
let path = this.normalize(decodeURIComponent(url.pathname));
@ -191,7 +193,7 @@ var fromFileURI = function fromFileURI(uri) {
exports.fromFileURI = fromFileURI;
// ////////// Boilerplate
//////////// Boilerplate
if (typeof Components != "undefined") {
this.EXPORTED_SYMBOLS = EXPORTED_SYMBOLS;
for (let symbol of EXPORTED_SYMBOLS) {

Просмотреть файл

@ -94,18 +94,19 @@ var dirname = function(path, options) {
if (!noDrive) {
// Return the drive path if possible, falling back to "."
return this.winGetDrive(path) || ".";
} else {
// Or just "."
return ".";
}
// Or just "."
return ".";
}
if (index == 1 && path.charAt(0) == "\\") {
// The path is reduced to a UNC drive
if (noDrive) {
return ".";
} else {
return path;
}
return path;
}
// Ignore any occurrence of "\\: immediately before that one
@ -246,7 +247,7 @@ var normalize = function(path) {
// popping whenever there is a ".."
path.split("\\").forEach(function loop(v) {
switch (v) {
case "": case ".": // Ignore
case "": case ".": // Ignore
break;
case "..":
if (stack.length == 0) {
@ -255,11 +256,13 @@ var normalize = function(path) {
} else {
stack.push("..");
}
} else if (stack[stack.length - 1] == "..") {
} else {
if (stack[stack.length - 1] == "..") {
stack.push("..");
} else {
stack.pop();
}
}
break;
default:
stack.push(v);
@ -303,12 +306,12 @@ exports.split = split;
* Return the file:// URI file path of the given local file path.
*/
// The case of %3b is designed to match Services.io, but fundamentally doesn't matter.
var toFileURIExtraEncodings = {";": "%3b", "?": "%3F", "#": "%23"};
var toFileURIExtraEncodings = {';': '%3b', '?': '%3F', '#': '%23'};
var toFileURI = function toFileURI(path) {
// URI-escape forward slashes and convert backward slashes to forward
path = this.normalize(path).replace(/[\\\/]/g, m => (m == "\\") ? "/" : "%2F");
path = this.normalize(path).replace(/[\\\/]/g, m => (m=='\\')? '/' : '%2F');
// Per https://url.spec.whatwg.org we should not encode [] in the path
let dontNeedEscaping = {"%5B": "[", "%5D": "]"};
let dontNeedEscaping = {'%5B': '[', '%5D': ']'};
let uri = encodeURI(path).replace(/%(5B|5D)/gi,
match => dontNeedEscaping[match]);
@ -318,7 +321,7 @@ var toFileURI = function toFileURI(path) {
uri = prefix + uri.replace(/[;?#]/g, match => toFileURIExtraEncodings[match]);
// turn e.g., file:///C: into file:///C:/
if (uri.charAt(uri.length - 1) === ":") {
if (uri.charAt(uri.length - 1) === ':') {
uri += "/"
}
@ -331,7 +334,7 @@ exports.toFileURI = toFileURI;
*/
var fromFileURI = function fromFileURI(uri) {
let url = new URL(uri);
if (url.protocol != "file:") {
if (url.protocol != 'file:') {
throw new Error("fromFileURI expects a file URI");
}
@ -358,10 +361,10 @@ exports.fromFileURI = fromFileURI;
* from a string.
*/
var trimBackslashes = function trimBackslashes(string) {
return string.replace(/^\\+|\\+$/g, "");
return string.replace(/^\\+|\\+$/g,'');
};
// ////////// Boilerplate
//////////// Boilerplate
if (typeof Components != "undefined") {
this.EXPORTED_SYMBOLS = EXPORTED_SYMBOLS;
for (let symbol of EXPORTED_SYMBOLS) {

Просмотреть файл

@ -123,7 +123,7 @@ var reference_dir_contents = function reference_dir_contents(path) {
};
// Set/Unset OS.Shared.DEBUG, OS.Shared.TEST and a console listener.
function toggleDebugTest(pref, consoleListener) {
function toggleDebugTest (pref, consoleListener) {
Services.prefs.setBoolPref("toolkit.osfile.log", pref);
Services.prefs.setBoolPref("toolkit.osfile.log.redirect", pref);
Services.console[pref ? "registerListener" : "unregisterListener"](
@ -276,7 +276,7 @@ var test_iter = maketest("iter", function iter(test) {
test.info("Double closing DirectoryIterator");
iterator = new OS.File.DirectoryIterator(currentDir);
await iterator.close();
await iterator.close(); // double closing |DirectoryIterator|
await iterator.close(); //double closing |DirectoryIterator|
test.ok(true, "|DirectoryIterator| was closed twice successfully");
let allFiles2 = [];
@ -309,7 +309,7 @@ var test_iter = maketest("iter", function iter(test) {
await iterator.forEach(function cb(entry, index, iterator) {
if (index < BATCH_LENGTH) {
test.is(entry.path, someFiles1[index].path, "Both runs return the same files (part 1)");
} else if (index < 2 * BATCH_LENGTH) {
} else if (index < 2*BATCH_LENGTH) {
test.is(entry.path, someFiles2[index - BATCH_LENGTH].path, "Both runs return the same files (part 2)");
} else if (index == 2 * BATCH_LENGTH) {
test.info("Attempting to stop asynchronous forEach");
@ -380,7 +380,7 @@ var test_exists = maketest("exists", function exists(test) {
*/
var test_debug = maketest("debug", function debug(test) {
return (async function() {
function testSetDebugPref(pref) {
function testSetDebugPref (pref) {
try {
Services.prefs.setBoolPref("toolkit.osfile.log", pref);
} catch (x) {
@ -407,7 +407,7 @@ var test_debug_test = maketest("debug_test", function debug_test(test) {
return (async function() {
// Create a console listener.
let consoleListener = {
observe: function(aMessage) {
observe: function (aMessage) {
// Ignore unexpected messages.
if (!(aMessage instanceof Components.interfaces.nsIConsoleMessage)) {
return;

Просмотреть файл

@ -11,11 +11,11 @@ function worker_handler(worker) {
switch (msg.data.kind) {
case "is":
SimpleTest.ok(msg.data.outcome, msg.data.description +
"( " + msg.data.a + " ==? " + msg.data.b + ")" );
"( "+ msg.data.a + " ==? " + msg.data.b + ")" );
return;
case "isnot":
SimpleTest.ok(msg.data.outcome, msg.data.description +
"( " + msg.data.a + " !=? " + msg.data.b + ")" );
"( "+ msg.data.a + " !=? " + msg.data.b + ")" );
return;
case "ok":
SimpleTest.ok(msg.data.condition, msg.data.description);
@ -28,7 +28,7 @@ function worker_handler(worker) {
return;
default:
SimpleTest.ok(false, "test_osfile.xul: wrong message " + JSON.stringify(msg.data));
return;
}
};
}

Просмотреть файл

@ -3,7 +3,7 @@
"use strict";
importScripts("worker_test_osfile_shared.js");
importScripts('worker_test_osfile_shared.js');
// The set of samples for communications test. Declare as a global
// variable to prevent this from being garbage-collected too early.
@ -130,7 +130,7 @@ self.onmessage = function(msg) {
// 4. Test sending serialized
info("Attempting to send message");
try {
self.postMessage({kind: "value",
self.postMessage({kind:"value",
typename: sample.typename,
value: serialized,
check: check.toSource()});

Просмотреть файл

@ -1,7 +1,7 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
importScripts("worker_test_osfile_shared.js");
importScripts('worker_test_osfile_shared.js');
importScripts("resource://gre/modules/workers/require.js");
var SharedAll = require("resource://gre/modules/osfile/osfile_shared_allthreads.jsm");
@ -50,7 +50,8 @@ function test_init() {
/**
* Test that we can open an existing file.
*/
function test_open_existing_file() {
function test_open_existing_file()
{
info("Starting test_open_existing");
let file = OS.File.open("chrome/toolkit/components/osfile/tests/mochi/worker_test_osfile_unix.js");
file.close();
@ -59,7 +60,8 @@ function test_open_existing_file() {
/**
* Test that opening a file that does not exist fails with the right error.
*/
function test_open_non_existing_file() {
function test_open_non_existing_file()
{
info("Starting test_open_non_existing");
let exn;
try {
@ -77,7 +79,8 @@ function test_open_non_existing_file() {
* Test that to ensure that |foo.flush()| does not
* cause an error, where |foo| is an open file.
*/
function test_flush_open_file() {
function test_flush_open_file()
{
info("Starting test_flush_open_file");
let tmp = "test_flush.tmp";
let file = OS.File.open(tmp, {create: true, write: true});
@ -98,7 +101,8 @@ function test_flush_open_file() {
* @param {number=} prefix If specified, only compare the |prefix|
* first bytes of |sourcePath| and |destPath|.
*/
function compare_files(test, sourcePath, destPath, prefix) {
function compare_files(test, sourcePath, destPath, prefix)
{
info(test + ": Comparing " + sourcePath + " and " + destPath);
let source = OS.File.open(sourcePath);
let dest = OS.File.open(destPath);
@ -129,7 +133,8 @@ function compare_files(test, sourcePath, destPath, prefix) {
/**
* Test that copying a file using |copy| works.
*/
function test_copy_existing_file() {
function test_copy_existing_file()
{
let src_file_name =
OS.Path.join("chrome", "toolkit", "components", "osfile", "tests", "mochi",
"worker_test_osfile_front.js");
@ -155,7 +160,7 @@ function test_copy_existing_file() {
let exn;
try {
OS.File.copy(src_file_name, tmp_file_name, {noOverwrite: true});
} catch (x) {
} catch(x) {
exn = x;
}
ok(!!exn, "test_copy_existing: noOverwrite prevents overwriting existing files");
@ -167,7 +172,8 @@ function test_copy_existing_file() {
/**
* Test that moving a file works.
*/
function test_move_file() {
function test_move_file()
{
info("test_move_file: Starting");
// 1. Copy file into a temporary file
let src_file_name =
@ -200,12 +206,13 @@ function test_move_file() {
OS.File.remove(tmp2_file_name);
}
function test_iter_dir() {
function test_iter_dir()
{
info("test_iter_dir: Starting");
// Create a file, to be sure that it exists
let tmp_file_name = "test_osfile_front.tmp";
let tmp_file = OS.File.open(tmp_file_name, {write: true, trunc: true});
let tmp_file = OS.File.open(tmp_file_name, {write: true, trunc:true});
tmp_file.close();
let parent = OS.File.getCurrentDirectory();
@ -320,7 +327,7 @@ function test_iter_dir() {
});
iterator.close();
// test for prototype |OS.File.DirectoryIterator.unixAsFile|
//test for prototype |OS.File.DirectoryIterator.unixAsFile|
if ("unixAsFile" in OS.File.DirectoryIterator.prototype) {
info("testing property unixAsFile");
let path = OS.Path.join("chrome", "toolkit", "components", "osfile", "tests", "mochi");
@ -420,7 +427,7 @@ function test_info() {
let SLOPPY_FILE_SYSTEM_ADJUSTMENT = 3000;
let startMs = start.getTime() - SLOPPY_FILE_SYSTEM_ADJUSTMENT;
let stopMs = stop.getTime() + SLOPPY_FILE_SYSTEM_ADJUSTMENT;
info("Testing stat with bounds [ " + startMs + ", " + stopMs + " ]");
info("Testing stat with bounds [ " + startMs + ", " + stopMs +" ]");
(function() {
let birth;
@ -467,7 +474,7 @@ function test_info() {
// Round up/down as above
startMs = start.getTime() - SLOPPY_FILE_SYSTEM_ADJUSTMENT;
stopMs = stop.getTime() + SLOPPY_FILE_SYSTEM_ADJUSTMENT;
info("Testing stat 2 with bounds [ " + startMs + ", " + stopMs + " ]");
info("Testing stat 2 with bounds [ " + startMs + ", " + stopMs +" ]");
let access = stat.lastAccessDate;
info("Testing lastAccessDate: " + access);
@ -489,7 +496,8 @@ function test_info() {
// Note that most of the features of path are tested in
// worker_test_osfile_{unix, win}.js
function test_path() {
function test_path()
{
info("test_path: starting");
let abcd = OS.Path.join("a", "b", "c", "d");
is(OS.Path.basename(abcd), "d", "basename of a/b/c/d");
@ -509,14 +517,15 @@ function test_path() {
/**
* Test the file |exists| method.
*/
function test_exists_file() {
let file_name = OS.Path.join("chrome", "toolkit", "components", "osfile",
function test_exists_file()
{
let file_name = OS.Path.join("chrome", "toolkit", "components" ,"osfile",
"tests", "mochi", "test_osfile_front.xul");
info("test_exists_file: starting");
ok(OS.File.exists(file_name), "test_exists_file: file exists (OS.File.exists)");
ok(!OS.File.exists(file_name + ".tmp"), "test_exists_file: file does not exists (OS.File.exists)");
let dir_name = OS.Path.join("chrome", "toolkit", "components", "osfile",
let dir_name = OS.Path.join("chrome", "toolkit", "components" ,"osfile",
"tests", "mochi");
ok(OS.File.exists(dir_name), "test_exists_file: directory exists");
ok(!OS.File.exists(dir_name) + ".tmp", "test_exists_file: directory does not exist");
@ -527,7 +536,8 @@ function test_exists_file() {
/**
* Test the file |remove| method.
*/
function test_remove_file() {
function test_remove_file()
{
let absent_file_name = "test_osfile_front_absent.tmp";
// Check that removing absent files is handled correctly

Просмотреть файл

@ -1,12 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
importScripts("worker_test_osfile_shared.js");
importScripts('worker_test_osfile_shared.js');
self.onmessage = function(msg) {
log("received message " + JSON.stringify(msg.data));
log("received message "+JSON.stringify(msg.data));
self.onmessage = function(msg) {
log("ignored message " + JSON.stringify(msg.data));
log("ignored message "+JSON.stringify(msg.data));
};
test_init();
test_getcwd();
@ -28,7 +28,7 @@ function test_open_close() {
is(typeof OS.Unix.File.open, "function", "OS.Unix.File.open is a function");
let file = OS.Unix.File.open("chrome/toolkit/components/osfile/tests/mochi/worker_test_osfile_unix.js", OS.Constants.libc.O_RDONLY, 0);
isnot(file, -1, "test_open_close: opening succeeded");
info("Close: " + OS.Unix.File.close.toSource());
info("Close: "+OS.Unix.File.close.toSource());
let result = OS.Unix.File.close(file);
is(result, 0, "test_open_close: close succeeded");
@ -37,7 +37,8 @@ function test_open_close() {
is(ctypes.errno, OS.Constants.libc.ENOENT, "test_open_close: error is ENOENT");
}
function test_create_file() {
function test_create_file()
{
info("Starting test_create_file");
let file = OS.Unix.File.open("test.tmp", OS.Constants.libc.O_RDWR
| OS.Constants.libc.O_CREAT
@ -47,7 +48,8 @@ function test_create_file() {
OS.Unix.File.close(file);
}
function test_access() {
function test_access()
{
info("Starting test_access");
let file = OS.Unix.File.open("test1.tmp", OS.Constants.libc.O_RDWR
| OS.Constants.libc.O_CREAT
@ -72,7 +74,8 @@ function test_access() {
OS.Unix.File.close(file);
}
function test_getcwd() {
function test_getcwd()
{
let array = new (ctypes.ArrayType(ctypes.char, 32768))();
let path = OS.Unix.File.getcwd(array, array.length);
if (ctypes.char.ptr(path).isNull()) {
@ -90,7 +93,8 @@ function test_getcwd() {
is(path.readString(), path2.readString(), "test_get_cwd: getcwd and getwd return the same path");
}
function test_read_write() {
function test_read_write()
{
let output_name = "osfile_copy.tmp";
// Copy file
let input = OS.Unix.File.open(
@ -145,7 +149,7 @@ function test_read_write() {
isnot(bytes, -1, "test_read_write: input read succeeded");
bytes2 = OS.Unix.File.read(output, array2, 4096);
isnot(bytes, -1, "test_read_write: output read succeeded");
is(bytes > 0, bytes2 > 0, "Both files contain data or neither does " + bytes + ", " + bytes2);
is(bytes > 0, bytes2 > 0, "Both files contain data or neither does "+bytes+", "+bytes2);
if (bytes == 0) {
break;
}
@ -164,7 +168,7 @@ function test_read_write() {
for (let i = 0; i < bytes; ++i) {
if (array[i] != array2[i]) {
ok(false, "Files do not match at position " + i
+ " (" + array[i] + "/" + array2[i] + ")");
+ " ("+array[i] + "/"+array2[i] + ")");
}
}
}
@ -178,7 +182,8 @@ function test_read_write() {
info("test_read_write cleanup complete");
}
function test_passing_undefined() {
function test_passing_undefined()
{
info("Testing that an exception gets thrown when an FFI function is passed undefined");
let exceptionRaised = false;
@ -187,7 +192,7 @@ function test_passing_undefined() {
| OS.Constants.libc.O_CREAT
| OS.Constants.libc.O_TRUNC,
OS.Constants.libc.S_IRWXU);
} catch (e) {
} catch(e) {
if (e instanceof TypeError && e.message.indexOf("open") > -1) {
exceptionRaised = true;
} else {

Просмотреть файл

@ -1,11 +1,11 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
importScripts("worker_test_osfile_shared.js");
importScripts('worker_test_osfile_shared.js');
self.onmessage = function(msg) {
self.onmessage = function(msg) {
log("ignored message " + JSON.stringify(msg.data));
log("ignored message "+JSON.stringify(msg.data));
};
test_init();
@ -55,7 +55,8 @@ function test_OpenClose() {
is(ctypes.winLastError, OS.Constants.Win.ERROR_FILE_NOT_FOUND, "test_OpenClose: error is ERROR_FILE_NOT_FOUND");
}
function test_CreateFile() {
function test_CreateFile()
{
info("Starting test_CreateFile");
let file = OS.Win.File.CreateFile(
"test.tmp",
@ -70,14 +71,16 @@ function test_CreateFile() {
isnot(result, 0, "test_CreateFile: close succeeded");
}
function test_GetCurrentDirectory() {
function test_GetCurrentDirectory()
{
let array = new (ctypes.ArrayType(ctypes.char16_t, 4096))();
let result = OS.Win.File.GetCurrentDirectory(4096, array);
ok(result < array.length, "test_GetCurrentDirectory: length sufficient");
ok(result > 0, "test_GetCurrentDirectory: length != 0");
}
function test_ReadWrite() {
function test_ReadWrite()
{
info("Starting test_ReadWrite");
let output_name = "osfile_copy.tmp";
// Copy file
@ -102,16 +105,16 @@ function test_ReadWrite() {
let array = new (ctypes.ArrayType(ctypes.char, 4096))();
let bytes_read = new ctypes.uint32_t(0);
let bytes_read_ptr = bytes_read.address();
log("We have a pointer for bytes read: " + bytes_read_ptr);
log("We have a pointer for bytes read: "+bytes_read_ptr);
let bytes_written = new ctypes.uint32_t(0);
let bytes_written_ptr = bytes_written.address();
log("We have a pointer for bytes written: " + bytes_written_ptr);
log("We have a pointer for bytes written: "+bytes_written_ptr);
log("test_ReadWrite: buffer and pointers ready");
let result;
while (true) {
log("test_ReadWrite: reading");
result = OS.Win.File.ReadFile(input, array, 4096, bytes_read_ptr, null);
isnot(result, 0, "test_ReadWrite: read success");
isnot (result, 0, "test_ReadWrite: read success");
let write_from = 0;
let bytes_left = bytes_read;
log("test_ReadWrite: read chunk complete " + bytes_left.value);
@ -119,11 +122,11 @@ function test_ReadWrite() {
break;
}
while (bytes_left.value > 0) {
log("test_ReadWrite: writing " + bytes_left.value);
log("test_ReadWrite: writing "+bytes_left.value);
let ptr = array.addressOfElement(write_from);
// Note: |WriteFile| launches an exception in case of error
result = OS.Win.File.WriteFile(output, array, bytes_left, bytes_written_ptr, null);
isnot(result, 0, "test_ReadWrite: write success");
isnot (result, 0, "test_ReadWrite: write success");
write_from += bytes_written;
bytes_left -= bytes_written;
}
@ -132,10 +135,10 @@ function test_ReadWrite() {
// Compare files
result = OS.Win.File.SetFilePointer(input, 0, null, OS.Constants.Win.FILE_BEGIN);
isnot(result, OS.Constants.Win.INVALID_SET_FILE_POINTER, "test_ReadWrite: input reset");
isnot (result, OS.Constants.Win.INVALID_SET_FILE_POINTER, "test_ReadWrite: input reset");
result = OS.Win.File.SetFilePointer(output, 0, null, OS.Constants.Win.FILE_BEGIN);
isnot(result, OS.Constants.Win.INVALID_SET_FILE_POINTER, "test_ReadWrite: output reset");
isnot (result, OS.Constants.Win.INVALID_SET_FILE_POINTER, "test_ReadWrite: output reset");
let array2 = new (ctypes.ArrayType(ctypes.char, 4096))();
let bytes_read2 = new ctypes.uint32_t(0);
@ -159,7 +162,7 @@ function test_ReadWrite() {
// remote file system, I believe.
bytes = Math.min(bytes_read.value, bytes_read2.value);
pos += bytes;
result = OS.Win.File.SetFilePointer(input, pos, null, OS.Constants.Win.FILE_BEGIN);
result = OS.Win.File.SetFilePointer(input, pos, null, OS.Constants.Win.FILE_BEGIN);
isnot(result, 0, "test_ReadWrite: input seek succeeded");
result = OS.Win.File.SetFilePointer(output, pos, null, OS.Constants.Win.FILE_BEGIN);
@ -172,7 +175,7 @@ function test_ReadWrite() {
for (let i = 0; i < bytes; ++i) {
if (array[i] != array2[i]) {
ok(false, "Files do not match at position " + i
+ " (" + array[i] + "/" + array2[i] + ")");
+ " ("+array[i] + "/"+array2[i] + ")");
}
}
}
@ -186,7 +189,8 @@ function test_ReadWrite() {
info("test_ReadWrite cleanup complete");
}
function test_passing_undefined() {
function test_passing_undefined()
{
info("Testing that an exception gets thrown when an FFI function is passed undefined");
let exceptionRaised = false;
@ -199,7 +203,7 @@ function test_passing_undefined() {
OS.Constants.Win.OPEN_EXISTING,
0,
null);
} catch (e) {
} catch(e) {
if (e instanceof TypeError && e.message.indexOf("CreateFile") > -1) {
exceptionRaised = true;
} else {

Просмотреть файл

@ -75,7 +75,7 @@ function reference_fetch_file(path, test) {
});
});
}
};
/**
* Compare asynchronously the contents two files using xpcom.
@ -94,7 +94,7 @@ function reference_compare_files(a, b, test) {
let b_contents = await reference_fetch_file(b, test);
do_check_eq(a_contents, b_contents);
})();
}
};
async function removeTestFile(filePath, ignoreNoSuchFile = true) {
try {

Просмотреть файл

@ -52,7 +52,7 @@ add_task(async function test_uncompressed() {
add_task(async function test_no_header() {
let path = OS.Path.join(OS.Constants.Path.tmpDir, "no_header.tmp");
let array = new Uint8Array(8).fill(0, 0); // Small array with no header
let array = new Uint8Array(8).fill(0,0); // Small array with no header
do_print("Writing data with no header");
@ -72,7 +72,7 @@ add_task(async function test_no_header() {
add_task(async function test_invalid_content() {
let path = OS.Path.join(OS.Constants.Path.tmpDir, "invalid_content.tmp");
let arr1 = new Uint8Array([109, 111, 122, 76, 122, 52, 48, 0]);
let arr2 = new Uint8Array(248).fill(1, 0);
let arr2 = new Uint8Array(248).fill(1,0);
let array = new Uint8Array(arr1.length + arr2.length);
array.set(arr1);

Просмотреть файл

@ -10,11 +10,11 @@ function run_test() {
// Test that OS.Constants is defined correctly.
add_task(async function check_definition() {
do_check_true(OS.Constants != null);
do_check_true(OS.Constants!=null);
do_check_true(!!OS.Constants.Win || !!OS.Constants.libc);
do_check_true(OS.Constants.Path != null);
do_check_true(OS.Constants.Sys != null);
// check system name
do_check_true(OS.Constants.Path!=null);
do_check_true(OS.Constants.Sys!=null);
//check system name
if (OS.Constants.Sys.Name == "Gonk") {
// Services.appinfo.OS doesn't know the difference between Gonk and Android
do_check_eq(Services.appinfo.OS, "Android");
@ -22,10 +22,10 @@ add_task(async function check_definition() {
do_check_eq(Services.appinfo.OS, OS.Constants.Sys.Name);
}
// check if using DEBUG build
//check if using DEBUG build
if (Components.classes["@mozilla.org/xpcom/debug;1"].getService(Components.interfaces.nsIDebug2).isDebugBuild == true) {
do_check_true(OS.Constants.Sys.DEBUG);
} else {
do_check_true(typeof(OS.Constants.Sys.DEBUG) == "undefined");
do_check_true(typeof(OS.Constants.Sys.DEBUG) == 'undefined');
}
});

Просмотреть файл

@ -9,14 +9,14 @@ function run_test() {
* Test to ensure that deprecation warning is issued on use
* of creationDate.
*/
add_task(async function test_deprecatedCreationDate() {
add_task(async function test_deprecatedCreationDate () {
let currentDir = await OS.File.getCurrentDirectory();
let path = OS.Path.join(currentDir, "test_creationDate.js");
let consoleMessagePromise = new Promise(resolve => {
let consoleListener = {
observe: function(aMessage) {
if (aMessage.message.indexOf("Field 'creationDate' is deprecated.") > -1) {
observe: function (aMessage) {
if(aMessage.message.indexOf("Field 'creationDate' is deprecated.") > -1) {
do_print("Deprecation message printed");
do_check_true(true);
Services.console.unregisterListener(consoleListener);

Просмотреть файл

@ -11,76 +11,76 @@ function run_test() {
// Test cases for filePathToURI
let paths = isWindows ? [
"C:\\",
"C:\\test",
"C:\\test\\",
"C:\\test%2f",
"C:\\test\\test\\test",
"C:\\test;+%",
"C:\\test?action=index\\",
"C:\\test\ test",
"\\\\C:\\a\\b\\c",
"\\\\Server\\a\\b\\c",
'C:\\',
'C:\\test',
'C:\\test\\',
'C:\\test%2f',
'C:\\test\\test\\test',
'C:\\test;+%',
'C:\\test?action=index\\',
'C:\\test\ test',
'\\\\C:\\a\\b\\c',
'\\\\Server\\a\\b\\c',
// note that per http://support.microsoft.com/kb/177506 (under more info),
// the following characters are allowed on Windows:
"C:\\char^",
"C:\\char&",
"C:\\char'",
"C:\\char@",
"C:\\char{",
"C:\\char}",
"C:\\char[",
"C:\\char]",
"C:\\char,",
"C:\\char$",
"C:\\char=",
"C:\\char!",
"C:\\char-",
"C:\\char#",
"C:\\char(",
"C:\\char)",
"C:\\char%",
"C:\\char.",
"C:\\char+",
"C:\\char~",
"C:\\char_"
'C:\\char^',
'C:\\char&',
'C:\\char\'',
'C:\\char@',
'C:\\char{',
'C:\\char}',
'C:\\char[',
'C:\\char]',
'C:\\char,',
'C:\\char$',
'C:\\char=',
'C:\\char!',
'C:\\char-',
'C:\\char#',
'C:\\char(',
'C:\\char)',
'C:\\char%',
'C:\\char.',
'C:\\char+',
'C:\\char~',
'C:\\char_'
] : [
"/",
"/test",
"/test/",
"/test%2f",
"/test/test/test",
"/test;+%",
"/test?action=index/",
"/test\ test",
'/',
'/test',
'/test/',
'/test%2f',
'/test/test/test',
'/test;+%',
'/test?action=index/',
'/test\ test',
'/punctuation/;,/?:@&=+$-_.!~*\'()[]"#',
"/CasePreserving"
'/CasePreserving'
];
// some additional URIs to test, beyond those generated from paths
let uris = isWindows ? [
"file:///C:/test/",
"file://localhost/C:/test",
"file:///c:/test/test.txt",
// 'file:///C:/foo%2f', // trailing, encoded slash
"file:///C:/%3f%3F",
"file:///C:/%3b%3B",
"file:///C:/%3c%3C", // not one of the special-cased ? or ;
"file:///C:/%78", // 'x', not usually uri encoded
"file:///C:/test#frag", // a fragment identifier
"file:///C:/test?action=index" // an actual query component
'file:///C:/test/',
'file://localhost/C:/test',
'file:///c:/test/test.txt',
//'file:///C:/foo%2f', // trailing, encoded slash
'file:///C:/%3f%3F',
'file:///C:/%3b%3B',
'file:///C:/%3c%3C', // not one of the special-cased ? or ;
'file:///C:/%78', // 'x', not usually uri encoded
'file:///C:/test#frag', // a fragment identifier
'file:///C:/test?action=index' // an actual query component
] : [
"file:///test/",
"file://localhost/test",
"file:///test/test.txt",
"file:///foo%2f", // trailing, encoded slash
"file:///%3f%3F",
"file:///%3b%3B",
"file:///%3c%3C", // not one of the special-cased ? or ;
"file:///%78", // 'x', not usually uri encoded
"file:///test#frag", // a fragment identifier
"file:///test?action=index" // an actual query component
'file:///test/',
'file://localhost/test',
'file:///test/test.txt',
'file:///foo%2f', // trailing, encoded slash
'file:///%3f%3F',
'file:///%3b%3B',
'file:///%3c%3C', // not one of the special-cased ? or ;
'file:///%78', // 'x', not usually uri encoded
'file:///test#frag', // a fragment identifier
'file:///test?action=index' // an actual query component
];
for (let path of paths) {
@ -105,7 +105,7 @@ function run_test() {
// check that non-file URLs aren't allowed
let thrown = false;
try {
OS.Path.fromFileURI("http://test.com")
OS.Path.fromFileURI('http://test.com')
} catch (e) {
do_check_eq(e.message, "fromFileURI expects a file URI");
thrown = true;

Просмотреть файл

@ -7,7 +7,7 @@
* Test that OS.File can be loaded using the CommonJS loader.
*/
var { Loader } = Components.utils.import("resource://gre/modules/commonjs/toolkit/loader.js", {});
var { Loader } = Components.utils.import('resource://gre/modules/commonjs/toolkit/loader.js', {});
function run_test() {
run_next_test();
@ -17,17 +17,17 @@ function run_test() {
add_task(async function() {
let dataDir = Services.io.newFileURI(do_get_file("test_loader/", true)).spec + "/";
let loader = Loader.Loader({
paths: {"": dataDir }
paths: {'': dataDir }
});
let require = Loader.Require(loader, Loader.Module("module_test_loader", "foo"));
let require = Loader.Require(loader, Loader.Module('module_test_loader', 'foo'));
do_print("Require is ready");
try {
require("module_test_loader");
require('module_test_loader');
} catch (error) {
dump("Bootstrap error: " +
(error.message ? error.message : String(error)) + "\n" +
(error.stack || error.fileName + ": " + error.lineNumber) + "\n");
dump('Bootstrap error: ' +
(error.message ? error.message : String(error)) + '\n' +
(error.stack || error.fileName + ': ' + error.lineNumber) + '\n');
throw error;
}

Просмотреть файл

@ -6,4 +6,4 @@
// Load OS.File from a module loaded with the CommonJS/addon-sdk loader
var {Cu} = require("chrome");
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import('resource://gre/modules/osfile.jsm');

Просмотреть файл

@ -15,8 +15,8 @@ function run_test() {
// Create a console listener.
let consoleListener = {
observe: function(aMessage) {
// Ignore unexpected messages.
observe: function (aMessage) {
//Ignore unexpected messages.
if (!(aMessage instanceof Components.interfaces.nsIConsoleMessage)) {
return;
}
@ -29,10 +29,10 @@ function run_test() {
}
++messageCount;
if (messageCount == 1) {
if(messageCount == 1) {
do_check_eq(aMessage.message, "TEST OS {\"name\":\"test\"}\n");
}
if (messageCount == 2) {
if(messageCount == 2) {
do_check_eq(aMessage.message, "TEST OS name is test\n");
toggleConsoleListener(false);
do_test_finished();
@ -42,7 +42,7 @@ function run_test() {
};
// Set/Unset the console listener.
function toggleConsoleListener(pref) {
function toggleConsoleListener (pref) {
do_print("Setting console listener: " + pref);
Services.prefs.setBoolPref("toolkit.osfile.log", pref);
Services.prefs.setBoolPref("toolkit.osfile.log.redirect", pref);

Просмотреть файл

@ -43,7 +43,7 @@ add_task(async function test_basic() {
// Make a directory
await OS.File.makeDir(dir);
// check if the directory exists
//check if the directory exists
await OS.File.stat(dir);
// Make a directory that already exists, this should succeed
@ -87,7 +87,7 @@ add_task(async function test_option_from() {
// Make a directory
await OS.File.makeDir(dir, {from: profileDir});
// check if the directory exists
//check if the directory exists
await OS.File.stat(dir);
// Make a directory that already exists, this should succeed

Просмотреть файл

@ -58,7 +58,7 @@ add_task(async function() {
* Test the error thrown by OS.File.open when attempting to open a directory
* that does not exist.
*/
add_task(async function test_error_attributes() {
add_task(async function test_error_attributes () {
let dir = OS.Path.join(do_get_profile().path, "test_osfileErrorAttrs");
let fpath = OS.Path.join(dir, "test_error_attributes.txt");

Просмотреть файл

@ -20,7 +20,7 @@ async function test_setPosition(forward, current, backward) {
await removeTestFile(path);
try {
let file = await OS.File.open(path, {write: true, append: false});
let file = await OS.File.open(path, {write:true, append:false});
try {
let pos = 0;
@ -46,7 +46,7 @@ async function test_setPosition(forward, current, backward) {
await file.setPosition(0, OS.File.POS_START);
await file.close();
}
} catch (ex) {
} catch(ex) {
await removeTestFile(path);
}
}
@ -60,7 +60,7 @@ async function test_setPosition_failures() {
await removeTestFile(path);
try {
let file = await OS.File.open(path, {write: true, append: false});
let file = await OS.File.open(path, {write:true, append:false});
try {
let pos = 0;
@ -103,7 +103,7 @@ async function test_setPosition_failures() {
await file.close();
await removeTestFile(path);
}
} catch (ex) {
} catch(ex) {
do_throw(ex);
}
}

Просмотреть файл

@ -21,9 +21,9 @@
function format_mode(mode) {
if (mode <= 0o777) {
return ("0000" + mode.toString(8)).slice(-4);
}
} else {
return "0" + mode.toString(8);
}
}
const _umask = OS.Constants.Sys.umask;

Просмотреть файл

@ -59,10 +59,10 @@ add_task(async function test_kill_race() {
// We have chosen OS.File.exists for our tests because it does not trigger
// a rejection and we absolutely do not care what the operation is other
// than it does not invoke a native fast-path.
await OS.File.exists("foo.foo");
await OS.File.exists('foo.foo');
do_print("issuing first request");
let firstRequest = OS.File.exists("foo.bar");
do_print('issuing first request');
let firstRequest = OS.File.exists('foo.bar');
let secondRequest;
let secondResolved = false;
@ -72,14 +72,14 @@ add_task(async function test_kill_race() {
// before we issue the kill request means we will get run before the `kill`
// task resumes and allow us to precisely create the desired race.
Scheduler.queue.then(function() {
do_print("issuing second request");
secondRequest = OS.File.exists("foo.baz");
do_print('issuing second request');
secondRequest = OS.File.exists('foo.baz');
secondRequest.then(function() {
secondResolved = true;
});
});
do_print("issuing kill request");
do_print('issuing kill request');
let killRequest = Scheduler.kill({ reset: true, shutdown: false });
// Wait on the killRequest so that we can schedule a new OS.File request
@ -89,10 +89,10 @@ add_task(async function test_kill_race() {
// worker (and this usage here should not be vulnerable even with the
// bug present), so when this completes the secondRequest has either been
// resolved or lost.
await OS.File.exists("foo.goz");
await OS.File.exists('foo.goz');
ok(secondResolved,
"The second request was resolved so we avoided the bug. Victory!");
'The second request was resolved so we avoided the bug. Victory!');
});
function run_test() {

Просмотреть файл

@ -24,4 +24,4 @@ add_test_pair(async function test_osfile_writeAtomic_zerobytes() {
function run_test() {
run_next_test();
}
}

Просмотреть файл

@ -16,7 +16,8 @@ Components.utils.import("resource://gre/modules/osfile/ospath_unix.jsm", ImportU
var Win = ImportWin;
var Unix = ImportUnix;
function do_check_fail(f) {
function do_check_fail(f)
{
try {
let result = f();
do_print("Failed do_check_fail: " + result);
@ -24,9 +25,10 @@ function do_check_fail(f) {
} catch (ex) {
do_check_true(true);
}
}
};
function run_test() {
function run_test()
{
do_print("Testing Windows paths");
do_print("Backslash-separated, no drive");

Просмотреть файл

@ -16,7 +16,7 @@ function compare_paths(ospath, key) {
let file;
try {
file = Services.dirsvc.get(key, Components.interfaces.nsIFile);
} catch (ex) {}
} catch(ex) {}
if (file) {
do_check_true(!!ospath);

Просмотреть файл

@ -32,7 +32,7 @@ add_task(async function check_failure() {
} catch (err) {
exception = err;
await OS.File.queue;
}
do_check_true(exception != null);
}
do_check_true(exception!=null);
do_print("Function resolved");
});
});

Просмотреть файл

@ -34,7 +34,7 @@ function testFiles(filename) {
// Ensure that openUnique() generates different file names each time, using the HEX number algorithm
let filenames = new Set();
for (let i = 0; i < MAX_TRIES; i++) {
for (let i=0; i < MAX_TRIES; i++) {
openedFile = await OS.File.openUnique(path);
await openedFile.file.close();
filenames.add(openedFile.path);
@ -43,7 +43,7 @@ function testFiles(filename) {
do_check_eq(filenames.size, MAX_TRIES);
// Ensure that openUnique() creates a new human readable file name using, as the original name is already taken.
openedFile = await OS.File.openUnique(path, {humanReadable: true});
openedFile = await OS.File.openUnique(path, {humanReadable : true});
do_print("\nCreate unique Human Readable file: " + openedFile.path);
await openedFile.file.close();
exists = await OS.File.exists(openedFile.path);
@ -53,8 +53,8 @@ function testFiles(filename) {
// Ensure that openUnique() generates different human readable file names each time
filenames = new Set();
for (let i = 0; i < MAX_TRIES; i++) {
openedFile = await OS.File.openUnique(path, {humanReadable: true});
for (let i=0; i < MAX_TRIES; i++) {
openedFile = await OS.File.openUnique(path, {humanReadable : true});
await openedFile.file.close();
filenames.add(openedFile.path);
}
@ -63,8 +63,8 @@ function testFiles(filename) {
let exn;
try {
for (let i = 0; i < 100; i++) {
openedFile = await OS.File.openUnique(path, {humanReadable: true});
for (let i=0; i < 100; i++) {
openedFile = await OS.File.openUnique(path, {humanReadable : true});
await openedFile.file.close();
}
} catch (ex) {