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 module filesystem; | 5 module filesystem; |
6 | 6 |
7 import "components/filesystem/public/interfaces/file.mojom"; | 7 import "components/filesystem/public/interfaces/file.mojom"; |
8 import "components/filesystem/public/interfaces/types.mojom"; | 8 import "components/filesystem/public/interfaces/types.mojom"; |
9 | 9 |
10 // This interface provides access to a directory in a "file system", providing | 10 // This interface provides access to a directory in a "file system", providing |
11 // operations such as creating/opening/removing/renaming files/directories | 11 // operations such as creating/opening/removing/renaming files/directories |
12 // within it. Note that all relative |path| arguments are relative to "this" | 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 | 13 // directory (i.e., "this" directory functions as the current working directory |
14 // for the various operations). | 14 // for the various operations). |
15 // TODO(vtl): Paths may be relative; should they allowed to be absolute? | 15 // TODO(vtl): Paths may be relative; should they allowed to be absolute? |
16 // (Currently not.) | 16 // (Currently not.) |
17 interface Directory { | 17 interface Directory { |
18 // Operations about "this" |Directory|: | 18 // Operations about "this" |Directory|: |
19 | 19 |
20 // Reads the contents of this directory. | 20 // Reads the contents of this directory. |
21 // TODO(vtl): Clarify error codes versus |directory_contents|. | 21 // TODO(vtl): Clarify error codes versus |directory_contents|. |
22 Read() => (Error error, array<DirectoryEntry>? directory_contents); | 22 Read() => (FileError error, array<DirectoryEntry>? directory_contents); |
23 | 23 |
24 // Operations *in* "this" |Directory|: | 24 // Operations *in* "this" |Directory|: |
25 | 25 |
26 // Opens the file specified by |path| with the given |open_flags|. |file| is | 26 // Opens the file specified by |path| with the given |open_flags|. |file| is |
27 // optional, mainly for consistency with |OpenDirectory()| (but may be useful, | 27 // optional, mainly for consistency with |OpenDirectory()| (but may be useful, |
28 // together with |kOpenFlagCreate|, for "touching" a file). | 28 // together with |kOpenFlagCreate|, for "touching" a file). |
29 OpenFile(string path, File&? file, uint32 open_flags) | 29 OpenFile(string path, File&? file, uint32 open_flags) |
30 => (Error error); | 30 => (FileError error); |
31 | 31 |
32 // Opens the directory specified by |path|. |directory| is optional, so that | 32 // Opens the directory specified by |path|. |directory| is optional, so that |
33 // this may be used as a simple "mkdir()" with |kOpenFlagCreate|. | 33 // this may be used as a simple "mkdir()" with |kOpenFlagCreate|. |
34 OpenDirectory(string path, | 34 OpenDirectory(string path, |
35 Directory&? directory, | 35 Directory&? directory, |
36 uint32 open_flags) => (Error error); | 36 uint32 open_flags) => (FileError error); |
37 | 37 |
38 // Renames/moves the file/directory given by |path| to |new_path|. | 38 // Renames/moves the file/directory given by |path| to |new_path|. |
39 Rename(string path, string new_path) => (Error error); | 39 Rename(string path, string new_path) => (FileError error); |
40 | 40 |
41 // Deletes the given path, which may be a file or a directory (see | 41 // Deletes the given path, which may be a file or a directory (see |
42 // |kDeleteFlag...| for details). | 42 // |kDeleteFlag...| for details). |
43 Delete(string path, uint32 delete_flags) => (Error error); | 43 Delete(string path, uint32 delete_flags) => (FileError error); |
44 | 44 |
45 // TODO(vtl): directory "streaming"? | 45 // TODO(vtl): directory "streaming"? |
46 // TODO(vtl): "make root" (i.e., prevent cd-ing, etc., to parent); note that | 46 // TODO(vtl): "make root" (i.e., prevent cd-ing, etc., to parent); note that |
47 // this would require a much more complicated implementation (e.g., it needs | 47 // this would require a much more complicated implementation (e.g., it needs |
48 // to be "inherited" by OpenDirectory(), and the enforcement needs to be valid | 48 // to be "inherited" by OpenDirectory(), and the enforcement needs to be valid |
49 // even if the opened directory is subsequently moved -- e.g., closer to the | 49 // even if the opened directory is subsequently moved -- e.g., closer to the |
50 // "root") | 50 // "root") |
51 // TODO(vtl): Add a "watch"? | 51 // TODO(vtl): Add a "watch"? |
52 }; | 52 }; |
OLD | NEW |