MCPcopy Create free account
hub / github.com/dethcrypto/dethcode / writeFile

Method writeFile

packages/ethereum-viewer/src/fs/fileSystemProvider.ts:83–111  ·  view source on GitHub ↗
(
    uri: vscode.Uri,
    content: Uint8Array,
    options: { create: boolean; overwrite: boolean }
  )

Source from the content-addressed store, hash-verified

81 }
82
83 writeFile(
84 uri: vscode.Uri,
85 content: Uint8Array,
86 options: { create: boolean; overwrite: boolean }
87 ): void {
88 const basename = path.posix.basename(uri.path);
89 const parent = this._ensureParentDirectory(uri);
90 let entry = parent.entries.get(basename);
91
92 if (entry instanceof Directory) {
93 throw vscode.FileSystemError.FileIsADirectory(uri);
94 }
95 if (!entry && !options.create) {
96 throw vscode.FileSystemError.FileNotFound(uri);
97 }
98 if (entry && options.create && !options.overwrite) {
99 throw vscode.FileSystemError.FileExists(uri);
100 }
101 if (!entry) {
102 entry = new File(basename);
103 parent.entries.set(basename, entry);
104 this._fireSoon({ type: vscode.FileChangeType.Created, uri });
105 }
106 entry.mtime = Date.now();
107 entry.size = content.byteLength;
108 entry.data = content;
109
110 this._fireSoon({ type: vscode.FileChangeType.Changed, uri });
111 }
112
113 // --- manage files/folders
114

Callers 3

fileSystem.test.tsFile · 0.80
writeFileFunction · 0.80

Calls 2

_fireSoonMethod · 0.95

Tested by

no test coverage detected