/**
 * This file is part of the vscode-remote-workspace distribution.
 * Copyright (c) Marcel Joachim Kloubert.
 *
 * vscode-remote-workspace is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, version 3.
 *
 * vscode-remote-workspace is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */ import * as vscrw from './extension' ; import * as vscode from 'vscode' ; import * as vscode_helpers from 'vscode-helpers' ; /**
 * Options for 'copy()' method of a 'vscode.FileSystemProvider' object.
 */ export type CopyOptions = { overwrite : boolean ; } ; /**
 * An directory item.
 */ export type DirectoryEntry = [ string , vscode . FileType ] ; /**
 * Options for 'writeFile()' method of a 'vscode.FileSystemProvider' object.
 */ export interface WriteFileOptions { /**
     * Create file if not exist.
     */ create : boolean ; /**
     * Overwrite file if exist.
     */ overwrite : boolean ; } /**
 * SFTP file system.
 */ export abstract class FileSystemBase extends vscode_helpers . DisposableBase implements vscode . FileSystemProvider { private readonly _EVENT_EMITTER : vscode . EventEmitter < vscode . FileChangeEvent [ ] > ; /**
     * Initializes a new instance of that class.
     */ public constructor ( ) { super ( ) ; this . _EVENT_EMITTER = new vscode . EventEmitter < vscode . FileChangeEvent [ ] > ( ) ; this . onDidChangeFile = this . _EVENT_EMITTER . event ; } inheritdoc public abstract async createDirectory ( uri ) ; inheritdoc public abstract async delete ( uri , options ) ; return { vscode_helpers . Logger } public get logger ( ) { return vscrw . getLogger ( ) ; } inheritdoc public readonly onDidChangeFile : vscode . Event < vscode . FileChangeEvent [ ] > ; inheritdoc public abstract async readDirectory ( uri ) ; inheritdoc public abstract async readFile ( uri ) ; inheritdoc public abstract async rename ( oldUri , newUri , options ) ; inheritdoc public abstract async stat ( uri ) ; param { vscode . FileStat | false } stat param { WriteFileOptions } options param { vscode . Uri } uri protected throwIfWriteFileIsNotAllowed ( stat , options , uri ? ) { if ( false === stat ) { if ( ! options . create ) { throw vscode . FileSystemError . FileNotFound ( uri ) ; } } else { if ( vscode . FileType . Directory === stat . type ) { throw vscode . FileSystemError . FileIsADirectory ( uri ) ; } if ( ! options . overwrite ) { throw vscode . FileSystemError . FileExists ( uri ) ; } } } param { vscode . Uri } uri param { Function } errorFactory protected throwWithoutAuthority ( uri , errorFactory ) { const SAFE_URI = vscrw . uriWithoutAuthority ( uri ) ; const ERROR = errorFactory ( SAFE_URI ) ; if ( ERROR ) { throw ERROR ; } } inheritdoc public abstract watch ( uri , options ) ; inheritdoc public abstract async writeFile ( uri , content , options ) ; }