writeTextSync will now unlock the file when it is done writing

This commit is contained in:
Panayot Cankov
2015-11-11 14:44:15 +02:00
parent 4fddce9d0b
commit d05b6fb890

View File

@@ -245,18 +245,22 @@ export class File extends FileSystemEntity {
public writeTextSync(content: string, onError?: (error: any) => any, encoding?: string): void { public writeTextSync(content: string, onError?: (error: any) => any, encoding?: string): void {
this.checkAccess(); this.checkAccess();
this[fileLockedProperty] = true; try {
this[fileLockedProperty] = true;
var that = this; var that = this;
var localError = function (error) { var localError = function (error) {
that[fileLockedProperty] = false; that[fileLockedProperty] = false;
if (onError) { if (onError) {
onError(error); onError(error);
} }
}; };
// TODO: Asyncronous // TODO: Asyncronous
getFileAccess().writeText(this.path, content, localError, encoding); getFileAccess().writeText(this.path, content, localError, encoding);
} finally {
this[fileLockedProperty] = false;
}
} }
private checkAccess() { private checkAccess() {