diff options
Diffstat (limited to 'js/os.ts')
-rw-r--r-- | js/os.ts | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -336,3 +336,29 @@ export function writeFileSync( const msg = fbs.WriteFileSync.endWriteFileSync(builder); send(builder, fbs.Any.WriteFileSync, msg); } + +/** + * Renames (moves) oldpath to newpath. + * import { renameSync } from "deno"; + * const oldpath = 'from/path'; + * const newpath = 'to/path'; + * + * renameSync(oldpath, newpath); + */ +export function renameSync(oldpath: string, newpath: string): void { + /* Ideally we could write: + const res = send({ + command: fbs.Command.RENAME_SYNC, + renameOldPath: oldpath, + renameNewPath: newpath + }); + */ + const builder = new flatbuffers.Builder(); + const _oldpath = builder.createString(oldpath); + const _newpath = builder.createString(newpath); + fbs.RenameSync.startRenameSync(builder); + fbs.RenameSync.addOldpath(builder, _oldpath); + fbs.RenameSync.addNewpath(builder, _newpath); + const msg = fbs.RenameSync.endRenameSync(builder); + send(builder, fbs.Any.RenameSync, msg); +} |