File: file.mojom

package info (click to toggle)
chromium-browser 57.0.2987.98-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,637,852 kB
  • ctags: 2,544,394
  • sloc: cpp: 12,815,961; ansic: 3,676,222; python: 1,147,112; asm: 526,608; java: 523,212; xml: 286,794; perl: 92,654; sh: 86,408; objc: 73,271; makefile: 27,698; cs: 18,487; yacc: 13,031; tcl: 12,957; pascal: 4,875; ml: 4,716; lex: 3,904; sql: 3,862; ruby: 1,982; lisp: 1,508; php: 1,368; exp: 404; awk: 325; csh: 117; jsp: 39; sed: 37
file content (89 lines) | stat: -rw-r--r-- 3,414 bytes parent folder | download | duplicates (2)
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
// 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.

// TODO(vtl): notes to self:
//  - file offsets, file positions, and file sizes are int64 (though positions
//    and sizes must always be non-negative)
//  - buffer size parameters (for read/write) are uint32

module filesystem.mojom;

import "components/filesystem/public/interfaces/types.mojom";
import "mojo/common/file.mojom";

// TODO(vtl): Write comments.
interface File {
  // Flushes/closes this file; no operations may be performed on this file after
  // this. Note that any error code is strictly informational -- the close may
  // not be retried.
  [Sync]
  Close() => (FileError err);

  // Reads (at most) |num_bytes_to_read| from the location specified by
  // |offset|/|whence|. On success, |bytes_read| is set to the data read.
  // TODO(vtl): Define/clarify behavior when less than |num_bytes_to_read| bytes
  // are read.
  // TODO(vtl): Clarify when (for what values of |offset|/|whence|) this
  // modifies the file position. Or maybe there should be a flag?
  [Sync]
  Read(uint32 num_bytes_to_read, int64 offset, Whence whence)
      => (FileError error, array<uint8>? bytes_read);

  // Writes |bytes_to_write| to the location specified by |offset|/|whence|.
  // TODO(vtl): Clarify behavior when |num_bytes_written| is less than the size
  // of |bytes_to_write|.
  [Sync]
  Write(array<uint8> bytes_to_write, int64 offset, Whence whence)
      => (FileError error, uint32 num_bytes_written);

  // Gets the current file position. On success, |position| is the current
  // offset (in bytes) from the beginning of the file).
  [Sync]
  Tell() => (FileError error, int64 position);

  // Sets the current file position to that specified by |offset|/|whence|. On
  // success, |position| is the offset (in bytes) from the beginning of the
  // file.
  [Sync]
  Seek(int64 offset, Whence whence) => (FileError error, int64 position);

  // Gets information about this file. On success, |file_information| is
  // non-null and will contain this information.
  [Sync]
  Stat() => (FileError error, FileInformation? file_information);

  // Truncates this file to the size specified by |size| (in bytes).
  [Sync]
  Truncate(int64 size) => (FileError error);

  // Updates this file's atime and/or mtime to the time specified by |atime| (or
  // |mtime|, respectively), which may also indicate "now". If |atime| or
  // |mtime| is null, then the corresponding time is not modified.
  [Sync]
  Touch(TimespecOrNow? atime, TimespecOrNow? mtime) => (FileError error);

  // Creates a new |File| instance, which shares the same "file description".
  // I.e., the access mode, etc. (as specified to |Directory::OpenFile()| by the
  // |open_flags| argument) as well as file position.
  [Sync]
  Dup(File& file) => (FileError error);

  // Syncs data to disk.
  [Sync]
  Flush() => (FileError error);

  // Attempts to take an exclusive write lock on the file. This both takes a
  // native OS file lock (so that non-chrome, non-mojo processes can't write to
  // this file).
  [Sync]
  Lock() => (FileError error);

  // Unlocks a previously locked file.
  [Sync]
  Unlock() => (FileError error);

  // Returns a handle to the file for raw access.
  [Sync]
  AsHandle() => (FileError error, mojo.common.mojom.File? file_handle);
};