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

Unified Diff: source/libvpx/test/video_source.h

Issue 478033002: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 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 | « source/libvpx/test/variance_test.cc ('k') | source/libvpx/test/vp9_spatial_svc_encoder.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/libvpx/test/video_source.h
===================================================================
--- source/libvpx/test/video_source.h (revision 290053)
+++ source/libvpx/test/video_source.h (working copy)
@@ -53,55 +53,33 @@
return fopen(path_to_source.c_str(), "rb");
}
-static FILE *OpenTestOutFile(const std::string& file_name) {
- const std::string path_to_source = GetDataPath() + "/" + file_name;
- return fopen(path_to_source.c_str(), "wb");
-}
-
-static std::string GetTempOutFilename() {
- std::string basename;
+static FILE *GetTempOutFile(std::string *file_name) {
+ file_name->clear();
#if defined(_WIN32)
char fname[MAX_PATH];
- // Assume for now that the filename generated is unique per process
- const UINT ret = GetTempFileNameA(
- GetDataPath().c_str(), "lvx", 0, fname);
- if (ret != 0) {
- const char *slash = strrchr(fname, '\\');
- if (slash == NULL) slash = strrchr(fname, '/');
- if (slash == NULL)
- basename.assign(fname);
- else
- basename.assign(slash + 1);
- } else {
- basename.clear();
+ char tmppath[MAX_PATH];
+ if (GetTempPathA(MAX_PATH, tmppath)) {
+ // Assume for now that the filename generated is unique per process
+ if (GetTempFileNameA(tmppath, "lvx", 0, fname)) {
+ file_name->assign(fname);
+ return fopen(fname, "wb+");
+ }
}
+ return NULL;
#else
- char fname[256];
- const std::string templ = GetDataPath() + "/libvpx_test_XXXXXX";
- strncpy(fname, templ.c_str(), templ.size());
- fname[templ.size()] = '\0';
- const int fd = mkstemp(fname);
- if (fd != -1) {
- close(fd);
- basename.assign(strrchr(fname, '/') + 1);
- } else {
- basename.clear();
- }
+ return tmpfile();
#endif
- return basename;
}
class TempOutFile {
public:
TempOutFile() {
- file_name_ = GetTempOutFilename();
- file_ = OpenTestOutFile(file_name_);
+ file_ = GetTempOutFile(&file_name_);
}
~TempOutFile() {
CloseFile();
if (!file_name_.empty()) {
- const std::string path_to_source = GetDataPath() + "/" + file_name_;
- EXPECT_EQ(0, remove(path_to_source.c_str()));
+ EXPECT_EQ(0, remove(file_name_.c_str()));
}
}
FILE *file() {
@@ -110,14 +88,14 @@
const std::string& file_name() {
return file_name_;
}
+
+ protected:
void CloseFile() {
if (file_) {
fclose(file_);
file_ = NULL;
}
}
-
- protected:
FILE *file_;
std::string file_name_;
};
« no previous file with comments | « source/libvpx/test/variance_test.cc ('k') | source/libvpx/test/vp9_spatial_svc_encoder.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698