mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
writeTextSync will now unlock the file when it is done writing
This commit is contained in:
@@ -245,18 +245,22 @@ export class File extends FileSystemEntity {
|
||||
public writeTextSync(content: string, onError?: (error: any) => any, encoding?: string): void {
|
||||
this.checkAccess();
|
||||
|
||||
this[fileLockedProperty] = true;
|
||||
|
||||
var that = this;
|
||||
var localError = function (error) {
|
||||
that[fileLockedProperty] = false;
|
||||
if (onError) {
|
||||
onError(error);
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: Asyncronous
|
||||
getFileAccess().writeText(this.path, content, localError, encoding);
|
||||
try {
|
||||
this[fileLockedProperty] = true;
|
||||
|
||||
var that = this;
|
||||
var localError = function (error) {
|
||||
that[fileLockedProperty] = false;
|
||||
if (onError) {
|
||||
onError(error);
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: Asyncronous
|
||||
getFileAccess().writeText(this.path, content, localError, encoding);
|
||||
} finally {
|
||||
this[fileLockedProperty] = false;
|
||||
}
|
||||
}
|
||||
|
||||
private checkAccess() {
|
||||
|
||||
Reference in New Issue
Block a user