mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 912457 - Expose async |flush()| in OS.File. r=yoric
This commit is contained in:
parent
b838c04b01
commit
7631e2c127
@ -485,6 +485,22 @@ File.prototype = {
|
||||
setPosition: function setPosition(pos, whence) {
|
||||
return Scheduler.post("File_prototype_setPosition",
|
||||
[this._fdmsg, pos, whence]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Flushes the file's buffers and causes all buffered data
|
||||
* to be written.
|
||||
* Disk flushes are very expensive and therefore should be used carefully,
|
||||
* sparingly and only in scenarios where it is vital that data survives
|
||||
* system crashes. Even though the function will be executed off the
|
||||
* main-thread, it might still affect the overall performance of any running
|
||||
* application.
|
||||
*
|
||||
* @return {promise}
|
||||
*/
|
||||
flush: function flush() {
|
||||
return Scheduler.post("File_prototype_flush",
|
||||
[this._fdmsg]);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -408,6 +408,12 @@ if (this.Components) {
|
||||
return this.getPosition();
|
||||
});
|
||||
},
|
||||
File_prototype_flush: function flush(fd) {
|
||||
return withFile(fd,
|
||||
function do_flush() {
|
||||
return this.flush();
|
||||
});
|
||||
},
|
||||
// Methods of OS.File.DirectoryIterator
|
||||
DirectoryIterator_prototype_next: function next(dir) {
|
||||
return withDir(dir,
|
||||
|
@ -171,6 +171,11 @@
|
||||
/**
|
||||
* Flushes the file's buffers and causes all buffered data
|
||||
* to be written.
|
||||
* Disk flushes are very expensive and therefore should be used carefully,
|
||||
* sparingly and only in scenarios where it is vital that data survives
|
||||
* system crashes. Even though the function will be executed off the
|
||||
* main-thread, it might still affect the overall performance of any
|
||||
* running application.
|
||||
*
|
||||
* @throws {OS.File.Error} In case of I/O error.
|
||||
*/
|
||||
|
@ -191,6 +191,11 @@
|
||||
/**
|
||||
* Flushes the file's buffers and causes all buffered data
|
||||
* to be written.
|
||||
* Disk flushes are very expensive and therefore should be used carefully,
|
||||
* sparingly and only in scenarios where it is vital that data survives
|
||||
* system crashes. Even though the function will be executed off the
|
||||
* main-thread, it might still affect the overall performance of any
|
||||
* running application.
|
||||
*
|
||||
* @throws {OS.File.Error} In case of I/O error.
|
||||
*/
|
||||
|
@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||
Components.utils.import("resource://gre/modules/Task.jsm");
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to ensure that |File.prototype.flush| is available in the async API.
|
||||
*/
|
||||
|
||||
add_task(function test_flush() {
|
||||
let path = OS.Path.join(OS.Constants.Path.tmpDir,
|
||||
"test_osfile_async_flush.tmp");
|
||||
let file = yield OS.File.open(path, {trunc: true, write: true});
|
||||
try {
|
||||
try {
|
||||
yield file.flush();
|
||||
} finally {
|
||||
yield file.close();
|
||||
}
|
||||
} finally {
|
||||
yield OS.File.remove(path);
|
||||
}
|
||||
});
|
||||
|
||||
add_task(do_test_finished);
|
@ -8,6 +8,7 @@ tail =
|
||||
[test_osfile_async_append.js]
|
||||
[test_osfile_async_bytes.js]
|
||||
[test_osfile_async_copy.js]
|
||||
[test_osfile_async_flush.js]
|
||||
[test_profiledir.js]
|
||||
[test_logging.js]
|
||||
[test_creationDate.js]
|
||||
|
Loading…
Reference in New Issue
Block a user