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