7 #include "packager/media/file/file_util.h"
11 #include "packager/base/files/file_path.h"
12 #include "packager/base/files/file_util.h"
13 #include "packager/base/strings/stringprintf.h"
14 #include "packager/base/threading/platform_thread.h"
15 #include "packager/base/time/time.h"
20 std::string TempFileName() {
21 const int32_t tid =
static_cast<int32_t
>(base::PlatformThread::CurrentId());
22 const int64_t current_time = base::Time::Now().ToInternalValue();
23 return base::StringPrintf(
"packager-tempfile-%x-%" PRIx64, tid, current_time);
27 bool TempFilePath(
const std::string& temp_dir, std::string* temp_file_path) {
28 if (temp_dir.empty()) {
29 base::FilePath file_path;
30 if (!base::CreateTemporaryFile(&file_path)) {
31 LOG(ERROR) <<
"Failed to create temporary file.";
34 *temp_file_path = file_path.AsUTF8Unsafe();
37 base::FilePath::FromUTF8Unsafe(temp_dir)
38 .Append(base::FilePath::FromUTF8Unsafe(TempFileName()))
bool TempFilePath(const std::string &temp_dir, std::string *temp_file_path)