7 #include "packager/file/file_util.h" 11 #include "packager/base/files/file_path.h" 12 #include "packager/base/files/file_util.h" 13 #include "packager/base/process/process_handle.h" 14 #include "packager/base/strings/stringprintf.h" 15 #include "packager/base/threading/platform_thread.h" 16 #include "packager/base/time/time.h" 21 std::string TempFileName() {
22 const int32_t pid =
static_cast<int32_t
>(base::GetCurrentProcId());
23 const int32_t tid =
static_cast<int32_t
>(base::PlatformThread::CurrentId());
24 const int64_t current_time = base::Time::Now().ToInternalValue();
25 return base::StringPrintf(
"packager-tempfile-%x-%x-%" PRIx64, pid, tid,
30 bool TempFilePath(
const std::string& temp_dir, std::string* temp_file_path) {
31 if (temp_dir.empty()) {
32 base::FilePath file_path;
33 if (!base::CreateTemporaryFile(&file_path)) {
34 LOG(ERROR) <<
"Failed to create temporary file.";
37 *temp_file_path = file_path.AsUTF8Unsafe();
40 base::FilePath::FromUTF8Unsafe(temp_dir)
41 .Append(base::FilePath::FromUTF8Unsafe(TempFileName()))
bool TempFilePath(const std::string &temp_dir, std::string *temp_file_path)
All the methods that are virtual are virtual for mocking.