Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // TODO(vtl): notes to self: | |
| 6 // - file offsets, file positions, and file sizes are int64 (though positions | |
| 7 // and sizes must always be non-negative) | |
| 8 // - buffer size parameters (for read/write) are uint32 | |
| 9 | |
| 10 module mojo.files; | |
| 11 | |
| 12 import "services/files/types.mojom"; | |
| 13 | |
| 14 // TODO(vtl): Write comments. | |
| 15 interface File { | |
| 16 Close() => (Error err); | |
|
qsr
2015/03/02 12:46:40
What can you do with a connected closed file? If n
viettrungluu
2015/03/02 18:10:59
Not very much.
qsr
2015/03/03 11:56:44
Ok
viettrungluu
2015/03/03 18:50:35
I meant that it's similar in effect to closing the
| |
| 17 | |
| 18 Read(uint32 num_bytes_to_read, int64 offset, Whence whence) | |
| 19 => (Error error, array<uint8>? bytes_read); | |
| 20 Write(array<uint8> bytes_to_write, int64 offset, Whence whence) | |
| 21 => (Error error, uint32 num_bytes_written); | |
| 22 | |
| 23 // TODO(vtl): We definitely want 64 bits for |num_bytes_to_read|; but do we | |
| 24 // want it to be signed (this is consistent with |size| values, but | |
| 25 // inconsistent with 32-bit |num_bytes_to_read| values)? Do we want to have | |
| 26 // separate "read to end" versus "tail" (i.e., keep on reading as more data is | |
| 27 // appended) modes, and how would those be signalled? | |
|
qsr
2015/03/02 12:46:40
Do you also need a special value of no limit?
viettrungluu
2015/03/02 18:10:59
See TODO above -- we need TWO special values!
| |
| 28 ReadToStream(handle<data_pipe_producer> source, | |
| 29 int64 offset, | |
| 30 Whence whence, | |
| 31 int64 num_bytes_to_read) => (Error error); | |
| 32 WriteFromStream(handle<data_pipe_consumer> sink, int64 offset, Whence whence) | |
| 33 => (Error error); | |
| 34 | |
| 35 Tell() => (Error error, int64 position); | |
| 36 Seek(int64 offset, Whence whence) => (Error error, int64 position); | |
| 37 | |
| 38 Stat() => (Error error, FileInformation? file_information); | |
| 39 Truncate(int64 size) => (Error error); | |
| 40 // TODO(vtl): null |times| means "now" (for both atime and mtime). | |
|
qsr
2015/03/02 12:46:40
Isn't the comment outdated? You have way to specif
viettrungluu
2015/03/02 18:10:59
Done.
| |
| 41 Touch(TimespecOrNow? atime, TimespecOrNow? mtime) => (Error error); | |
| 42 | |
| 43 // TODO(vtl): |Dup()| shares the same file description (i.e., mode and | |
| 44 // position). | |
| 45 Dup(File& file) => (Error error); | |
| 46 // TODO(vtl): What are the rules for reopening (w.r.t. changing mode/flags). | |
| 47 // E.g., obviously can go from "read-write" to "read", but reverse? (probably | |
| 48 // not), can remove "append"? (probably not?). Do we allow "truncate"? | |
| 49 Reopen(File& file, uint32 open_flags) => (Error error); | |
| 50 | |
| 51 // TODO(vtl): probably should have access flags (but also exec?); how do these | |
| 52 // relate to access mode? | |
| 53 AsBuffer() => (Error error, handle<shared_buffer>? buffer); | |
| 54 | |
| 55 // TODO(vtl): Add a "watch"? | |
| 56 }; | |
| OLD | NEW |