How to use the @theia/filesystem/lib/common.FileSystemError.FileExists function in @theia/filesystem

To help you get started, we’ve selected a few @theia/filesystem examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eclipse-theia / theia / packages / task / src / browser / task-configuration-manager.ts View on Github external
let uri: URI;
            if (configUri && configUri.path.base === 'tasks.json') {
                uri = configUri;
            } else { // fallback
                uri = new URI(model.workspaceFolderUri).resolve(`${this.preferenceConfigurations.getPaths()[0]}/tasks.json`);
            }

            const fileStat = await this.filesystem.getFileStat(uri.toString());
            if (!fileStat) {
                throw new Error(`file not found: ${uri.toString()}`);
            }
            try {
                this.filesystem.setContent(fileStat, content);
            } catch (e) {
                if (!FileSystemError.FileExists.is(e)) {
                    throw e;
                }
            }
            return uri;
        }
    }
github eclipse-theia / theia / packages / debug / src / browser / debug-configuration-manager.ts View on Github external
if (configUri && configUri.path.base === 'launch.json') {
            uri = configUri;
        } else { // fallback
            uri = new URI(model.workspaceFolderUri).resolve(`${this.preferenceConfigurations.getPaths()[0]}/launch.json`);
        }
        const debugType = await this.selectDebugType();
        const configurations = debugType ? await this.provideDebugConfigurations(debugType, model.workspaceFolderUri) : [];
        const content = this.getInitialConfigurationContent(configurations);
        const fileStat = await this.filesystem.getFileStat(uri.toString());
        if (!fileStat) {
            throw new Error(`file not found: ${uri.toString()}`);
        }
        try {
            await this.filesystem.setContent(fileStat, content);
        } catch (e) {
            if (!FileSystemError.FileExists.is(e)) {
                throw e;
            }
        }
        return uri;
    }