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, |