MCPcopy
hub / github.com/jvilk/BrowserFS / renameSync

Method renameSync

src/backend/MountableFileSystem.ts:229–245  ·  view source on GitHub ↗
(oldPath: string, newPath: string)

Source from the content-addressed store, hash-verified

227 }
228
229 public renameSync(oldPath: string, newPath: string): void {
230 // Scenario 1: old and new are on same FS.
231 const fs1rv = this._getFs(oldPath);
232 const fs2rv = this._getFs(newPath);
233 if (fs1rv.fs === fs2rv.fs) {
234 try {
235 return fs1rv.fs.renameSync(fs1rv.path, fs2rv.path);
236 } catch (e) {
237 this.standardizeError(this.standardizeError(e, fs1rv.path, oldPath), fs2rv.path, newPath);
238 throw e;
239 }
240 }
241 // Scenario 2: Different file systems.
242 const data = fs.readFileSync(oldPath);
243 fs.writeFileSync(newPath, data);
244 return fs.unlinkSync(oldPath);
245 }
246
247 public readdirSync(p: string): string[] {
248 const fsInfo = this._getFs(p);

Callers

nothing calls this directly

Calls 6

_getFsMethod · 0.95
standardizeErrorMethod · 0.95
renameSyncMethod · 0.65
readFileSyncMethod · 0.65
writeFileSyncMethod · 0.65
unlinkSyncMethod · 0.65

Tested by

no test coverage detected