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

Side by Side Diff: components/filesystem/util.h

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/shared_impl.cc ('k') | components/filesystem/util.cc » ('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 #ifndef COMPONENTS_FILESYSTEM_UTIL_H_ 5 #ifndef COMPONENTS_FILESYSTEM_UTIL_H_
6 #define COMPONENTS_FILESYSTEM_UTIL_H_ 6 #define COMPONENTS_FILESYSTEM_UTIL_H_
7 7
8 #include "base/files/file.h"
8 #include "components/filesystem/public/interfaces/types.mojom.h" 9 #include "components/filesystem/public/interfaces/types.mojom.h"
9 10
10 namespace mojo { 11 namespace mojo {
11 class String; 12 class String;
12 } 13 }
13 14
14 namespace filesystem { 15 namespace filesystem {
15 16
16 // Validation functions (typically used to check arguments; they return 17 // Validation functions (typically used to check arguments; they return
17 // |ERROR_OK| if valid, else the standard/recommended error for the validation 18 // |ERROR_OK| if valid, else the standard/recommended error for the validation
18 // error): 19 // error):
19 20
20 // Checks if |path|, which must be non-null, is (looks like) a valid (relative) 21 // Checks if |path|, which must be non-null, is (looks like) a valid (relative)
21 // path. (On failure, returns |ERROR_INVALID_ARGUMENT| if |path| is not UTF-8, 22 // path. (On failure, returns |ERROR_INVALID_ARGUMENT| if |path| is not UTF-8,
22 // or |ERROR_PERMISSION_DENIED| if it is not relative.) 23 // or |ERROR_PERMISSION_DENIED| if it is not relative.)
23 Error IsPathValid(const mojo::String& path); 24 Error IsPathValid(const mojo::String& path);
24 25
25 // Checks if |whence| is a valid (known) |Whence| value. (On failure, returns 26 // Checks if |whence| is a valid (known) |Whence| value. (On failure, returns
26 // |ERROR_UNIMPLEMENTED|.) 27 // |ERROR_UNIMPLEMENTED|.)
27 Error IsWhenceValid(Whence whence); 28 Error IsWhenceValid(Whence whence);
28 29
29 // Checks if |offset| is a valid file offset (from some point); this is 30 // Checks if |offset| is a valid file offset (from some point); this is
30 // implementation-dependent (typically checking if |offset| fits in an |off_t|). 31 // implementation-dependent (typically checking if |offset| fits in an |off_t|).
31 // (On failure, returns |ERROR_OUT_OF_RANGE|.) 32 // (On failure, returns |ERROR_OUT_OF_RANGE|.)
32 Error IsOffsetValid(int64_t offset); 33 Error IsOffsetValid(int64_t offset);
33 34
34 // Conversion functions: 35 // Conversion functions:
35 36
36 // Converts a standard errno value (|E...|) to an |Error| value. 37 // Returns the platform dependent error details converted to the
37 Error ErrnoToError(int errno_value); 38 // filesystem.Error enum.
39 Error GetError(const base::File& file);
38 40
39 // Converts a |Whence| value to a standard whence value (|SEEK_...|). 41 // Serializes Info to the wire format.
40 int WhenceToStandardWhence(Whence whence); 42 FileInformationPtr MakeFileInformation(const base::File::Info& info);
41 43
42 // Converts a |Timespec| to a |struct timespec|. If |in| is null, |out->tv_nsec| 44 // Creates an absolute file path and ensures that we don't try to traverse up.
43 // is set to |UTIME_OMIT|. 45 Error ValidatePath(const mojo::String& raw_path,
44 Error TimespecToStandardTimespec(const Timespec* in, struct timespec* out); 46 const base::FilePath& filesystem_base,
45 47 base::FilePath* out);
46 // Converts a |TimespecOrNow| to a |struct timespec|. If |in| is null,
47 // |out->tv_nsec| is set to |UTIME_OMIT|; if |in->now| is set, |out->tv_nsec| is
48 // set to |UTIME_NOW|.
49 Error TimespecOrNowToStandardTimespec(const TimespecOrNow* in,
50 struct timespec* out);
51
52 // Ensures that |open_flags| is one of the valid combinations listed in
53 // types.mojom.
54 Error ValidateOpenFlags(uint32_t open_flags, bool is_directory);
55
56 // Ensures that |delete_flags| is one of the valid combinations listed in
57 // types.mojom.
58 Error ValidateDeleteFlags(uint32_t delete_flags);
59 48
60 } // namespace filesystem 49 } // namespace filesystem
61 50
62 #endif // COMPONENTS_FILESYSTEM_UTIL_H_ 51 #endif // COMPONENTS_FILESYSTEM_UTIL_H_
OLDNEW
« no previous file with comments | « components/filesystem/shared_impl.cc ('k') | components/filesystem/util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698