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

Unified Diff: util/file/file_io_posix.cc

Issue 811823003: Cross platform low level file IO wrappers (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: . Created 6 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: util/file/file_io_posix.cc
diff --git a/util/file/fd_io.cc b/util/file/file_io_posix.cc
similarity index 56%
rename from util/file/fd_io.cc
rename to util/file/file_io_posix.cc
index cc97400ba34ba3e827a71f9c9dc1955ad18e1e8d..ff32009021679f3690e9a7eb65c402dfc2e5f6d1 100644
--- a/util/file/fd_io.cc
+++ b/util/file/file_io_posix.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "util/file/fd_io.h"
+#include "util/file/file_io.h"
#include <unistd.h>
@@ -66,70 +66,18 @@ ssize_t ReadOrWrite(int fd,
namespace crashpad {
-ssize_t ReadFD(int fd, void* buffer, size_t size) {
- return ReadOrWrite<ReadTraits>(fd, buffer, size);
+ssize_t ReadFile(FileHandle file, void* buffer, size_t size) {
+ return ReadOrWrite<ReadTraits>(file, buffer, size);
}
-ssize_t WriteFD(int fd, const void* buffer, size_t size) {
- return ReadOrWrite<WriteTraits>(fd, buffer, size);
+ssize_t WriteFile(FileHandle file, const void* buffer, size_t size) {
+ return ReadOrWrite<WriteTraits>(file, buffer, size);
}
-bool LoggingReadFD(int fd, void* buffer, size_t size) {
- ssize_t expect = base::checked_cast<ssize_t>(size);
- ssize_t rv = ReadFD(fd, buffer, size);
- if (rv < 0) {
- PLOG(ERROR) << "read";
- return false;
- }
- if (rv != expect) {
- LOG(ERROR) << "read: expected " << expect << ", observed " << rv;
- return false;
- }
-
- return true;
-}
-
-bool LoggingWriteFD(int fd, const void* buffer, size_t size) {
- ssize_t expect = base::checked_cast<ssize_t>(size);
- ssize_t rv = WriteFD(fd, buffer, size);
- if (rv < 0) {
- PLOG(ERROR) << "write";
- return false;
- }
- if (rv != expect) {
- LOG(ERROR) << "write: expected " << expect << ", observed " << rv;
- return false;
- }
-
- return true;
-}
-
-void CheckedReadFD(int fd, void* buffer, size_t size) {
- CHECK(LoggingReadFD(fd, buffer, size));
-}
-
-void CheckedWriteFD(int fd, const void* buffer, size_t size) {
- CHECK(LoggingWriteFD(fd, buffer, size));
-}
-
-void CheckedReadFDAtEOF(int fd) {
- char c;
- ssize_t rv = ReadFD(fd, &c, 1);
- if (rv < 0) {
- PCHECK(rv == 0) << "read";
- } else {
- CHECK_EQ(rv, 0) << "read";
- }
-}
-
-bool LoggingCloseFD(int fd) {
- int rv = IGNORE_EINTR(close(fd));
+bool LoggingCloseFile(FileHandle file) {
+ int rv = IGNORE_EINTR(close(file));
PLOG_IF(ERROR, rv != 0) << "close";
return rv == 0;
}
-void CheckedCloseFD(int fd) {
- CHECK(LoggingCloseFD(fd));
-}
-
} // namespace crashpad
« util/file/file_io.h ('K') | « util/file/file_io.cc ('k') | util/file/file_io_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698