| 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 struct FileOpenDetails { |
| 11 string path; |
| 12 uint32 open_flags; |
| 13 }; |
| 14 |
| 15 struct FileOpenResult { |
| 16 string path; |
| 17 FileError error; |
| 18 handle file_handle; |
| 19 }; |
| 20 |
| 10 // This interface provides access to a directory in a "file system", providing | 21 // This interface provides access to a directory in a "file system", providing |
| 11 // operations such as creating/opening/removing/renaming files/directories | 22 // operations such as creating/opening/removing/renaming files/directories |
| 12 // within it. Note that all relative |path| arguments are relative to "this" | 23 // within it. Note that all relative |path| arguments are relative to "this" |
| 13 // directory (i.e., "this" directory functions as the current working directory | 24 // directory (i.e., "this" directory functions as the current working directory |
| 14 // for the various operations). | 25 // for the various operations). |
| 15 // TODO(vtl): Paths may be relative; should they allowed to be absolute? | 26 // TODO(vtl): Paths may be relative; should they allowed to be absolute? |
| 16 // (Currently not.) | 27 // (Currently not.) |
| 17 interface Directory { | 28 interface Directory { |
| 18 // Operations about "this" |Directory|: | 29 // Operations about "this" |Directory|: |
| 19 | 30 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 30 [Sync] | 41 [Sync] |
| 31 OpenFile(string path, File&? file, uint32 open_flags) | 42 OpenFile(string path, File&? file, uint32 open_flags) |
| 32 => (FileError error); | 43 => (FileError error); |
| 33 | 44 |
| 34 // Opens the file specified by |path| with the given |open_flags|. Returns a | 45 // Opens the file specified by |path| with the given |open_flags|. Returns a |
| 35 // native file descriptor wrapped in a MojoHandle. | 46 // native file descriptor wrapped in a MojoHandle. |
| 36 [Sync] | 47 [Sync] |
| 37 OpenFileHandle(string path, uint32 open_flags) | 48 OpenFileHandle(string path, uint32 open_flags) |
| 38 => (FileError error, handle file_handle); | 49 => (FileError error, handle file_handle); |
| 39 | 50 |
| 51 // Like OpenFileHandle, but opens multiple files. |
| 52 [Sync] |
| 53 OpenFileHandles(array<FileOpenDetails> files) |
| 54 => (array<FileOpenResult> results); |
| 55 |
| 40 // Opens the directory specified by |path|. |directory| is optional, so that | 56 // Opens the directory specified by |path|. |directory| is optional, so that |
| 41 // this may be used as a simple "mkdir()" with |kOpenFlagCreate|. | 57 // this may be used as a simple "mkdir()" with |kOpenFlagCreate|. |
| 42 [Sync] | 58 [Sync] |
| 43 OpenDirectory(string path, | 59 OpenDirectory(string path, |
| 44 Directory&? directory, | 60 Directory&? directory, |
| 45 uint32 open_flags) => (FileError error); | 61 uint32 open_flags) => (FileError error); |
| 46 | 62 |
| 47 // Renames/moves the file/directory given by |path| to |new_path|. | 63 // Renames/moves the file/directory given by |path| to |new_path|. |
| 48 [Sync] | 64 [Sync] |
| 49 Rename(string path, string new_path) => (FileError error); | 65 Rename(string path, string new_path) => (FileError error); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 WriteFile(string path, array<uint8> data) => (FileError error); | 97 WriteFile(string path, array<uint8> data) => (FileError error); |
| 82 | 98 |
| 83 // TODO(vtl): directory "streaming"? | 99 // TODO(vtl): directory "streaming"? |
| 84 // TODO(vtl): "make root" (i.e., prevent cd-ing, etc., to parent); note that | 100 // TODO(vtl): "make root" (i.e., prevent cd-ing, etc., to parent); note that |
| 85 // this would require a much more complicated implementation (e.g., it needs | 101 // this would require a much more complicated implementation (e.g., it needs |
| 86 // to be "inherited" by OpenDirectory(), and the enforcement needs to be valid | 102 // to be "inherited" by OpenDirectory(), and the enforcement needs to be valid |
| 87 // even if the opened directory is subsequently moved -- e.g., closer to the | 103 // even if the opened directory is subsequently moved -- e.g., closer to the |
| 88 // "root") | 104 // "root") |
| 89 // TODO(vtl): Add a "watch"? | 105 // TODO(vtl): Add a "watch"? |
| 90 }; | 106 }; |
| OLD | NEW |