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 module mojo.files; | |
6 | |
7 import "services/files/file.mojom"; | |
8 import "services/files/types.mojom"; | |
9 | |
10 // This interface provides access to a directory in a "file system", providing | |
11 // operations such as creating/opening/removing/renaming files/directories | |
12 // within it. Note that all relative |path| arguments are relative to "this" | |
13 // directory (i.e., "this" directory functions as the current working directory | |
14 // for the various operations). | |
15 // TODO(vtl): Paths may be relative; should they allowed to be absolute? | |
16 // (Currently not.) | |
17 interface Directory { | |
18 // Operations about "this" |Directory|: | |
19 | |
20 // Reads the contents of this directory. | |
21 // TODO(vtl): Clarify error codes versus |directory_contents|. | |
22 Read() => (Error error, array<DirectoryEntry>? directory_contents); | |
23 | |
24 // Gets information about this directory. On success, |file_information| is | |
25 // non-null and will contain this information. | |
26 Stat() => (Error error, FileInformation? file_information); | |
27 | |
28 // Updates this directory's atime and/or mtime to the time specified by | |
29 // |atime| (or |mtime|, respectively), which may also indicate "now". If | |
30 // |atime| or |mtime| is null, then the corresponding time is not modified. | |
31 Touch(TimespecOrNow? atime, TimespecOrNow? mtime) => (Error error); | |
32 | |
33 // Operations *in* "this" |Directory|: | |
34 | |
35 // Opens the file specified by |path| with the given |open_flags|. |file| is | |
36 // optional, mainly for consistency with |OpenDirectory()| (but may be useful, | |
37 // together with |kOpenFlagCreate|, for "touching" a file). | |
38 OpenFile(string path, File&? file, uint32 open_flags) | |
39 => (Error error); | |
40 | |
41 // Opens the directory specified by |path|. |directory| is optional, so that | |
42 // this may be used as a simple "mkdir()" with |kOpenFlagCreate|. | |
43 OpenDirectory(string path, | |
44 Directory&? directory, | |
45 uint32 open_flags) => (Error error); | |
46 | |
47 // Renames/moves the file/directory given by |path| to |new_path|. | |
48 Rename(string path, string new_path) => (Error error); | |
49 | |
50 // Deletes the given path, which may be a file or a directory (see | |
51 // |kDeleteFlag...| for details). | |
52 Delete(string path, uint32 delete_flags) => (Error error); | |
53 | |
54 // TODO(vtl): directory "streaming"? | |
55 // TODO(vtl): "make root" (i.e., prevent cd-ing, etc., to parent); note that | |
56 // this would require a much more complicated implementation (e.g., it needs | |
57 // to be "inherited" by OpenDirectory(), and the enforcement needs to be valid | |
58 // even if the opened directory is subsequently moved -- e.g., closer to the | |
59 // "root") | |
60 // TODO(vtl): Add a "watch"? | |
61 // TODO(vtl): Should we have a "close" method? | |
62 // TODO(vtl): Add Dup() and Reopen() (like File)? | |
63 }; | |
OLD | NEW |