Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (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 | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 | |
| 15 #ifndef CRASHPAD_UTIL_MAC_XATTR_H_ | |
| 16 #define CRASHPAD_UTIL_MAC_XATTR_H_ | |
| 17 | |
| 18 #include <time.h> | |
| 19 | |
| 20 #include <string> | |
| 21 | |
| 22 #include "base/files/file_path.h" | |
| 23 #include "base/strings/string_piece.h" | |
| 24 | |
| 25 namespace crashpad { | |
| 26 | |
| 27 //! \brief Reads an extended attribute on a file. | |
| 28 //! | |
| 29 //! \param[in] file The path to the file. | |
| 30 //! \param[in] name The name of the extended attribute to read. | |
| 31 //! \param[out] value The value of the attribute. | |
| 32 //! | |
| 33 //! \return `true` if the read was successful, with \a value filled in. `false` | |
| 34 //! on error, with a message logged. | |
| 35 bool ReadXattr(const base::FilePath& file, | |
| 36 const base::StringPiece& name, | |
| 37 std::string* value); | |
| 38 | |
| 39 //! \brief Writes an extended attribute on a file. | |
| 40 //! | |
| 41 //! \param[in] file The path to the file. | |
| 42 //! \param[in] name The name of the extended attribute to write. | |
| 43 //! \param[in] value The value of the attribute. | |
| 44 //! | |
| 45 //! \return `true` if the write was successful. `false` on error, with a message | |
| 46 //! logged. | |
| 47 bool WriteXattr(const base::FilePath& file, | |
|
Mark Mentovai
2014/12/30 19:19:15
You may want ClearXattr at some point also, but it
Robert Sesek
2014/12/30 21:59:04
Acknowledged.
| |
| 48 const base::StringPiece& name, | |
| 49 const std::string& value); | |
| 50 | |
| 51 //! \copydoc ReadXattr | |
| 52 //! | |
| 53 //! Only the values `"0"` and `"1"`, for `false` and `true` respectively, are | |
| 54 //! valid conversions. | |
| 55 bool ReadXattrBool(const base::FilePath& file, | |
| 56 const base::StringPiece& name, | |
| 57 bool* value); | |
| 58 | |
| 59 //! \copydoc WriteXattr | |
| 60 bool WriteXattrBool(const base::FilePath& file, | |
| 61 const base::StringPiece& name, | |
| 62 bool value); | |
| 63 | |
| 64 //! \copydoc ReadXattr | |
| 65 bool ReadXattrInt(const base::FilePath& file, | |
| 66 const base::StringPiece& name, | |
| 67 int* value); | |
| 68 | |
| 69 //! \copydoc WriteXattr | |
| 70 bool WriteXattrInt(const base::FilePath& file, | |
| 71 const base::StringPiece& name, | |
| 72 int value); | |
| 73 | |
| 74 //! \copydoc ReadXattr | |
| 75 bool ReadXattrTimeT(const base::FilePath& file, | |
| 76 const base::StringPiece& name, | |
| 77 time_t* value); | |
| 78 | |
| 79 //! \copydoc WriteXattr | |
| 80 bool WriteXattrTimeT(const base::FilePath& file, | |
| 81 const base::StringPiece& name, | |
| 82 time_t value); | |
| 83 | |
| 84 } // namespace crashpad | |
| 85 | |
| 86 #endif // CRASHPAD_UTIL_MAC_XATTR_H_ | |
| OLD | NEW |