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

Unified Diff: third_party/crashpad/crashpad/util/mac/xattr.h

Issue 1505213004: Copy Crashpad into the Chrome tree instead of importing it via DEPS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments, update README.chromium Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: third_party/crashpad/crashpad/util/mac/xattr.h
diff --git a/third_party/crashpad/crashpad/util/mac/xattr.h b/third_party/crashpad/crashpad/util/mac/xattr.h
new file mode 100644
index 0000000000000000000000000000000000000000..3e14f672c9c62381d6bba4f337e3d159057dea3b
--- /dev/null
+++ b/third_party/crashpad/crashpad/util/mac/xattr.h
@@ -0,0 +1,97 @@
+// Copyright 2014 The Crashpad Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef CRASHPAD_UTIL_MAC_XATTR_H_
+#define CRASHPAD_UTIL_MAC_XATTR_H_
+
+#include <time.h>
+
+#include <string>
+
+#include "base/files/file_path.h"
+#include "base/strings/string_piece.h"
+
+namespace crashpad {
+
+//! \brief The result code for a ReadXattr operation.
+enum class XattrStatus {
+ //! \brief No error occured. No message is logged.
+ kOK = 0,
+
+ //! \brief The attribute does not exist. No message is logged.
+ kNoAttribute,
+
+ //! \brief An error occurred and an error message was logged.
+ kOtherError,
+};
+
+//! \brief Reads an extended attribute on a file.
+//!
+//! \param[in] file The path to the file.
+//! \param[in] name The name of the extended attribute to read.
+//! \param[out] value The value of the attribute.
+//!
+//! \return XattrStatus
+XattrStatus ReadXattr(const base::FilePath& file,
+ const base::StringPiece& name,
+ std::string* value);
+
+//! \brief Writes an extended attribute on a file.
+//!
+//! \param[in] file The path to the file.
+//! \param[in] name The name of the extended attribute to write.
+//! \param[in] value The value of the attribute.
+//!
+//! \return `true` if the write was successful. `false` on error, with a message
+//! logged.
+bool WriteXattr(const base::FilePath& file,
+ const base::StringPiece& name,
+ const std::string& value);
+
+//! \copydoc ReadXattr
+//!
+//! Only the values `"0"` and `"1"`, for `false` and `true` respectively, are
+//! valid conversions.
+XattrStatus ReadXattrBool(const base::FilePath& file,
+ const base::StringPiece& name,
+ bool* value);
+
+//! \copydoc WriteXattr
+bool WriteXattrBool(const base::FilePath& file,
+ const base::StringPiece& name,
+ bool value);
+
+//! \copydoc ReadXattr
+XattrStatus ReadXattrInt(const base::FilePath& file,
+ const base::StringPiece& name,
+ int* value);
+
+//! \copydoc WriteXattr
+bool WriteXattrInt(const base::FilePath& file,
+ const base::StringPiece& name,
+ int value);
+
+//! \copydoc ReadXattr
+XattrStatus ReadXattrTimeT(const base::FilePath& file,
+ const base::StringPiece& name,
+ time_t* value);
+
+//! \copydoc WriteXattr
+bool WriteXattrTimeT(const base::FilePath& file,
+ const base::StringPiece& name,
+ time_t value);
+
+} // namespace crashpad
+
+#endif // CRASHPAD_UTIL_MAC_XATTR_H_

Powered by Google App Engine
This is Rietveld 408576698