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 //FIXME FIXME FIXME: 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 // - timestamps are int64, milliseconds since Unix epoch (i.e., dubious) | |
10 | |
11 module mojo.files; | |
12 | |
13 import "services/file_manager/types.mojom"; | |
14 | |
15 interface File { | |
16 Close() => (Error err); | |
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 ReadStream(handle<data_pipe_producer> source, int64 offset, Whence whence) | |
qsr
2015/02/06 10:54:55
When does those returns in a non error case? When
viettrungluu
2015/02/06 16:57:36
Hmmm, that's a good question.
I was imagining tha
| |
24 => (Error error); | |
25 WriteStream(handle<data_pipe_consumer> sink, int64 offset, Whence whence) | |
26 => (Error error); | |
27 | |
28 Tell() => (Error error, int64 position); | |
29 Seek(int64 offset, Whence whence) => (Error error, int64 position); | |
30 | |
31 Stat() => (Error error, FileInformation? file_information); | |
32 Truncate(int64 size) => (Error error); | |
33 // TODO(vtl): null |times| means "now" (for both atime and mtime). | |
34 Touch(FileTimes? times) => (Error error); | |
35 | |
36 // TODO(vtl): |Dup()| shares the same file description (i.e., mode and | |
37 // position). | |
38 Dup(File& file) => (Error error); | |
39 // TODO(vtl): What are the rules for reopening (w.r.t. changing mode/flags). | |
40 // E.g., obviously can go from "read-write" to "read", but reverse? (probably | |
41 // not), can remove "append"? (probably not?). Do we allow "truncate"? | |
42 Reopen(File& file, uint32 access_flags, uint32 open_flags) | |
43 => (Error error); | |
abarth-chromium
2015/02/06 04:38:35
I imagine we'll want to be able to pass Files to o
viettrungluu
2015/02/06 06:20:41
Right. The more confusing ones are "append", etc.
| |
44 | |
45 // TODO(vtl): probably should have access flags (but also exec?); how do these | |
46 // relate to access mode? | |
47 AsBuffer() => (Error error, handle<shared_buffer>? buffer); | |
48 | |
49 // TODO(vtl): Add a "watch"? | |
50 }; | |
OLD | NEW |