mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 761138 - Create/remove directories (Unix version). r=froydnj
This commit is contained in:
parent
f88b773991
commit
300050b577
@ -109,7 +109,7 @@ if (typeof Components != "undefined") {
|
||||
*/
|
||||
Object.defineProperty(OSError.prototype, "becauseExists", {
|
||||
get: function becauseExists() {
|
||||
return this.unixErrno == OS.Constants.libc.EEXISTS;
|
||||
return this.unixErrno == OS.Constants.libc.EEXIST;
|
||||
}
|
||||
});
|
||||
/**
|
||||
@ -122,6 +122,16 @@ if (typeof Components != "undefined") {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* |true| if the error was raised because a directory is not empty
|
||||
* does not exist, |false| otherwise.
|
||||
*/
|
||||
Object.defineProperty(OSError.prototype, "becauseNotEmpty", {
|
||||
get: function becauseNotEmpty() {
|
||||
return this.unixErrno == OS.Constants.libc.ENOTEMPTY;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Serialize an instance of OSError to something that can be
|
||||
* transmitted across threads (not necessarily a string).
|
||||
|
@ -268,6 +268,49 @@
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove an empty directory.
|
||||
*
|
||||
* @param {string} path The name of the directory to remove.
|
||||
* @param {*=} options Additional options.
|
||||
* - {bool} ignoreAbsent If |true|, do not fail if the
|
||||
* directory does not exist yet.
|
||||
*/
|
||||
File.removeEmptyDir = function removeEmptyDir(path, options) {
|
||||
options = options || noOptions;
|
||||
let result = UnixFile.rmdir(path);
|
||||
if (result == -1) {
|
||||
if (options.ignoreAbsent && ctypes.errno == Const.ENOENT) {
|
||||
return;
|
||||
}
|
||||
throw new File.Error("removeEmptyDir");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Default mode for opening directories.
|
||||
*/
|
||||
const DEFAULT_UNIX_MODE_DIR = Const.S_IRWXU;
|
||||
|
||||
/**
|
||||
* Create a directory.
|
||||
*
|
||||
* @param {string} path The name of the directory.
|
||||
* @param {*=} options Additional options. This
|
||||
* implementation interprets the following fields:
|
||||
*
|
||||
* - {number} unixMode If specified, a file creation mode,
|
||||
* as per libc function |mkdir|. If unspecified, dirs are
|
||||
* created with a default mode of 0700 (dir is private to
|
||||
* the user, the user can read, write and execute).
|
||||
*/
|
||||
File.makeDir = function makeDir(path, options) {
|
||||
options = options || noOptions;
|
||||
let omode = options.unixMode || DEFAULT_UNIX_MODE_DIR;
|
||||
throw_on_negative("makeDir",
|
||||
UnixFile.mkdir(path, omode));
|
||||
};
|
||||
|
||||
/**
|
||||
* Copy a file to a destination.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user