| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO(vtl): notes to self: | 5 // TODO(vtl): notes to self: |
| 6 // - file offsets, file positions, and file sizes are int64 (though positions | 6 // - file offsets, file positions, and file sizes are int64 (though positions |
| 7 // and sizes must always be non-negative) | 7 // and sizes must always be non-negative) |
| 8 // - buffer size parameters (for read/write) are uint32 | 8 // - buffer size parameters (for read/write) are uint32 |
| 9 | 9 |
| 10 module filesystem; | 10 module filesystem; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // modifies the file position. Or maybe there should be a flag? | 26 // modifies the file position. Or maybe there should be a flag? |
| 27 Read(uint32 num_bytes_to_read, int64 offset, Whence whence) | 27 Read(uint32 num_bytes_to_read, int64 offset, Whence whence) |
| 28 => (Error error, array<uint8>? bytes_read); | 28 => (Error error, array<uint8>? bytes_read); |
| 29 | 29 |
| 30 // Writes |bytes_to_write| to the location specified by |offset|/|whence|. | 30 // Writes |bytes_to_write| to the location specified by |offset|/|whence|. |
| 31 // TODO(vtl): Clarify behavior when |num_bytes_written| is less than the size | 31 // TODO(vtl): Clarify behavior when |num_bytes_written| is less than the size |
| 32 // of |bytes_to_write|. | 32 // of |bytes_to_write|. |
| 33 Write(array<uint8> bytes_to_write, int64 offset, Whence whence) | 33 Write(array<uint8> bytes_to_write, int64 offset, Whence whence) |
| 34 => (Error error, uint32 num_bytes_written); | 34 => (Error error, uint32 num_bytes_written); |
| 35 | 35 |
| 36 // TODO(vtl): We definitely want 64 bits for |num_bytes_to_read|; but do we | 36 // TODO(erg): Add stream variants of Read()/Write(). |
| 37 // want it to be signed (this is consistent with |size| values, but | |
| 38 // inconsistent with 32-bit |num_bytes_to_read| values)? Do we want to have | |
| 39 // separate "read to end" versus "tail" (i.e., keep on reading as more data is | |
| 40 // appended) modes, and how would those be signalled? | |
| 41 ReadToStream(handle<data_pipe_producer> source, | |
| 42 int64 offset, | |
| 43 Whence whence, | |
| 44 int64 num_bytes_to_read) => (Error error); | |
| 45 WriteFromStream(handle<data_pipe_consumer> sink, int64 offset, Whence whence) | |
| 46 => (Error error); | |
| 47 | 37 |
| 48 // Gets the current file position. On success, |position| is the current | 38 // Gets the current file position. On success, |position| is the current |
| 49 // offset (in bytes) from the beginning of the file). | 39 // offset (in bytes) from the beginning of the file). |
| 50 Tell() => (Error error, int64 position); | 40 Tell() => (Error error, int64 position); |
| 51 | 41 |
| 52 // Sets the current file position to that specified by |offset|/|whence|. On | 42 // Sets the current file position to that specified by |offset|/|whence|. On |
| 53 // success, |position| is the offset (in bytes) from the beginning of the | 43 // success, |position| is the offset (in bytes) from the beginning of the |
| 54 // file. | 44 // file. |
| 55 Seek(int64 offset, Whence whence) => (Error error, int64 position); | 45 Seek(int64 offset, Whence whence) => (Error error, int64 position); |
| 56 | 46 |
| 57 // Gets information about this file. On success, |file_information| is | 47 // Gets information about this file. On success, |file_information| is |
| 58 // non-null and will contain this information. | 48 // non-null and will contain this information. |
| 59 Stat() => (Error error, FileInformation? file_information); | 49 Stat() => (Error error, FileInformation? file_information); |
| 60 | 50 |
| 61 // Truncates this file to the size specified by |size| (in bytes). | 51 // Truncates this file to the size specified by |size| (in bytes). |
| 62 Truncate(int64 size) => (Error error); | 52 Truncate(int64 size) => (Error error); |
| 63 | 53 |
| 64 // Updates this file's atime and/or mtime to the time specified by |atime| (or | 54 // Updates this file's atime and/or mtime to the time specified by |atime| (or |
| 65 // |mtime|, respectively), which may also indicate "now". If |atime| or | 55 // |mtime|, respectively), which may also indicate "now". If |atime| or |
| 66 // |mtime| is null, then the corresponding time is not modified. | 56 // |mtime| is null, then the corresponding time is not modified. |
| 67 Touch(TimespecOrNow? atime, TimespecOrNow? mtime) => (Error error); | 57 Touch(TimespecOrNow? atime, TimespecOrNow? mtime) => (Error error); |
| 68 | 58 |
| 69 // Creates a new |File| instance, which shares the same "file description". | 59 // Creates a new |File| instance, which shares the same "file description". |
| 70 // I.e., the access mode, etc. (as specified to |Directory::OpenFile()| by the | 60 // I.e., the access mode, etc. (as specified to |Directory::OpenFile()| by the |
| 71 // |open_flags| argument) as well as file position. | 61 // |open_flags| argument) as well as file position. |
| 72 Dup(File& file) => (Error error); | 62 Dup(File& file) => (Error error); |
| 73 | |
| 74 // TODO(vtl): What are the rules for reopening (w.r.t. changing mode/flags). | |
| 75 // E.g., obviously can go from "read-write" to "read", but reverse? (probably | |
| 76 // not), can remove "append"? (probably not?). Do we allow "truncate"? | |
| 77 Reopen(File& file, uint32 open_flags) => (Error error); | |
| 78 | |
| 79 // TODO(vtl): probably should have access flags (but also exec?); how do these | |
| 80 // relate to access mode? | |
| 81 AsBuffer() => (Error error, handle<shared_buffer>? buffer); | |
| 82 | |
| 83 // Special-file-specific control function, for device "files". |in| and |out| | |
| 84 // are dependent on |request|. | |
| 85 // TODO(vtl): Make a master list of request values somewhere. | |
| 86 Ioctl(uint32 request, array<uint32>? in_values) | |
| 87 => (Error error, array<uint32>? out_values); | |
| 88 | |
| 89 // TODO(vtl): Add a "watch"? | |
| 90 // TODO(vtl): Add something analogous to fsync(2)? | |
| 91 }; | 63 }; |
| OLD | NEW |