1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module filesystem.mojom;
// Error codes used by the file system. These error codes line up exactly with
// those of base::File.
enum FileError {
OK = 0,
FAILED = -1,
IN_USE = -2,
EXISTS = -3,
NOT_FOUND = -4,
ACCESS_DENIED = -5,
TOO_MANY_OPENED = -6,
NO_MEMORY = -7,
NO_SPACE = -8,
NOT_A_DIRECTORY = -9,
INVALID_OPERATION = -10,
SECURITY = -11,
ABORT = -12,
NOT_A_FILE = -13,
NOT_EMPTY = -14,
INVALID_URL = -15,
IO = -16,
};
// Used to explain the meaning of an offset within a file. These values line up
// exactly with base::File.
enum Whence {
// Offset is relative to the beginning of the file.
FROM_BEGIN = 0,
// Offset is from current position in the file.
FROM_CURRENT = 1,
// Offset is relative to the end of the file.
FROM_END = 2
};
// Used for |Touch()| calls. If |now| is set, |timespec| must be null (the time
// "now" will be used). Otherwise, |timespec| must not be null.
// TODO(vtl): Use a union instead, when that becomes possible.
struct TimespecOrNow {
bool now;
double seconds;
};
// Describes various information about a file or directory (for |Stat()|). Note
// that access/modification times may be set arbitrarily (by those with
// appropriate capabilities) and may not reflect reality.
struct FileInformation {
// Type of the file.
FsFileType type;
// Size of the file, in bytes. Zero for directories.
int64 size;
// Last access time, in seconds since Unix Epoch.
double atime;
// Last modification time, in seconds since Unix Epoch.
double mtime;
// Create time of the file, in seconds since Unix Epoch.
double ctime;
};
// File and directory open flags. Is a limited subset of base::File::Flags. These
// are constants instead of enums so that they are bitwise OR-able.
// Opens a file, only if it exists.
const uint32 kFlagOpen = 0x1;
// Creates a new file, only if it does not already exist.
const uint32 kFlagCreate = 0x2;
// May create a new file.
const uint32 kFlagOpenAlways = 0x4;
// May overwrite an old file.
const uint32 kCreateAlways = 0x8;
// Opens a file and truncates it, only if it exists.
const uint32 kFlagOpenTruncated = 0x10;
const uint32 kFlagRead = 0x20;
const uint32 kFlagWrite = 0x40;
const uint32 kFlagAppend = 0x80;
// Deletes the file when closed.
const uint32 kDeleteOnClose = 0x2000;
// File types.
//
// Note: This is named FsFileType because otherwise we have a name collision
// with windows.h.
enum FsFileType {
UNKNOWN = 0,
REGULAR_FILE,
DIRECTORY,
};
// Describes a directory entry (i.e., a single member of a directory).
struct DirectoryEntry {
FsFileType type;
string name;
};
// Deletion flags:
// Recursively delete.
const uint32 kDeleteFlagRecursive = 0x1;
|