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

Side by Side Diff: util/mac/xattr.h

Issue 842223003: Add a tri-state enum to return the result of Xattr operations. (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 11 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 | « no previous file | util/mac/xattr.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 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #ifndef CRASHPAD_UTIL_MAC_XATTR_H_ 15 #ifndef CRASHPAD_UTIL_MAC_XATTR_H_
16 #define CRASHPAD_UTIL_MAC_XATTR_H_ 16 #define CRASHPAD_UTIL_MAC_XATTR_H_
17 17
18 #include <time.h> 18 #include <time.h>
19 19
20 #include <string> 20 #include <string>
21 21
22 #include "base/files/file_path.h" 22 #include "base/files/file_path.h"
23 #include "base/strings/string_piece.h" 23 #include "base/strings/string_piece.h"
24 24
25 namespace crashpad { 25 namespace crashpad {
26 26
27 //! \brief The result code for a ReadXattr operation.
28 enum class XattrStatus {
29 //! \brief No error occured. No message is logged.
30 kOK = 0,
31
32 //! \brief The attribute does not exist. No message is logged.
33 kNoAttribute,
34
35 //! \brief An error occurred and an error message was logged.
36 kOtherError,
37 };
38
27 //! \brief Reads an extended attribute on a file. 39 //! \brief Reads an extended attribute on a file.
28 //! 40 //!
29 //! \param[in] file The path to the file. 41 //! \param[in] file The path to the file.
30 //! \param[in] name The name of the extended attribute to read. 42 //! \param[in] name The name of the extended attribute to read.
31 //! \param[out] value The value of the attribute. 43 //! \param[out] value The value of the attribute.
32 //! 44 //!
33 //! \return `true` if the read was successful, with \a value filled in. `false` 45 //! \return XattrStatus
34 //! on error, with a message logged. 46 XattrStatus ReadXattr(const base::FilePath& file,
35 bool ReadXattr(const base::FilePath& file, 47 const base::StringPiece& name,
36 const base::StringPiece& name, 48 std::string* value);
37 std::string* value);
38 49
39 //! \brief Writes an extended attribute on a file. 50 //! \brief Writes an extended attribute on a file.
40 //! 51 //!
41 //! \param[in] file The path to the file. 52 //! \param[in] file The path to the file.
42 //! \param[in] name The name of the extended attribute to write. 53 //! \param[in] name The name of the extended attribute to write.
43 //! \param[in] value The value of the attribute. 54 //! \param[in] value The value of the attribute.
44 //! 55 //!
45 //! \return `true` if the write was successful. `false` on error, with a message 56 //! \return `true` if the write was successful. `false` on error, with a message
46 //! logged. 57 //! logged.
47 bool WriteXattr(const base::FilePath& file, 58 bool WriteXattr(const base::FilePath& file,
48 const base::StringPiece& name, 59 const base::StringPiece& name,
49 const std::string& value); 60 const std::string& value);
50 61
51 //! \copydoc ReadXattr 62 //! \copydoc ReadXattr
52 //! 63 //!
53 //! Only the values `"0"` and `"1"`, for `false` and `true` respectively, are 64 //! Only the values `"0"` and `"1"`, for `false` and `true` respectively, are
54 //! valid conversions. 65 //! valid conversions.
55 bool ReadXattrBool(const base::FilePath& file, 66 XattrStatus ReadXattrBool(const base::FilePath& file,
56 const base::StringPiece& name, 67 const base::StringPiece& name,
57 bool* value); 68 bool* value);
58 69
59 //! \copydoc WriteXattr 70 //! \copydoc WriteXattr
60 bool WriteXattrBool(const base::FilePath& file, 71 bool WriteXattrBool(const base::FilePath& file,
61 const base::StringPiece& name, 72 const base::StringPiece& name,
62 bool value); 73 bool value);
63 74
64 //! \copydoc ReadXattr 75 //! \copydoc ReadXattr
65 bool ReadXattrInt(const base::FilePath& file, 76 XattrStatus ReadXattrInt(const base::FilePath& file,
66 const base::StringPiece& name, 77 const base::StringPiece& name,
67 int* value); 78 int* value);
68 79
69 //! \copydoc WriteXattr 80 //! \copydoc WriteXattr
70 bool WriteXattrInt(const base::FilePath& file, 81 bool WriteXattrInt(const base::FilePath& file,
71 const base::StringPiece& name, 82 const base::StringPiece& name,
72 int value); 83 int value);
73 84
74 //! \copydoc ReadXattr 85 //! \copydoc ReadXattr
75 bool ReadXattrTimeT(const base::FilePath& file, 86 XattrStatus ReadXattrTimeT(const base::FilePath& file,
76 const base::StringPiece& name, 87 const base::StringPiece& name,
77 time_t* value); 88 time_t* value);
78 89
79 //! \copydoc WriteXattr 90 //! \copydoc WriteXattr
80 bool WriteXattrTimeT(const base::FilePath& file, 91 bool WriteXattrTimeT(const base::FilePath& file,
81 const base::StringPiece& name, 92 const base::StringPiece& name,
82 time_t value); 93 time_t value);
83 94
84 } // namespace crashpad 95 } // namespace crashpad
85 96
86 #endif // CRASHPAD_UTIL_MAC_XATTR_H_ 97 #endif // CRASHPAD_UTIL_MAC_XATTR_H_
OLDNEW
« no previous file with comments | « no previous file | util/mac/xattr.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698