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 // Error codes used by the file system. These error codes line up exactly with | 7 // Error codes used by the file system. These error codes line up exactly with |
8 // those of base::File. | 8 // those of base::File. |
9 enum Error { | 9 enum FileError { |
10 OK = 0, | 10 OK = 0, |
11 FAILED = -1, | 11 FAILED = -1, |
12 IN_USE = -2, | 12 IN_USE = -2, |
13 EXISTS = -3, | 13 EXISTS = -3, |
14 NOT_FOUND = -4, | 14 NOT_FOUND = -4, |
15 ACCESS_DENIED = -5, | 15 ACCESS_DENIED = -5, |
16 TOO_MANY_OPENED = -6, | 16 TOO_MANY_OPENED = -6, |
17 NO_MEMORY = -7, | 17 NO_MEMORY = -7, |
18 NO_SPACE = -8, | 18 NO_SPACE = -8, |
19 NOT_A_DIRECTORY = -9, | 19 NOT_A_DIRECTORY = -9, |
(...skipping 23 matching lines...) Expand all Loading... |
43 struct TimespecOrNow { | 43 struct TimespecOrNow { |
44 bool now; | 44 bool now; |
45 double seconds; | 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 FsFileType 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, in seconds since Unix Epoch. | 56 // Last access time, in seconds since Unix Epoch. |
57 double atime; | 57 double atime; |
58 // Last modification time, in seconds since Unix Epoch. | 58 // Last modification time, in seconds since Unix Epoch. |
59 double mtime; | 59 double mtime; |
60 // Create time of the file, in seconds since Unix Epoch. | 60 // Create time of the file, in seconds since Unix Epoch. |
61 double ctime; | 61 double ctime; |
62 }; | 62 }; |
63 | 63 |
64 // File and directory open flags. Is a limited subset of base::File::Flags. Thes
e | 64 // File and directory open flags. Is a limited subset of base::File::Flags. Thes
e |
65 // are constants instead of enums so that they are bitwise OR-able. | 65 // are constants instead of enums so that they are bitwise OR-able. |
66 | 66 |
67 // Opens a file, only if it exists. | 67 // Opens a file, only if it exists. |
68 const uint32 kFlagOpen = 0x1; | 68 const uint32 kFlagOpen = 0x1; |
69 // Creates a new file, only if it does not already exist. | 69 // Creates a new file, only if it does not already exist. |
70 const uint32 kFlagCreate = 0x2; | 70 const uint32 kFlagCreate = 0x2; |
71 // May create a new file. | 71 // May create a new file. |
72 const uint32 kFlagOpenAlways = 0x4; | 72 const uint32 kFlagOpenAlways = 0x4; |
73 // May overwrite an old file. | 73 // May overwrite an old file. |
74 const uint32 kCreateAlways = 0x8; | 74 const uint32 kCreateAlways = 0x8; |
75 // Opens a file and truncates it, only if it exists. | 75 // Opens a file and truncates it, only if it exists. |
76 const uint32 kFlagOpenTruncated = 0x10; | 76 const uint32 kFlagOpenTruncated = 0x10; |
77 const uint32 kFlagRead = 0x20; | 77 const uint32 kFlagRead = 0x20; |
78 const uint32 kFlagWrite = 0x40; | 78 const uint32 kFlagWrite = 0x40; |
79 const uint32 kFlagAppend = 0x80; | 79 const uint32 kFlagAppend = 0x80; |
80 | 80 |
81 // File types. | 81 // File types. |
82 enum FileType { | 82 // |
| 83 // Note: This is named FsFileType because otherwise we have a name collision |
| 84 // with windows.h. |
| 85 enum FsFileType { |
83 UNKNOWN = 0, | 86 UNKNOWN = 0, |
84 REGULAR_FILE, | 87 REGULAR_FILE, |
85 DIRECTORY, | 88 DIRECTORY, |
86 }; | 89 }; |
87 | 90 |
88 // Describes a directory entry (i.e., a single member of a directory). | 91 // Describes a directory entry (i.e., a single member of a directory). |
89 struct DirectoryEntry { | 92 struct DirectoryEntry { |
90 FileType type; | 93 FsFileType type; |
91 string name; | 94 string name; |
92 }; | 95 }; |
93 | 96 |
94 // Deletion flags: | 97 // Deletion flags: |
95 // Recursively delete. | 98 // Recursively delete. |
96 const uint32 kDeleteFlagRecursive = 0x1; | 99 const uint32 kDeleteFlagRecursive = 0x1; |
OLD | NEW |