358
359
private async doValidateCreateFile(resource: URI, options?: ICreateFileOptions): Promise<void> {
361
>
// validate overwrite
362
>
if (!options?.overwrite && await this.exists(resource)) {
363
throw new FileOperationError(localize('fileExists', "Unable to create file '{0}' that already exists when overwrite flag is not set", this.resourceForError(resource)), FileOperationResult.FILE_MODIFIED_SINCE, options);
364
}
366
367
async createFile(resource: URI, bufferOrReadableOrStream: VSBuffer | VSBufferReadable | VSBufferReadableStream = VSBuffer.fromString(''), options?: ICreateFileOptions): Promise<IFileStatWithMetadata> {
369
>
// validate
370
>
await this.doValidateCreateFile(resource, options);
371
>
372
>
// do write into file (this will create it too)
373
>
const fileStat = await this.writeFile(resource, bufferOrReadableOrStream);
374
>
375
>
// events
376
>
this._onDidRunOperation.fire(new FileOperationEvent(resource, FileOperation.CREATE, fileStat));
377
>
378
>
return fileStat;
379
>
}
380
381
async writeFile(resource: URI, bufferOrReadableOrStream: VSBuffer | VSBufferReadable | VSBufferReadableStream, options?: IWriteFileOptions): Promise<IFileStatWithMetadata> {