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 {
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() {