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) | |
darin (slow to review)
2015/02/06 23:36:11
nit: maybe this should be called ReadToStream? sho
vtl
2015/02/06 23:51:50
Maybe?
darin (slow to review)
2015/02/07 00:05:53
OK, yes... I got myself confused. The name ReadStr
| |
24 => (Error error); | |
25 WriteStream(handle<data_pipe_consumer> sink, int64 offset, Whence whence) | |
26 => (Error error); | |
27 | |
28 Tell() => (Error error, int64 position); | |
darin (slow to review)
2015/02/06 23:36:11
is the point of these to enable some read-ahead op
vtl
2015/02/06 23:51:49
If you want to support POSIX-ish/standard C librar
darin (slow to review)
2015/02/07 00:05:53
OK, I see.
| |
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); | |
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); | |
darin (slow to review)
2015/02/06 23:36:11
how about Read/Write variants that take a SHM hand
vtl
2015/02/06 23:51:49
They don't have to map the entire file (buffer han
darin (slow to review)
2015/02/07 00:05:53
I see.
| |
48 | |
49 // TODO(vtl): Add a "watch"? | |
50 }; | |
OLD | NEW |