Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: components/filesystem/public/interfaces/types.mojom

Issue 1158253002: mandoline filesystem: Rewrite using base::File. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Get the error from the right object. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/filesystem/public/interfaces/file.mojom ('k') | components/filesystem/shared_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Error codes used by the file manager. 7 // Error codes used by the file system. These error codes line up exactly with
8 // TODO(vtl): Add more (to, e.g., cover all of errno). 8 // those of base::File.
9 enum Error { 9 enum Error {
10 OK = 0, 10 OK = 0,
11 UNKNOWN, 11 FAILED = -1,
12 INVALID_ARGUMENT, 12 IN_USE = -2,
13 PERMISSION_DENIED, 13 EXISTS = -3,
14 OUT_OF_RANGE, 14 NOT_FOUND = -4,
15 UNIMPLEMENTED, 15 ACCESS_DENIED = -5,
16 CLOSED, 16 TOO_MANY_OPENED = -6,
17 UNAVAILABLE, 17 NO_MEMORY = -7,
18 INTERNAL, 18 NO_SPACE = -8,
19 NOT_A_DIRECTORY = -9,
20 INVALID_OPERATION = -10,
21 SECURITY = -11,
22 ABORT = -12,
23 NOT_A_FILE = -13,
24 NOT_EMPTY = -14,
25 INVALID_URL = -15,
26 IO = -16,
19 }; 27 };
20 28
21 // Used to explain the meaning of an offset within a file. 29 // Used to explain the meaning of an offset within a file. These values line up
30 // exactly with base::File.
22 enum Whence { 31 enum Whence {
32 // Offset is relative to the beginning of the file.
33 FROM_BEGIN = 0,
23 // Offset is from current position in the file. 34 // Offset is from current position in the file.
24 FROM_CURRENT = 0, 35 FROM_CURRENT = 1,
25 // Offset is relative to the beginning of the file.
26 FROM_START,
27 // Offset is relative to the end of the file. 36 // Offset is relative to the end of the file.
28 FROM_END, 37 FROM_END = 2
29 };
30
31 // Describes (idealized) wall-clock time, since Unix epoch (i.e., since
32 // "1970-01-01 00:00 UTC", ignoring leap seconds and that UTC as we know it
33 // started in 1972).
34 // TODO(vtl): Should probably be moved out of mojo.files (maybe to mojo.time?).
35 struct Timespec {
36 int64 seconds;
37 int32 nanoseconds; // Always in the interval [0, 10^9).
38 }; 38 };
39 39
40 // Used for |Touch()| calls. If |now| is set, |timespec| must be null (the time 40 // Used for |Touch()| calls. If |now| is set, |timespec| must be null (the time
41 // "now" will be used). Otherwise, |timespec| must not be null. 41 // "now" will be used). Otherwise, |timespec| must not be null.
42 // TODO(vtl): Use a union instead, when that becomes possible. 42 // TODO(vtl): Use a union instead, when that becomes possible.
43 struct TimespecOrNow { 43 struct TimespecOrNow {
44 bool now; 44 bool now;
45 Timespec? timespec; 45 double seconds;
46 }; 46 };
47 47
48 // Describes various information about a file or directory (for |Stat()|). Note 48 // Describes various information about a file or directory (for |Stat()|). Note
49 // that access/modification times may be set arbitrarily (by those with 49 // that access/modification times may be set arbitrarily (by those with
50 // appropriate capabilities) and may not reflect reality. 50 // appropriate capabilities) and may not reflect reality.
51 struct FileInformation { 51 struct FileInformation {
52 // Type of the file. 52 // Type of the file.
53 FileType type; 53 FileType type;
54 // Size of the file, in bytes. Zero for directories. 54 // Size of the file, in bytes. Zero for directories.
55 int64 size; 55 int64 size;
56 // Last access time, if available/supported. 56 // Last access time, in seconds since Unix Epoch.
57 Timespec? atime; 57 double atime;
58 // Last modification time, if available/supported. 58 // Last modification time, in seconds since Unix Epoch.
59 Timespec? mtime; 59 double mtime;
60 // Create time of the file, in seconds since Unix Epoch.
61 double ctime;
60 }; 62 };
61 63
62 // File and directory open flags (at least one of |kOpenFlagRead| and 64 // File and directory open flags. Is a limited subset of base::File::Flags. Thes e
63 // |kOpenFlagWrite| is required): 65 // are constants instead of enums so that they are bitwise OR-able.
64 // Opens the file/directory for reading. 66
65 const uint32 kOpenFlagRead = 0x1; 67 // Opens a file, only if it exists.
66 // Opens the file/directory for writing. 68 const uint32 kFlagOpen = 0x1;
67 const uint32 kOpenFlagWrite = 0x2; 69 // Creates a new file, only if it does not already exist.
68 // Only meaningful together with |kOpenFlagWrite|: creates the file if 70 const uint32 kFlagCreate = 0x2;
69 // necessary. 71 // May create a new file.
70 const uint32 kOpenFlagCreate = 0x4; 72 const uint32 kFlagOpenAlways = 0x4;
71 // Only meaningful together with |kOpenFlagCreate|: requires file/directory to 73 // May overwrite an old file.
72 // be created, failing if it already exists. 74 const uint32 kCreateAlways = 0x8;
73 const uint32 kOpenFlagExclusive = 0x8; 75 // Opens a file and truncates it, only if it exists.
74 // Only meaningful for files, together with |kOpenFlagWrite|: writes will always 76 const uint32 kFlagOpenTruncated = 0x10;
75 // append to the file. 77 const uint32 kFlagRead = 0x20;
76 const uint32 kOpenFlagAppend = 0x10; 78 const uint32 kFlagWrite = 0x40;
77 // Only meaningful for files, together with |kOpenFlagWrite|: truncates the 79 const uint32 kFlagAppend = 0x80;
78 // file.
79 const uint32 kOpenFlagTruncate = 0x20;
80 80
81 // File types. 81 // File types.
82 enum FileType { 82 enum FileType {
83 UNKNOWN = 0, 83 UNKNOWN = 0,
84 REGULAR_FILE, 84 REGULAR_FILE,
85 DIRECTORY, 85 DIRECTORY,
86 }; 86 };
87 87
88 // Describes a directory entry (i.e., a single member of a directory). 88 // Describes a directory entry (i.e., a single member of a directory).
89 struct DirectoryEntry { 89 struct DirectoryEntry {
90 FileType type; 90 FileType type;
91 string name; 91 string name;
92 }; 92 };
93 93
94 // Deletion flags: 94 // Deletion flags:
95 // Only delete if the path refers to a file/non-directory (by default, will 95 // Recursively delete.
96 // delete files and directories). 96 const uint32 kDeleteFlagRecursive = 0x1;
97 const uint32 kDeleteFlagFileOnly = 0x1;
98 // Only delete if the path refers to a directory.
99 const uint32 kDeleteFlagDirectoryOnly = 0x2;
100 // Recursively delete (neither of the two flags above may be specified).
101 const uint32 kDeleteFlagRecursive = 0x4;
OLDNEW
« no previous file with comments | « components/filesystem/public/interfaces/file.mojom ('k') | components/filesystem/shared_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698