files2 - mode => flags

This commit is contained in:
Benjamin Pasero 2019-03-26 18:49:14 +01:00
parent c1c1f2b2af
commit addde0b36b

View file

@ -121,7 +121,7 @@ export class DiskFileSystemProvider extends Disposable implements IFileSystemPro
if (exists && isWindows) {
try {
// On Windows and if the file exists, we use a different strategy of saving the file
// by first truncating the file and then writing with r+ mode. This helps to save hidden files on Windows
// by first truncating the file and then writing with r+ flag. This helps to save hidden files on Windows
// (see https://github.com/Microsoft/vscode/issues/931) and prevent removing alternate data streams
// (see https://github.com/Microsoft/vscode/issues/6363)
await truncate(filePath, 0);
@ -153,20 +153,20 @@ export class DiskFileSystemProvider extends Disposable implements IFileSystemPro
try {
const filePath = this.toFilePath(resource);
let mode: string;
let flags: string;
if (opts.create) {
// we take this as a hint that the file is opened for writing
// as such we use 'w' to truncate an existing or create the
// file otherwise. we do not allow reading.
mode = 'w';
flags = 'w';
} else {
// otherwise we assume the file is opened for reading
// as such we use 'r' to neither truncate, nor create
// the file.
mode = 'r';
flags = 'r';
}
return await promisify(open)(filePath, mode);
return await promisify(open)(filePath, flags);
} catch (error) {
throw this.toFileSystemProviderError(error);
}