mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
Rename flatbuffer base.msg to base.inner
This better disambiguates with the msg_generated.ts module, which in JS we call "fbs", but would be better called "msg".
This commit is contained in:
parent
51dc46eff4
commit
f774953011
21 changed files with 204 additions and 204 deletions
|
@ -41,6 +41,6 @@ function req(
|
|||
fbs.CopyFile.startCopyFile(builder);
|
||||
fbs.CopyFile.addFrom(builder, from_);
|
||||
fbs.CopyFile.addTo(builder, to_);
|
||||
const msg = fbs.CopyFile.endCopyFile(builder);
|
||||
return [builder, fbs.Any.CopyFile, msg];
|
||||
const inner = fbs.CopyFile.endCopyFile(builder);
|
||||
return [builder, fbs.Any.CopyFile, inner];
|
||||
}
|
||||
|
|
|
@ -39,12 +39,12 @@ export function handleAsyncMsgFromRust(ui8: Uint8Array) {
|
|||
// @internal
|
||||
export function sendAsync(
|
||||
builder: flatbuffers.Builder,
|
||||
msgType: fbs.Any,
|
||||
msg: flatbuffers.Offset,
|
||||
innerType: fbs.Any,
|
||||
inner: flatbuffers.Offset,
|
||||
data?: ArrayBufferView
|
||||
): Promise<fbs.Base> {
|
||||
maybePushTrace(msgType, false); // add to trace if tracing
|
||||
const [cmdId, resBuf] = sendInternal(builder, msgType, msg, data, false);
|
||||
maybePushTrace(innerType, false); // add to trace if tracing
|
||||
const [cmdId, resBuf] = sendInternal(builder, innerType, inner, data, false);
|
||||
util.assert(resBuf == null);
|
||||
const promise = util.createResolvable<fbs.Base>();
|
||||
promiseTable.set(cmdId, promise);
|
||||
|
@ -54,12 +54,12 @@ export function sendAsync(
|
|||
// @internal
|
||||
export function sendSync(
|
||||
builder: flatbuffers.Builder,
|
||||
msgType: fbs.Any,
|
||||
msg: flatbuffers.Offset,
|
||||
innerType: fbs.Any,
|
||||
inner: flatbuffers.Offset,
|
||||
data?: ArrayBufferView
|
||||
): null | fbs.Base {
|
||||
maybePushTrace(msgType, true); // add to trace if tracing
|
||||
const [cmdId, resBuf] = sendInternal(builder, msgType, msg, data, true);
|
||||
maybePushTrace(innerType, true); // add to trace if tracing
|
||||
const [cmdId, resBuf] = sendInternal(builder, innerType, inner, data, true);
|
||||
util.assert(cmdId >= 0);
|
||||
if (resBuf == null) {
|
||||
return null;
|
||||
|
@ -74,15 +74,15 @@ export function sendSync(
|
|||
|
||||
function sendInternal(
|
||||
builder: flatbuffers.Builder,
|
||||
msgType: fbs.Any,
|
||||
msg: flatbuffers.Offset,
|
||||
innerType: fbs.Any,
|
||||
inner: flatbuffers.Offset,
|
||||
data: undefined | ArrayBufferView,
|
||||
sync = true
|
||||
): [number, null | Uint8Array] {
|
||||
const cmdId = nextCmdId++;
|
||||
fbs.Base.startBase(builder);
|
||||
fbs.Base.addMsg(builder, msg);
|
||||
fbs.Base.addMsgType(builder, msgType);
|
||||
fbs.Base.addInner(builder, inner);
|
||||
fbs.Base.addInnerType(builder, innerType);
|
||||
fbs.Base.addSync(builder, sync);
|
||||
fbs.Base.addCmdId(builder, cmdId);
|
||||
builder.finish(fbs.Base.endBase(builder));
|
||||
|
|
16
js/fetch.ts
16
js/fetch.ts
|
@ -205,20 +205,20 @@ export async function fetch(
|
|||
);
|
||||
|
||||
// Decode FetchRes
|
||||
assert(fbs.Any.FetchRes === resBase.msgType());
|
||||
const msg = new fbs.FetchRes();
|
||||
assert(resBase.msg(msg) != null);
|
||||
assert(fbs.Any.FetchRes === resBase.innerType());
|
||||
const inner = new fbs.FetchRes();
|
||||
assert(resBase.inner(inner) != null);
|
||||
|
||||
const status = msg.status();
|
||||
const bodyArray = msg.bodyArray();
|
||||
const status = inner.status();
|
||||
const bodyArray = inner.bodyArray();
|
||||
assert(bodyArray != null);
|
||||
const body = typedArrayToArrayBuffer(bodyArray!);
|
||||
|
||||
const headersList: Array<[string, string]> = [];
|
||||
const len = msg.headerKeyLength();
|
||||
const len = inner.headerKeyLength();
|
||||
for (let i = 0; i < len; ++i) {
|
||||
const key = msg.headerKey(i);
|
||||
const value = msg.headerValue(i);
|
||||
const key = inner.headerKey(i);
|
||||
const value = inner.headerValue(i);
|
||||
headersList.push([key, value]);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,18 +73,18 @@ export class FileInfoImpl implements FileInfo {
|
|||
path: string | null;
|
||||
|
||||
/* @internal */
|
||||
constructor(private _msg: fbs.StatRes) {
|
||||
const modified = this._msg.modified().toFloat64();
|
||||
const accessed = this._msg.accessed().toFloat64();
|
||||
const created = this._msg.created().toFloat64();
|
||||
const hasMode = this._msg.hasMode();
|
||||
const mode = this._msg.mode(); // negative for invalid mode (Windows)
|
||||
const name = this._msg.name();
|
||||
const path = this._msg.path();
|
||||
constructor(private _inner: fbs.StatRes) {
|
||||
const modified = this._inner.modified().toFloat64();
|
||||
const accessed = this._inner.accessed().toFloat64();
|
||||
const created = this._inner.created().toFloat64();
|
||||
const hasMode = this._inner.hasMode();
|
||||
const mode = this._inner.mode(); // negative for invalid mode (Windows)
|
||||
const name = this._inner.name();
|
||||
const path = this._inner.path();
|
||||
|
||||
this._isFile = this._msg.isFile();
|
||||
this._isSymlink = this._msg.isSymlink();
|
||||
this.len = this._msg.len().toFloat64();
|
||||
this._isFile = this._inner.isFile();
|
||||
this._isSymlink = this._inner.isSymlink();
|
||||
this.len = this._inner.len().toFloat64();
|
||||
this.modified = modified ? modified : null;
|
||||
this.accessed = accessed ? accessed : null;
|
||||
this.created = created ? created : null;
|
||||
|
|
28
js/files.ts
28
js/files.ts
|
@ -41,12 +41,12 @@ export async function open(
|
|||
const filename_ = builder.createString(filename);
|
||||
fbs.Open.startOpen(builder);
|
||||
fbs.Open.addFilename(builder, filename_);
|
||||
const msg = fbs.Open.endOpen(builder);
|
||||
const baseRes = await dispatch.sendAsync(builder, fbs.Any.Open, msg);
|
||||
const inner = fbs.Open.endOpen(builder);
|
||||
const baseRes = await dispatch.sendAsync(builder, fbs.Any.Open, inner);
|
||||
assert(baseRes != null);
|
||||
assert(fbs.Any.OpenRes === baseRes!.msgType());
|
||||
assert(fbs.Any.OpenRes === baseRes!.innerType());
|
||||
const res = new fbs.OpenRes();
|
||||
assert(baseRes!.msg(res) != null);
|
||||
assert(baseRes!.inner(res) != null);
|
||||
const fd = res.rid();
|
||||
return new File(fd);
|
||||
}
|
||||
|
@ -58,12 +58,12 @@ export async function read(
|
|||
const builder = new flatbuffers.Builder();
|
||||
fbs.Read.startRead(builder);
|
||||
fbs.Read.addRid(builder, fd);
|
||||
const msg = fbs.Read.endRead(builder);
|
||||
const baseRes = await dispatch.sendAsync(builder, fbs.Any.Read, msg, p);
|
||||
const inner = fbs.Read.endRead(builder);
|
||||
const baseRes = await dispatch.sendAsync(builder, fbs.Any.Read, inner, p);
|
||||
assert(baseRes != null);
|
||||
assert(fbs.Any.ReadRes === baseRes!.msgType());
|
||||
assert(fbs.Any.ReadRes === baseRes!.innerType());
|
||||
const res = new fbs.ReadRes();
|
||||
assert(baseRes!.msg(res) != null);
|
||||
assert(baseRes!.inner(res) != null);
|
||||
return { nread: res.nread(), eof: res.eof() };
|
||||
}
|
||||
|
||||
|
@ -71,12 +71,12 @@ export async function write(fd: number, p: ArrayBufferView): Promise<number> {
|
|||
const builder = new flatbuffers.Builder();
|
||||
fbs.Write.startWrite(builder);
|
||||
fbs.Write.addRid(builder, fd);
|
||||
const msg = fbs.Write.endWrite(builder);
|
||||
const baseRes = await dispatch.sendAsync(builder, fbs.Any.Write, msg, p);
|
||||
const inner = fbs.Write.endWrite(builder);
|
||||
const baseRes = await dispatch.sendAsync(builder, fbs.Any.Write, inner, p);
|
||||
assert(baseRes != null);
|
||||
assert(fbs.Any.WriteRes === baseRes!.msgType());
|
||||
assert(fbs.Any.WriteRes === baseRes!.innerType());
|
||||
const res = new fbs.WriteRes();
|
||||
assert(baseRes!.msg(res) != null);
|
||||
assert(baseRes!.inner(res) != null);
|
||||
return res.nbyte();
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,6 @@ export function close(fd: number): void {
|
|||
const builder = new flatbuffers.Builder();
|
||||
fbs.Close.startClose(builder);
|
||||
fbs.Close.addRid(builder, fd);
|
||||
const msg = fbs.Close.endClose(builder);
|
||||
dispatch.sendSync(builder, fbs.Any.Close, msg);
|
||||
const inner = fbs.Close.endClose(builder);
|
||||
dispatch.sendSync(builder, fbs.Any.Close, inner);
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@ function sendStart(): fbs.StartRes {
|
|||
const startOffset = fbs.Start.endStart(builder);
|
||||
const baseRes = sendSync(builder, fbs.Any.Start, startOffset);
|
||||
assert(baseRes != null);
|
||||
assert(fbs.Any.StartRes === baseRes!.msgType());
|
||||
assert(fbs.Any.StartRes === baseRes!.innerType());
|
||||
const startRes = new fbs.StartRes();
|
||||
assert(baseRes!.msg(startRes) != null);
|
||||
assert(baseRes!.inner(startRes) != null);
|
||||
return startRes;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,15 +59,15 @@ function req({
|
|||
if (suffix != null) {
|
||||
fbs.MakeTempDir.addSuffix(builder, fbSuffix);
|
||||
}
|
||||
const msg = fbs.MakeTempDir.endMakeTempDir(builder);
|
||||
return [builder, fbs.Any.MakeTempDir, msg];
|
||||
const inner = fbs.MakeTempDir.endMakeTempDir(builder);
|
||||
return [builder, fbs.Any.MakeTempDir, inner];
|
||||
}
|
||||
|
||||
function res(baseRes: null | fbs.Base): string {
|
||||
assert(baseRes != null);
|
||||
assert(fbs.Any.MakeTempDirRes === baseRes!.msgType());
|
||||
assert(fbs.Any.MakeTempDirRes === baseRes!.innerType());
|
||||
const res = new fbs.MakeTempDirRes();
|
||||
assert(baseRes!.msg(res) != null);
|
||||
assert(baseRes!.inner(res) != null);
|
||||
const path = res.path();
|
||||
assert(path != null);
|
||||
return path!;
|
||||
|
|
|
@ -32,6 +32,6 @@ function req(
|
|||
fbs.Mkdir.startMkdir(builder);
|
||||
fbs.Mkdir.addPath(builder, path_);
|
||||
fbs.Mkdir.addMode(builder, mode);
|
||||
const msg = fbs.Mkdir.endMkdir(builder);
|
||||
return [builder, fbs.Any.Mkdir, msg];
|
||||
const inner = fbs.Mkdir.endMkdir(builder);
|
||||
return [builder, fbs.Any.Mkdir, inner];
|
||||
}
|
||||
|
|
36
js/os.ts
36
js/os.ts
|
@ -10,8 +10,8 @@ export function exit(exitCode = 0): never {
|
|||
const builder = new flatbuffers.Builder();
|
||||
fbs.Exit.startExit(builder);
|
||||
fbs.Exit.addCode(builder, exitCode);
|
||||
const msg = fbs.Exit.endExit(builder);
|
||||
sendSync(builder, fbs.Any.Exit, msg);
|
||||
const inner = fbs.Exit.endExit(builder);
|
||||
sendSync(builder, fbs.Any.Exit, inner);
|
||||
return util.unreachable();
|
||||
}
|
||||
|
||||
|
@ -27,15 +27,15 @@ export function codeFetch(
|
|||
fbs.CodeFetch.startCodeFetch(builder);
|
||||
fbs.CodeFetch.addModuleSpecifier(builder, moduleSpecifier_);
|
||||
fbs.CodeFetch.addContainingFile(builder, containingFile_);
|
||||
const msg = fbs.CodeFetch.endCodeFetch(builder);
|
||||
const baseRes = sendSync(builder, fbs.Any.CodeFetch, msg);
|
||||
const inner = fbs.CodeFetch.endCodeFetch(builder);
|
||||
const baseRes = sendSync(builder, fbs.Any.CodeFetch, inner);
|
||||
assert(baseRes != null);
|
||||
assert(
|
||||
fbs.Any.CodeFetchRes === baseRes!.msgType(),
|
||||
`base.msgType() unexpectedly is ${baseRes!.msgType()}`
|
||||
fbs.Any.CodeFetchRes === baseRes!.innerType(),
|
||||
`base.innerType() unexpectedly is ${baseRes!.innerType()}`
|
||||
);
|
||||
const codeFetchRes = new fbs.CodeFetchRes();
|
||||
assert(baseRes!.msg(codeFetchRes) != null);
|
||||
assert(baseRes!.inner(codeFetchRes) != null);
|
||||
return {
|
||||
moduleName: codeFetchRes.moduleName(),
|
||||
filename: codeFetchRes.filename(),
|
||||
|
@ -58,16 +58,16 @@ export function codeCache(
|
|||
fbs.CodeCache.addFilename(builder, filename_);
|
||||
fbs.CodeCache.addSourceCode(builder, sourceCode_);
|
||||
fbs.CodeCache.addOutputCode(builder, outputCode_);
|
||||
const msg = fbs.CodeCache.endCodeCache(builder);
|
||||
const baseRes = sendSync(builder, fbs.Any.CodeCache, msg);
|
||||
const inner = fbs.CodeCache.endCodeCache(builder);
|
||||
const baseRes = sendSync(builder, fbs.Any.CodeCache, inner);
|
||||
assert(baseRes == null); // Expect null or error.
|
||||
}
|
||||
|
||||
function createEnv(_msg: fbs.EnvironRes): { [index: string]: string } {
|
||||
function createEnv(_inner: fbs.EnvironRes): { [index: string]: string } {
|
||||
const env: { [index: string]: string } = {};
|
||||
|
||||
for (let i = 0; i < _msg.mapLength(); i++) {
|
||||
const item = _msg.map(i)!;
|
||||
for (let i = 0; i < _inner.mapLength(); i++) {
|
||||
const item = _inner.map(i)!;
|
||||
|
||||
env[item.key()!] = item.value()!;
|
||||
}
|
||||
|
@ -87,8 +87,8 @@ function setEnv(key: string, value: string): void {
|
|||
fbs.SetEnv.startSetEnv(builder);
|
||||
fbs.SetEnv.addKey(builder, _key);
|
||||
fbs.SetEnv.addValue(builder, _value);
|
||||
const msg = fbs.SetEnv.endSetEnv(builder);
|
||||
sendSync(builder, fbs.Any.SetEnv, msg);
|
||||
const inner = fbs.SetEnv.endSetEnv(builder);
|
||||
sendSync(builder, fbs.Any.SetEnv, inner);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -112,11 +112,11 @@ export function env(): { [index: string]: string } {
|
|||
*/
|
||||
const builder = new flatbuffers.Builder();
|
||||
fbs.Environ.startEnviron(builder);
|
||||
const msg = fbs.Environ.endEnviron(builder);
|
||||
const baseRes = sendSync(builder, fbs.Any.Environ, msg)!;
|
||||
assert(fbs.Any.EnvironRes === baseRes.msgType());
|
||||
const inner = fbs.Environ.endEnviron(builder);
|
||||
const baseRes = sendSync(builder, fbs.Any.Environ, inner)!;
|
||||
assert(fbs.Any.EnvironRes === baseRes.innerType());
|
||||
const res = new fbs.EnvironRes();
|
||||
assert(baseRes.msg(res) != null);
|
||||
assert(baseRes.inner(res) != null);
|
||||
// TypeScript cannot track assertion above, therefore not null assertion
|
||||
return createEnv(res);
|
||||
}
|
||||
|
|
|
@ -32,15 +32,15 @@ function req(path: string): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] {
|
|||
const path_ = builder.createString(path);
|
||||
fbs.ReadDir.startReadDir(builder);
|
||||
fbs.ReadDir.addPath(builder, path_);
|
||||
const msg = fbs.ReadDir.endReadDir(builder);
|
||||
return [builder, fbs.Any.ReadDir, msg];
|
||||
const inner = fbs.ReadDir.endReadDir(builder);
|
||||
return [builder, fbs.Any.ReadDir, inner];
|
||||
}
|
||||
|
||||
function res(baseRes: null | fbs.Base): FileInfo[] {
|
||||
assert(baseRes != null);
|
||||
assert(fbs.Any.ReadDirRes === baseRes!.msgType());
|
||||
assert(fbs.Any.ReadDirRes === baseRes!.innerType());
|
||||
const res = new fbs.ReadDirRes();
|
||||
assert(baseRes!.msg(res) != null);
|
||||
assert(baseRes!.inner(res) != null);
|
||||
const fileInfos: FileInfo[] = [];
|
||||
for (let i = 0; i < res.entriesLength(); i++) {
|
||||
fileInfos.push(new FileInfoImpl(res.entries(i)!));
|
||||
|
|
|
@ -35,16 +35,16 @@ function req(
|
|||
const filename_ = builder.createString(filename);
|
||||
fbs.ReadFile.startReadFile(builder);
|
||||
fbs.ReadFile.addFilename(builder, filename_);
|
||||
const msg = fbs.ReadFile.endReadFile(builder);
|
||||
return [builder, fbs.Any.ReadFile, msg];
|
||||
const inner = fbs.ReadFile.endReadFile(builder);
|
||||
return [builder, fbs.Any.ReadFile, inner];
|
||||
}
|
||||
|
||||
function res(baseRes: null | fbs.Base): Uint8Array {
|
||||
assert(baseRes != null);
|
||||
assert(fbs.Any.ReadFileRes === baseRes!.msgType());
|
||||
const msg = new fbs.ReadFileRes();
|
||||
assert(baseRes!.msg(msg) != null);
|
||||
const dataArray = msg.dataArray();
|
||||
assert(fbs.Any.ReadFileRes === baseRes!.innerType());
|
||||
const inner = new fbs.ReadFileRes();
|
||||
assert(baseRes!.inner(inner) != null);
|
||||
const dataArray = inner.dataArray();
|
||||
assert(dataArray != null);
|
||||
return new Uint8Array(dataArray!);
|
||||
}
|
||||
|
|
|
@ -29,15 +29,15 @@ function req(name: string): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] {
|
|||
const name_ = builder.createString(name);
|
||||
fbs.Readlink.startReadlink(builder);
|
||||
fbs.Readlink.addName(builder, name_);
|
||||
const msg = fbs.Readlink.endReadlink(builder);
|
||||
return [builder, fbs.Any.Readlink, msg];
|
||||
const inner = fbs.Readlink.endReadlink(builder);
|
||||
return [builder, fbs.Any.Readlink, inner];
|
||||
}
|
||||
|
||||
function res(baseRes: null | fbs.Base): string {
|
||||
assert(baseRes !== null);
|
||||
assert(fbs.Any.ReadlinkRes === baseRes!.msgType());
|
||||
assert(fbs.Any.ReadlinkRes === baseRes!.innerType());
|
||||
const res = new fbs.ReadlinkRes();
|
||||
assert(baseRes!.msg(res) !== null);
|
||||
assert(baseRes!.inner(res) !== null);
|
||||
const path = res.path();
|
||||
assert(path !== null);
|
||||
return path!;
|
||||
|
|
|
@ -58,6 +58,6 @@ function req(
|
|||
fbs.Remove.startRemove(builder);
|
||||
fbs.Remove.addPath(builder, path_);
|
||||
fbs.Remove.addRecursive(builder, recursive);
|
||||
const msg = fbs.Remove.endRemove(builder);
|
||||
return [builder, fbs.Any.Remove, msg];
|
||||
const inner = fbs.Remove.endRemove(builder);
|
||||
return [builder, fbs.Any.Remove, inner];
|
||||
}
|
||||
|
|
|
@ -37,6 +37,6 @@ function req(
|
|||
fbs.Rename.startRename(builder);
|
||||
fbs.Rename.addOldpath(builder, oldpath_);
|
||||
fbs.Rename.addNewpath(builder, newpath_);
|
||||
const msg = fbs.Rename.endRename(builder);
|
||||
return [builder, fbs.Any.Rename, msg];
|
||||
const inner = fbs.Rename.endRename(builder);
|
||||
return [builder, fbs.Any.Rename, inner];
|
||||
}
|
||||
|
|
|
@ -64,14 +64,14 @@ function req(
|
|||
fbs.Stat.startStat(builder);
|
||||
fbs.Stat.addFilename(builder, filename_);
|
||||
fbs.Stat.addLstat(builder, lstat);
|
||||
const msg = fbs.Stat.endStat(builder);
|
||||
return [builder, fbs.Any.Stat, msg];
|
||||
const inner = fbs.Stat.endStat(builder);
|
||||
return [builder, fbs.Any.Stat, inner];
|
||||
}
|
||||
|
||||
function res(baseRes: null | fbs.Base): FileInfo {
|
||||
assert(baseRes != null);
|
||||
assert(fbs.Any.StatRes === baseRes!.msgType());
|
||||
assert(fbs.Any.StatRes === baseRes!.innerType());
|
||||
const res = new fbs.StatRes();
|
||||
assert(baseRes!.msg(res) != null);
|
||||
assert(baseRes!.inner(res) != null);
|
||||
return new FileInfoImpl(res);
|
||||
}
|
||||
|
|
|
@ -51,6 +51,6 @@ function req(
|
|||
fbs.Symlink.startSymlink(builder);
|
||||
fbs.Symlink.addOldname(builder, oldname_);
|
||||
fbs.Symlink.addNewname(builder, newname_);
|
||||
const msg = fbs.Symlink.endSymlink(builder);
|
||||
return [builder, fbs.Any.Symlink, msg];
|
||||
const inner = fbs.Symlink.endSymlink(builder);
|
||||
return [builder, fbs.Any.Symlink, inner];
|
||||
}
|
||||
|
|
|
@ -54,8 +54,8 @@ function setGlobalTimeout(due: number | null, now: number) {
|
|||
const builder = new flatbuffers.Builder();
|
||||
fbs.SetTimeout.startSetTimeout(builder);
|
||||
fbs.SetTimeout.addTimeout(builder, timeout);
|
||||
const msg = fbs.SetTimeout.endSetTimeout(builder);
|
||||
const res = sendSync(builder, fbs.Any.SetTimeout, msg);
|
||||
const inner = fbs.SetTimeout.endSetTimeout(builder);
|
||||
const res = sendSync(builder, fbs.Any.SetTimeout, inner);
|
||||
assert(res == null);
|
||||
// Remember when when the global timer will fire.
|
||||
globalTimeoutDue = due;
|
||||
|
|
|
@ -37,6 +37,6 @@ function req(
|
|||
fbs.Truncate.startTruncate(builder);
|
||||
fbs.Truncate.addName(builder, name_);
|
||||
fbs.Truncate.addLen(builder, len);
|
||||
const msg = fbs.Truncate.endTruncate(builder);
|
||||
return [builder, fbs.Any.Truncate, msg];
|
||||
const inner = fbs.Truncate.endTruncate(builder);
|
||||
return [builder, fbs.Any.Truncate, inner];
|
||||
}
|
||||
|
|
|
@ -47,6 +47,6 @@ function req(
|
|||
fbs.WriteFile.startWriteFile(builder);
|
||||
fbs.WriteFile.addFilename(builder, filename_);
|
||||
fbs.WriteFile.addPerm(builder, perm);
|
||||
const msg = fbs.WriteFile.endWriteFile(builder);
|
||||
return [builder, fbs.Any.WriteFile, msg, data];
|
||||
const inner = fbs.WriteFile.endWriteFile(builder);
|
||||
return [builder, fbs.Any.WriteFile, inner, data];
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ table Base {
|
|||
sync: bool = true; // TODO(ry) Change default to false.
|
||||
error_kind: ErrorKind = NoError;
|
||||
error: string;
|
||||
msg: Any;
|
||||
inner: Any;
|
||||
}
|
||||
|
||||
table Start {
|
||||
|
|
200
src/ops.rs
200
src/ops.rs
|
@ -61,10 +61,10 @@ pub fn dispatch(
|
|||
) -> (bool, Box<Op>) {
|
||||
let base = msg::get_root_as_base(control);
|
||||
let is_sync = base.sync();
|
||||
let msg_type = base.msg_type();
|
||||
let inner_type = base.inner_type();
|
||||
let cmd_id = base.cmd_id();
|
||||
|
||||
let op: Box<Op> = if msg_type == msg::Any::SetTimeout {
|
||||
let op: Box<Op> = if inner_type == msg::Any::SetTimeout {
|
||||
// SetTimeout is an exceptional op: the global timeout field is part of the
|
||||
// Isolate state (not the IsolateState state) and it must be updated on the
|
||||
// main thread.
|
||||
|
@ -72,7 +72,7 @@ pub fn dispatch(
|
|||
op_set_timeout(isolate, &base, data)
|
||||
} else {
|
||||
// Handle regular ops.
|
||||
let op_creator: OpCreator = match msg_type {
|
||||
let op_creator: OpCreator = match inner_type {
|
||||
msg::Any::Start => op_start,
|
||||
msg::Any::CodeFetch => op_code_fetch,
|
||||
msg::Any::CodeCache => op_code_cache,
|
||||
|
@ -101,7 +101,7 @@ pub fn dispatch(
|
|||
msg::Any::Dial => op_dial,
|
||||
_ => panic!(format!(
|
||||
"Unhandled message {}",
|
||||
msg::enum_name_any(msg_type)
|
||||
msg::enum_name_any(inner_type)
|
||||
)),
|
||||
};
|
||||
op_creator(isolate.state.clone(), &base, data)
|
||||
|
@ -145,7 +145,7 @@ pub fn dispatch(
|
|||
|
||||
debug!(
|
||||
"msg_from_js {} sync {}",
|
||||
msg::enum_name_any(msg_type),
|
||||
msg::enum_name_any(inner_type),
|
||||
base.sync()
|
||||
);
|
||||
return (base.sync(), boxed_op);
|
||||
|
@ -170,8 +170,8 @@ fn op_exit(
|
|||
base: &msg::Base,
|
||||
_data: &'static mut [u8],
|
||||
) -> Box<Op> {
|
||||
let msg = base.msg_as_exit().unwrap();
|
||||
std::process::exit(msg.code())
|
||||
let inner = base.inner_as_exit().unwrap();
|
||||
std::process::exit(inner.code())
|
||||
}
|
||||
|
||||
fn op_start(
|
||||
|
@ -189,7 +189,7 @@ fn op_start(
|
|||
let cwd_off =
|
||||
builder.create_string(deno_fs::normalize_path(cwd_path.as_ref()).as_ref());
|
||||
|
||||
let msg = msg::StartRes::create(
|
||||
let inner = msg::StartRes::create(
|
||||
&mut builder,
|
||||
&msg::StartResArgs {
|
||||
cwd: Some(cwd_off),
|
||||
|
@ -204,8 +204,8 @@ fn op_start(
|
|||
base.cmd_id(),
|
||||
&mut builder,
|
||||
msg::BaseArgs {
|
||||
msg_type: msg::Any::StartRes,
|
||||
msg: Some(msg.as_union_value()),
|
||||
inner_type: msg::Any::StartRes,
|
||||
inner: Some(inner.as_union_value()),
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
|
@ -241,10 +241,10 @@ fn op_code_fetch(
|
|||
data: &'static mut [u8],
|
||||
) -> Box<Op> {
|
||||
assert_eq!(data.len(), 0);
|
||||
let msg = base.msg_as_code_fetch().unwrap();
|
||||
let inner = base.inner_as_code_fetch().unwrap();
|
||||
let cmd_id = base.cmd_id();
|
||||
let module_specifier = msg.module_specifier().unwrap();
|
||||
let containing_file = msg.containing_file().unwrap();
|
||||
let module_specifier = inner.module_specifier().unwrap();
|
||||
let containing_file = inner.containing_file().unwrap();
|
||||
|
||||
assert_eq!(state.dir.root.join("gen"), state.dir.gen, "Sanity check");
|
||||
|
||||
|
@ -263,13 +263,13 @@ fn op_code_fetch(
|
|||
}
|
||||
_ => (),
|
||||
};
|
||||
let msg = msg::CodeFetchRes::create(builder, &msg_args);
|
||||
let inner = msg::CodeFetchRes::create(builder, &msg_args);
|
||||
Ok(serialize_response(
|
||||
cmd_id,
|
||||
builder,
|
||||
msg::BaseArgs {
|
||||
msg: Some(msg.as_union_value()),
|
||||
msg_type: msg::Any::CodeFetchRes,
|
||||
inner: Some(inner.as_union_value()),
|
||||
inner_type: msg::Any::CodeFetchRes,
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
|
@ -283,10 +283,10 @@ fn op_code_cache(
|
|||
data: &'static mut [u8],
|
||||
) -> Box<Op> {
|
||||
assert_eq!(data.len(), 0);
|
||||
let msg = base.msg_as_code_cache().unwrap();
|
||||
let filename = msg.filename().unwrap();
|
||||
let source_code = msg.source_code().unwrap();
|
||||
let output_code = msg.output_code().unwrap();
|
||||
let inner = base.inner_as_code_cache().unwrap();
|
||||
let filename = inner.filename().unwrap();
|
||||
let source_code = inner.source_code().unwrap();
|
||||
let output_code = inner.output_code().unwrap();
|
||||
Box::new(futures::future::result(|| -> OpResult {
|
||||
state.dir.code_cache(filename, source_code, output_code)?;
|
||||
Ok(empty_buf())
|
||||
|
@ -299,8 +299,8 @@ fn op_set_timeout(
|
|||
data: &'static mut [u8],
|
||||
) -> Box<Op> {
|
||||
assert_eq!(data.len(), 0);
|
||||
let msg = base.msg_as_set_timeout().unwrap();
|
||||
let val = msg.timeout() as i64;
|
||||
let inner = base.inner_as_set_timeout().unwrap();
|
||||
let val = inner.timeout() as i64;
|
||||
isolate.timeout_due = if val >= 0 {
|
||||
Some(Instant::now() + Duration::from_millis(val as u64))
|
||||
} else {
|
||||
|
@ -315,9 +315,9 @@ fn op_set_env(
|
|||
data: &'static mut [u8],
|
||||
) -> Box<Op> {
|
||||
assert_eq!(data.len(), 0);
|
||||
let msg = base.msg_as_set_env().unwrap();
|
||||
let key = msg.key().unwrap();
|
||||
let value = msg.value().unwrap();
|
||||
let inner = base.inner_as_set_env().unwrap();
|
||||
let key = inner.key().unwrap();
|
||||
let value = inner.value().unwrap();
|
||||
|
||||
if !state.flags.allow_env {
|
||||
return odd_future(permission_denied());
|
||||
|
@ -355,7 +355,7 @@ fn op_env(
|
|||
)
|
||||
}).collect();
|
||||
let tables = builder.create_vector(&vars);
|
||||
let msg = msg::EnvironRes::create(
|
||||
let inner = msg::EnvironRes::create(
|
||||
builder,
|
||||
&msg::EnvironResArgs {
|
||||
map: Some(tables),
|
||||
|
@ -366,8 +366,8 @@ fn op_env(
|
|||
cmd_id,
|
||||
builder,
|
||||
msg::BaseArgs {
|
||||
msg: Some(msg.as_union_value()),
|
||||
msg_type: msg::Any::EnvironRes,
|
||||
inner: Some(inner.as_union_value()),
|
||||
inner_type: msg::Any::EnvironRes,
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
|
@ -379,10 +379,10 @@ fn op_fetch_req(
|
|||
data: &'static mut [u8],
|
||||
) -> Box<Op> {
|
||||
assert_eq!(data.len(), 0);
|
||||
let msg = base.msg_as_fetch_req().unwrap();
|
||||
let inner = base.inner_as_fetch_req().unwrap();
|
||||
let cmd_id = base.cmd_id();
|
||||
let id = msg.id();
|
||||
let url = msg.url().unwrap();
|
||||
let id = inner.id();
|
||||
let url = inner.url().unwrap();
|
||||
|
||||
if !state.flags.allow_net {
|
||||
return odd_future(permission_denied());
|
||||
|
@ -430,7 +430,7 @@ fn op_fetch_req(
|
|||
let header_values_off =
|
||||
builder.create_vector_of_strings(header_values.as_slice());
|
||||
|
||||
let msg = msg::FetchRes::create(
|
||||
let inner = msg::FetchRes::create(
|
||||
builder,
|
||||
&msg::FetchResArgs {
|
||||
id,
|
||||
|
@ -446,8 +446,8 @@ fn op_fetch_req(
|
|||
cmd_id,
|
||||
builder,
|
||||
msg::BaseArgs {
|
||||
msg: Some(msg.as_union_value()),
|
||||
msg_type: msg::Any::FetchRes,
|
||||
inner: Some(inner.as_union_value()),
|
||||
inner_type: msg::Any::FetchRes,
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
|
@ -495,16 +495,16 @@ fn op_make_temp_dir(
|
|||
) -> Box<Op> {
|
||||
assert_eq!(data.len(), 0);
|
||||
let base = Box::new(*base);
|
||||
let msg = base.msg_as_make_temp_dir().unwrap();
|
||||
let inner = base.inner_as_make_temp_dir().unwrap();
|
||||
let cmd_id = base.cmd_id();
|
||||
|
||||
if !state.flags.allow_write {
|
||||
return odd_future(permission_denied());
|
||||
}
|
||||
|
||||
let dir = msg.dir().map(PathBuf::from);
|
||||
let prefix = msg.prefix().map(String::from);
|
||||
let suffix = msg.suffix().map(String::from);
|
||||
let dir = inner.dir().map(PathBuf::from);
|
||||
let prefix = inner.prefix().map(String::from);
|
||||
let suffix = inner.suffix().map(String::from);
|
||||
|
||||
blocking!(base.sync(), || -> OpResult {
|
||||
// TODO(piscisaureus): use byte vector for paths, not a string.
|
||||
|
@ -518,7 +518,7 @@ fn op_make_temp_dir(
|
|||
)?;
|
||||
let builder = &mut FlatBufferBuilder::new();
|
||||
let path_off = builder.create_string(path.to_str().unwrap());
|
||||
let msg = msg::MakeTempDirRes::create(
|
||||
let inner = msg::MakeTempDirRes::create(
|
||||
builder,
|
||||
&msg::MakeTempDirResArgs {
|
||||
path: Some(path_off),
|
||||
|
@ -529,8 +529,8 @@ fn op_make_temp_dir(
|
|||
cmd_id,
|
||||
builder,
|
||||
msg::BaseArgs {
|
||||
msg: Some(msg.as_union_value()),
|
||||
msg_type: msg::Any::MakeTempDirRes,
|
||||
inner: Some(inner.as_union_value()),
|
||||
inner_type: msg::Any::MakeTempDirRes,
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
|
@ -543,9 +543,9 @@ fn op_mkdir(
|
|||
data: &'static mut [u8],
|
||||
) -> Box<Op> {
|
||||
assert_eq!(data.len(), 0);
|
||||
let msg = base.msg_as_mkdir().unwrap();
|
||||
let mode = msg.mode();
|
||||
let path = String::from(msg.path().unwrap());
|
||||
let inner = base.inner_as_mkdir().unwrap();
|
||||
let mode = inner.mode();
|
||||
let path = String::from(inner.path().unwrap());
|
||||
|
||||
if !state.flags.allow_write {
|
||||
return odd_future(permission_denied());
|
||||
|
@ -565,16 +565,16 @@ fn op_open(
|
|||
) -> Box<Op> {
|
||||
assert_eq!(data.len(), 0);
|
||||
let cmd_id = base.cmd_id();
|
||||
let msg = base.msg_as_open().unwrap();
|
||||
let filename = PathBuf::from(msg.filename().unwrap());
|
||||
// TODO let perm = msg.perm();
|
||||
let inner = base.inner_as_open().unwrap();
|
||||
let filename = PathBuf::from(inner.filename().unwrap());
|
||||
// TODO let perm = inner.perm();
|
||||
|
||||
let op = tokio::fs::File::open(filename)
|
||||
.map_err(|err| DenoError::from(err))
|
||||
.and_then(move |fs_file| -> OpResult {
|
||||
let resource = resources::add_fs_file(fs_file);
|
||||
let builder = &mut FlatBufferBuilder::new();
|
||||
let msg = msg::OpenRes::create(
|
||||
let inner = msg::OpenRes::create(
|
||||
builder,
|
||||
&msg::OpenResArgs {
|
||||
rid: resource.rid,
|
||||
|
@ -585,8 +585,8 @@ fn op_open(
|
|||
cmd_id,
|
||||
builder,
|
||||
msg::BaseArgs {
|
||||
msg: Some(msg.as_union_value()),
|
||||
msg_type: msg::Any::OpenRes,
|
||||
inner: Some(inner.as_union_value()),
|
||||
inner_type: msg::Any::OpenRes,
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
|
@ -620,8 +620,8 @@ fn op_read(
|
|||
data: &'static mut [u8],
|
||||
) -> Box<Op> {
|
||||
let cmd_id = base.cmd_id();
|
||||
let msg = base.msg_as_read().unwrap();
|
||||
let rid = msg.rid();
|
||||
let inner = base.inner_as_read().unwrap();
|
||||
let rid = inner.rid();
|
||||
|
||||
match resources::lookup(rid) {
|
||||
None => odd_future(errors::new(
|
||||
|
@ -633,7 +633,7 @@ fn op_read(
|
|||
.map_err(|err| DenoError::from(err))
|
||||
.and_then(move |(_resource, _buf, nread)| {
|
||||
let builder = &mut FlatBufferBuilder::new();
|
||||
let msg = msg::ReadRes::create(
|
||||
let inner = msg::ReadRes::create(
|
||||
builder,
|
||||
&msg::ReadResArgs {
|
||||
nread: nread as u32,
|
||||
|
@ -645,8 +645,8 @@ fn op_read(
|
|||
cmd_id,
|
||||
builder,
|
||||
msg::BaseArgs {
|
||||
msg: Some(msg.as_union_value()),
|
||||
msg_type: msg::Any::ReadRes,
|
||||
inner: Some(inner.as_union_value()),
|
||||
inner_type: msg::Any::ReadRes,
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
|
@ -662,8 +662,8 @@ fn op_write(
|
|||
data: &'static mut [u8],
|
||||
) -> Box<Op> {
|
||||
let cmd_id = base.cmd_id();
|
||||
let msg = base.msg_as_write().unwrap();
|
||||
let rid = msg.rid();
|
||||
let inner = base.inner_as_write().unwrap();
|
||||
let rid = inner.rid();
|
||||
|
||||
match resources::lookup(rid) {
|
||||
None => odd_future(errors::new(
|
||||
|
@ -676,7 +676,7 @@ fn op_write(
|
|||
.map_err(|err| DenoError::from(err))
|
||||
.and_then(move |(_resource, _buf)| {
|
||||
let builder = &mut FlatBufferBuilder::new();
|
||||
let msg = msg::WriteRes::create(
|
||||
let inner = msg::WriteRes::create(
|
||||
builder,
|
||||
&msg::WriteResArgs {
|
||||
nbyte: len as u32,
|
||||
|
@ -687,8 +687,8 @@ fn op_write(
|
|||
cmd_id,
|
||||
builder,
|
||||
msg::BaseArgs {
|
||||
msg: Some(msg.as_union_value()),
|
||||
msg_type: msg::Any::WriteRes,
|
||||
inner: Some(inner.as_union_value()),
|
||||
inner_type: msg::Any::WriteRes,
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
|
@ -704,9 +704,9 @@ fn op_remove(
|
|||
data: &'static mut [u8],
|
||||
) -> Box<Op> {
|
||||
assert_eq!(data.len(), 0);
|
||||
let msg = base.msg_as_remove().unwrap();
|
||||
let path = PathBuf::from(msg.path().unwrap());
|
||||
let recursive = msg.recursive();
|
||||
let inner = base.inner_as_remove().unwrap();
|
||||
let path = PathBuf::from(inner.path().unwrap());
|
||||
let recursive = inner.recursive();
|
||||
if !state.flags.allow_write {
|
||||
return odd_future(permission_denied());
|
||||
}
|
||||
|
@ -733,17 +733,17 @@ fn op_read_file(
|
|||
data: &'static mut [u8],
|
||||
) -> Box<Op> {
|
||||
assert_eq!(data.len(), 0);
|
||||
let msg = base.msg_as_read_file().unwrap();
|
||||
let inner = base.inner_as_read_file().unwrap();
|
||||
let cmd_id = base.cmd_id();
|
||||
let filename = PathBuf::from(msg.filename().unwrap());
|
||||
let filename = PathBuf::from(inner.filename().unwrap());
|
||||
debug!("op_read_file {}", filename.display());
|
||||
blocking!(base.sync(), || {
|
||||
let vec = fs::read(&filename)?;
|
||||
// Build the response message. memcpy data into msg.
|
||||
// Build the response message. memcpy data into inner.
|
||||
// TODO(ry) zero-copy.
|
||||
let builder = &mut FlatBufferBuilder::new();
|
||||
let data_off = builder.create_vector(vec.as_slice());
|
||||
let msg = msg::ReadFileRes::create(
|
||||
let inner = msg::ReadFileRes::create(
|
||||
builder,
|
||||
&msg::ReadFileResArgs {
|
||||
data: Some(data_off),
|
||||
|
@ -754,8 +754,8 @@ fn op_read_file(
|
|||
cmd_id,
|
||||
builder,
|
||||
msg::BaseArgs {
|
||||
msg: Some(msg.as_union_value()),
|
||||
msg_type: msg::Any::ReadFileRes,
|
||||
inner: Some(inner.as_union_value()),
|
||||
inner_type: msg::Any::ReadFileRes,
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
|
@ -768,9 +768,9 @@ fn op_copy_file(
|
|||
data: &'static mut [u8],
|
||||
) -> Box<Op> {
|
||||
assert_eq!(data.len(), 0);
|
||||
let msg = base.msg_as_copy_file().unwrap();
|
||||
let from = PathBuf::from(msg.from().unwrap());
|
||||
let to = PathBuf::from(msg.to().unwrap());
|
||||
let inner = base.inner_as_copy_file().unwrap();
|
||||
let from = PathBuf::from(inner.from().unwrap());
|
||||
let to = PathBuf::from(inner.to().unwrap());
|
||||
|
||||
if !state.flags.allow_write {
|
||||
return odd_future(permission_denied());
|
||||
|
@ -809,10 +809,10 @@ fn op_stat(
|
|||
data: &'static mut [u8],
|
||||
) -> Box<Op> {
|
||||
assert_eq!(data.len(), 0);
|
||||
let msg = base.msg_as_stat().unwrap();
|
||||
let inner = base.inner_as_stat().unwrap();
|
||||
let cmd_id = base.cmd_id();
|
||||
let filename = PathBuf::from(msg.filename().unwrap());
|
||||
let lstat = msg.lstat();
|
||||
let filename = PathBuf::from(inner.filename().unwrap());
|
||||
let lstat = inner.lstat();
|
||||
|
||||
blocking!(base.sync(), || {
|
||||
let builder = &mut FlatBufferBuilder::new();
|
||||
|
@ -823,7 +823,7 @@ fn op_stat(
|
|||
fs::metadata(&filename)?
|
||||
};
|
||||
|
||||
let msg = msg::StatRes::create(
|
||||
let inner = msg::StatRes::create(
|
||||
builder,
|
||||
&msg::StatResArgs {
|
||||
is_file: metadata.is_file(),
|
||||
|
@ -842,8 +842,8 @@ fn op_stat(
|
|||
cmd_id,
|
||||
builder,
|
||||
msg::BaseArgs {
|
||||
msg: Some(msg.as_union_value()),
|
||||
msg_type: msg::Any::StatRes,
|
||||
inner: Some(inner.as_union_value()),
|
||||
inner_type: msg::Any::StatRes,
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
|
@ -856,9 +856,9 @@ fn op_read_dir(
|
|||
data: &'static mut [u8],
|
||||
) -> Box<Op> {
|
||||
assert_eq!(data.len(), 0);
|
||||
let msg = base.msg_as_read_dir().unwrap();
|
||||
let inner = base.inner_as_read_dir().unwrap();
|
||||
let cmd_id = base.cmd_id();
|
||||
let path = String::from(msg.path().unwrap());
|
||||
let path = String::from(inner.path().unwrap());
|
||||
|
||||
blocking!(base.sync(), || -> OpResult {
|
||||
debug!("op_read_dir {}", path);
|
||||
|
@ -888,7 +888,7 @@ fn op_read_dir(
|
|||
}).collect();
|
||||
|
||||
let entries = builder.create_vector(&entries);
|
||||
let msg = msg::ReadDirRes::create(
|
||||
let inner = msg::ReadDirRes::create(
|
||||
builder,
|
||||
&msg::ReadDirResArgs {
|
||||
entries: Some(entries),
|
||||
|
@ -899,8 +899,8 @@ fn op_read_dir(
|
|||
cmd_id,
|
||||
builder,
|
||||
msg::BaseArgs {
|
||||
msg: Some(msg.as_union_value()),
|
||||
msg_type: msg::Any::ReadDirRes,
|
||||
inner: Some(inner.as_union_value()),
|
||||
inner_type: msg::Any::ReadDirRes,
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
|
@ -912,14 +912,14 @@ fn op_write_file(
|
|||
base: &msg::Base,
|
||||
data: &'static mut [u8],
|
||||
) -> Box<Op> {
|
||||
let msg = base.msg_as_write_file().unwrap();
|
||||
let inner = base.inner_as_write_file().unwrap();
|
||||
|
||||
if !state.flags.allow_write {
|
||||
return odd_future(permission_denied());
|
||||
}
|
||||
|
||||
let filename = String::from(msg.filename().unwrap());
|
||||
let perm = msg.perm();
|
||||
let filename = String::from(inner.filename().unwrap());
|
||||
let perm = inner.perm();
|
||||
|
||||
blocking!(base.sync(), || -> OpResult {
|
||||
debug!("op_write_file {} {}", filename, data.len());
|
||||
|
@ -937,9 +937,9 @@ fn op_rename(
|
|||
if !state.flags.allow_write {
|
||||
return odd_future(permission_denied());
|
||||
}
|
||||
let msg = base.msg_as_rename().unwrap();
|
||||
let oldpath = PathBuf::from(msg.oldpath().unwrap());
|
||||
let newpath = PathBuf::from(msg.newpath().unwrap());
|
||||
let inner = base.inner_as_rename().unwrap();
|
||||
let oldpath = PathBuf::from(inner.oldpath().unwrap());
|
||||
let newpath = PathBuf::from(inner.newpath().unwrap());
|
||||
blocking!(base.sync(), || -> OpResult {
|
||||
debug!("op_rename {} {}", oldpath.display(), newpath.display());
|
||||
fs::rename(&oldpath, &newpath)?;
|
||||
|
@ -961,9 +961,9 @@ fn op_symlink(
|
|||
return odd_future(not_implemented());
|
||||
}
|
||||
|
||||
let msg = base.msg_as_symlink().unwrap();
|
||||
let oldname = PathBuf::from(msg.oldname().unwrap());
|
||||
let newname = PathBuf::from(msg.newname().unwrap());
|
||||
let inner = base.inner_as_symlink().unwrap();
|
||||
let oldname = PathBuf::from(inner.oldname().unwrap());
|
||||
let newname = PathBuf::from(inner.newname().unwrap());
|
||||
blocking!(base.sync(), || -> OpResult {
|
||||
debug!("op_symlink {} {}", oldname.display(), newname.display());
|
||||
#[cfg(any(unix))]
|
||||
|
@ -978,16 +978,16 @@ fn op_read_link(
|
|||
data: &'static mut [u8],
|
||||
) -> Box<Op> {
|
||||
assert_eq!(data.len(), 0);
|
||||
let msg = base.msg_as_readlink().unwrap();
|
||||
let inner = base.inner_as_readlink().unwrap();
|
||||
let cmd_id = base.cmd_id();
|
||||
let name = PathBuf::from(msg.name().unwrap());
|
||||
let name = PathBuf::from(inner.name().unwrap());
|
||||
|
||||
blocking!(base.sync(), || -> OpResult {
|
||||
debug!("op_read_link {}", name.display());
|
||||
let path = fs::read_link(&name)?;
|
||||
let builder = &mut FlatBufferBuilder::new();
|
||||
let path_off = builder.create_string(path.to_str().unwrap());
|
||||
let msg = msg::ReadlinkRes::create(
|
||||
let inner = msg::ReadlinkRes::create(
|
||||
builder,
|
||||
&msg::ReadlinkResArgs {
|
||||
path: Some(path_off),
|
||||
|
@ -998,8 +998,8 @@ fn op_read_link(
|
|||
cmd_id,
|
||||
builder,
|
||||
msg::BaseArgs {
|
||||
msg: Some(msg.as_union_value()),
|
||||
msg_type: msg::Any::ReadlinkRes,
|
||||
inner: Some(inner.as_union_value()),
|
||||
inner_type: msg::Any::ReadlinkRes,
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
|
@ -1017,9 +1017,9 @@ fn op_truncate(
|
|||
return odd_future(permission_denied());
|
||||
}
|
||||
|
||||
let msg = base.msg_as_truncate().unwrap();
|
||||
let filename = String::from(msg.name().unwrap());
|
||||
let len = msg.len();
|
||||
let inner = base.inner_as_truncate().unwrap();
|
||||
let filename = String::from(inner.name().unwrap());
|
||||
let len = inner.len();
|
||||
blocking!(base.sync(), || {
|
||||
debug!("op_truncate {} {}", filename, len);
|
||||
let f = fs::OpenOptions::new().write(true).open(&filename)?;
|
||||
|
|
Loading…
Reference in a new issue