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