mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 770538 - Call Unix C function |dirfd| from JavaScript. r=dteller
This commit is contained in:
parent
28f2d72fcb
commit
44ca94fcc1
@ -241,6 +241,11 @@
|
||||
/*return*/ Types.negativeone_or_fd,
|
||||
/*fd*/ Types.fd);
|
||||
|
||||
UnixFile.dirfd =
|
||||
declareFFI("dirfd", ctypes.default_abi,
|
||||
/*return*/ Types.negativeone_or_fd,
|
||||
/*dir*/ Types.null_or_DIR_ptr);
|
||||
|
||||
UnixFile.chdir =
|
||||
declareFFI("chdir", ctypes.default_abi,
|
||||
/*return*/ Types.negativeone_or_nothing,
|
||||
|
@ -650,6 +650,14 @@
|
||||
this._dir = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return directory as |File|
|
||||
*/
|
||||
File.DirectoryIterator.prototype.unixAsFile = function unixAsFile() {
|
||||
if (!this._dir) throw File.Error.closed();
|
||||
return error_or_file(UnixFile.dirfd(this._dir));
|
||||
};
|
||||
|
||||
/**
|
||||
* An entry in a directory.
|
||||
*/
|
||||
|
@ -553,6 +553,28 @@ function test_iter_dir()
|
||||
});
|
||||
iterator.close();
|
||||
|
||||
//test for prototype |OS.File.DirectoryIterator.unixAsFile|
|
||||
if ("unixAsFile" in OS.File.DirectoryIterator.prototype) {
|
||||
ok(true, "testing property unixAsFile");
|
||||
let path = OS.Path.join("chrome", "toolkit", "components", "osfile", "tests", "mochi");
|
||||
iterator = new OS.File.DirectoryIterator(path);
|
||||
|
||||
let dir_file = iterator.unixAsFile();// return |File|
|
||||
let stat0 = dir_file.stat();
|
||||
let stat1 = OS.File.stat(path);
|
||||
|
||||
let unix_info_to_string = function unix_info_to_string(info) {
|
||||
return "| " + info.unixMode + " | " + info.unixOwner + " | " + info.unixGroup + " | " + info.creationDate + " | " + info.lastModificationDate + " | " + info.lastAccessDate + " | " + info.size + " |";
|
||||
};
|
||||
|
||||
let s0_string = unix_info_to_string(stat0);
|
||||
let s1_string = unix_info_to_string(stat1);
|
||||
|
||||
ok(stat0.isDir, "unixAsFile returned a directory");
|
||||
is(s0_string, s1_string, "unixAsFile returned the correct file");
|
||||
dir_file.close();
|
||||
iterator.close();
|
||||
}
|
||||
ok(true, "test_iter_dir: Complete");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user