Closed Bug 769191 Opened 12 years ago Closed 12 years ago

[OS.File] read and write should accept a default length

Categories

(Toolkit Graveyard :: OS.File, defect)

defect
Not set
trivial

Tracking

(Not tracked)

RESOLVED FIXED
mozilla18

People

(Reporter: Yoric, Assigned: Yoric)

References

Details

Attachments

(1 file, 2 obsolete files)

Common scenario: let a = new ArrayBuffer(21); let file = OS.File.open(...) file.read(a, a.byteLength); If no length is given, we should use the length of the array buffer.
Assignee: nobody → dteller
Attachment #637423 - Flags: review?(taras.mozilla)
Comment on attachment 637423 [details] [diff] [review] Default arguments of OS.File.prototype.read/write bugzilla is failing so I can't see the patch, but this makes sense
Attachment #637423 - Flags: review?(taras.mozilla) → review+
Doing this differently.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → DUPLICATE
Attachment #637423 - Attachment is obsolete: true
Attachment #656581 - Flags: review?(nfroyd)
Status: RESOLVED → REOPENED
Resolution: DUPLICATE → ---
Component: Networking: File → OS.File
Product: Core → Toolkit
Comment on attachment 656581 [details] [diff] [review] Default arguments for AbstractFile.prototype.{readTo, write} Review of attachment 656581 [details] [diff] [review]: ----------------------------------------------------------------- Somewhere in worker_test_osfile_front.js it would be good to add a test for C pointer without options.bytes, for both readTo and write, to check that the error is thrown correctly. ::: toolkit/components/osfile/osfile_shared_front.jsm @@ +166,5 @@ > throw new TypeError("Expecting a non-null pointer"); > } > ptr = exports.OS.Shared.Type.uint8_t.out_ptr.cast(candidate); > + if (bytes == null) { > + throw new TypeError("This function expects either an ArrayBuffer or a C pointer and a number of bytes."); I think this error message should indicate that |bytes| is required with a C pointer and shouldn't talk about ArrayBuffers; this is the pointer case, after all.
Attachment #656581 - Flags: review?(nfroyd) → review+
Added default arguments and changed error message.
Attachment #656581 - Attachment is obsolete: true
Attachment #656996 - Flags: review+
Hum, I meant "added *test* for default arguments".
Whiteboard: [land after bug 780483]
Status: REOPENED → RESOLVED
Closed: 12 years ago12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla18
Product: Toolkit → Toolkit Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: