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

Unified Diff: mojo/data_pipe_utils/data_pipe_file_utils.cc

Issue 1303343007: Created a blocking copy to temporary file function. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 4 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 | « no previous file | mojo/data_pipe_utils/data_pipe_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/data_pipe_utils/data_pipe_file_utils.cc
diff --git a/mojo/data_pipe_utils/data_pipe_file_utils.cc b/mojo/data_pipe_utils/data_pipe_file_utils.cc
index e37c8dfe9aeee9140bb33717c5b55d5066c8f9b3..1bba30748d8c541e6a138efef3540c8f3df054ee 100644
--- a/mojo/data_pipe_utils/data_pipe_file_utils.cc
+++ b/mojo/data_pipe_utils/data_pipe_file_utils.cc
@@ -329,6 +329,23 @@ bool BlockingCopyToFile(ScopedDataPipeConsumerHandle source,
base::Bind(&CopyToFileHelper, fp.get()));
}
+bool BlockingCopyToTempFile(ScopedDataPipeConsumerHandle source,
+ FILE** fpp) {
viettrungluu 2015/09/01 23:36:25 Possibly this should be a base::ScopedFILE*. Or y
Sean Klein 2015/09/01 23:57:52 Out of curiosity, what is the difference between a
jamesr 2015/09/02 00:06:39 base::ScopedFILE's destructor calls fclose()
+ base::FilePath path;
+ *fpp = (base::CreateAndOpenTemporaryFile(&path));
+ if (!*fpp) {
+ LOG(ERROR) << "CreateAndOpenTemporaryFile failed in"
+ << "BlockingCopyToTempFile";
+ return false;
+ }
+ if (unlink(path.value().c_str())) {
+ LOG(ERROR) << "Failed to unlink temporary file\n";
viettrungluu 2015/09/01 23:36:25 Also: no \n needed here. More importantly, it's pe
Sean Klein 2015/09/01 23:57:52 Done.
+ return false;
+ }
+ return BlockingCopyHelper(source.Pass(),
+ base::Bind(&CopyToFileHelper, *fpp));
+}
+
void CopyToFile(ScopedDataPipeConsumerHandle source,
const base::FilePath& destination,
base::TaskRunner* task_runner,
« no previous file with comments | « no previous file | mojo/data_pipe_utils/data_pipe_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698