Closed Bug 655168 Opened 14 years ago Closed 14 years ago

add facilities to read binary files in the shell

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: gal, Assigned: gal)

References

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file)

Syntax: snarf(path, "binary") => returns a Uint8Array with the binary data
Attached patch patchSplinter Review
Assignee: general → gal
Comment on attachment 530452 [details] [diff] [review] patch Review of attachment 530452 [details] [diff] [review]: Yay for shell functionality! ::: js/src/shell/js.cpp @@ +1168,5 @@ + return NULL; + } + + JSObject *obj = NULL; + if (fseek(file, 0, SEEK_END) == EOF) { Nonzero instead of EOF? C99 spec just says "The fseek function returns nonzero only for a request that cannot be satisfied." for this and ftell. @@ +4505,5 @@ + JS_GUARD_OBJECT_NOTIFIER_INIT; + } + + ~FreeOnReturn() { +#ifdef XP_UNIX FreeOnReturn class that only frees on XP_UNIX should probably be called either XPFreeOnReturn or you should pass an |enable| bool to the constructor that's the value of defined(XP_UNIX). @@ +4535,5 @@ #ifdef XP_UNIX pathname = MakeAbsolutePathname(cx, script->filename, filename.ptr()); if (!pathname) return JS_FALSE; + FreeOnReturn _(cx, pathname); I think _ is technically an illegal variable name. "Each name that begins with an underscore is reserved to the implementation for use as a name in the global namespace." pnGuard?
Attachment #530452 - Flags: review+
Comment on attachment 530452 [details] [diff] [review] patch Review of attachment 530452 [details] [diff] [review]: ::: js/src/shell/js.cpp @@ +4535,5 @@ #ifdef XP_UNIX pathname = MakeAbsolutePathname(cx, script->filename, filename.ptr()); if (!pathname) return JS_FALSE; + FreeOnReturn _(cx, pathname); "in the global namespace", right? This is inside a function. I think it's safe to use here, by that language, if I understand it correctly.
Whiteboard: fixed-in-tracemonkey
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Blocks: 657891
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: