diff options
Diffstat (limited to 'js/rename.ts')
-rw-r--r-- | js/rename.ts | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/js/rename.ts b/js/rename.ts index e5e08d647..9d475f7e9 100644 --- a/js/rename.ts +++ b/js/rename.ts @@ -3,6 +3,20 @@ import * as msg from "gen/msg_generated"; import * as flatbuffers from "./flatbuffers"; import * as dispatch from "./dispatch"; +function req( + oldpath: string, + newpath: string +): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] { + const builder = flatbuffers.createBuilder(); + const oldpath_ = builder.createString(oldpath); + const newpath_ = builder.createString(newpath); + msg.Rename.startRename(builder); + msg.Rename.addOldpath(builder, oldpath_); + msg.Rename.addNewpath(builder, newpath_); + const inner = msg.Rename.endRename(builder); + return [builder, msg.Any.Rename, inner]; +} + /** Synchronously renames (moves) `oldpath` to `newpath`. If `newpath` already * exists and is not a directory, `renameSync()` replaces it. OS-specific * restrictions may apply when `oldpath` and `newpath` are in different @@ -23,17 +37,3 @@ export function renameSync(oldpath: string, newpath: string): void { export async function rename(oldpath: string, newpath: string): Promise<void> { await dispatch.sendAsync(...req(oldpath, newpath)); } - -function req( - oldpath: string, - newpath: string -): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] { - const builder = flatbuffers.createBuilder(); - const oldpath_ = builder.createString(oldpath); - const newpath_ = builder.createString(newpath); - msg.Rename.startRename(builder); - msg.Rename.addOldpath(builder, oldpath_); - msg.Rename.addNewpath(builder, newpath_); - const inner = msg.Rename.endRename(builder); - return [builder, msg.Any.Rename, inner]; -} |