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

Unified Diff: base/file_util_linux.cc

Issue 100225: POSIX: Add a macro for handling EINTR. (Closed)
Patch Set: ... Created 11 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_descriptor_shuffle.cc ('k') | base/file_util_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_linux.cc
diff --git a/base/file_util_linux.cc b/base/file_util_linux.cc
index d595fe15ee19dbbf3c51472878c0cc197dfdb9de..35f614a69020d754b88222ae0da667ff866defd5 100644
--- a/base/file_util_linux.cc
+++ b/base/file_util_linux.cc
@@ -9,6 +9,7 @@
#include <string>
#include <vector>
+#include "base/eintr_wrappers.h"
#include "base/file_path.h"
#include "base/string_util.h"
@@ -44,7 +45,7 @@ bool CopyFile(const FilePath& from_path, const FilePath& to_path) {
bool result = true;
while (result) {
- ssize_t bytes_read = read(infile, &buffer[0], buffer.size());
+ ssize_t bytes_read = HANDLE_EINTR(read(infile, &buffer[0], buffer.size()));
if (bytes_read < 0) {
result = false;
break;
@@ -54,10 +55,10 @@ bool CopyFile(const FilePath& from_path, const FilePath& to_path) {
// Allow for partial writes
ssize_t bytes_written_per_read = 0;
do {
- ssize_t bytes_written_partial = write(
+ ssize_t bytes_written_partial = HANDLE_EINTR(write(
outfile,
&buffer[bytes_written_per_read],
- bytes_read - bytes_written_per_read);
+ bytes_read - bytes_written_per_read));
if (bytes_written_partial < 0) {
result = false;
break;
@@ -66,9 +67,9 @@ bool CopyFile(const FilePath& from_path, const FilePath& to_path) {
} while (bytes_written_per_read < bytes_read);
}
- if (close(infile) < 0)
+ if (HANDLE_EINTR(close(infile)) < 0)
result = false;
- if (close(outfile) < 0)
+ if (HANDLE_EINTR(close(outfile)) < 0)
result = false;
return result;
« no previous file with comments | « base/file_descriptor_shuffle.cc ('k') | base/file_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698