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

Unified Diff: client/deps/glbench/src/utils.cc

Issue 897003: set resource loading path relative to the executable (Closed)
Patch Set: Created 10 years, 9 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 | « client/deps/glbench/src/utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/deps/glbench/src/utils.cc
diff --git a/client/deps/glbench/src/utils.cc b/client/deps/glbench/src/utils.cc
index 5340d7ba4df22df0fb8ef6374326df96e0108a67..a214f5b6e1bbd1375ae6487c303f8979440c48d1 100644
--- a/client/deps/glbench/src/utils.cc
+++ b/client/deps/glbench/src/utils.cc
@@ -10,11 +10,25 @@
#include "utils.h"
+#include "base/file_path.h"
#include "base/logging.h"
#include "main.h"
-void *MmapFile(const char *name, size_t *length) {
- int fd = open(name, O_RDONLY);
+FilePath *g_base_path = new FilePath();
+
+// Sets the base path for MmapFile to `dirname($argv0)`/$relative.
+void SetBasePathFromArgv0(const char* argv0, const char* relative) {
Alexey Marinichev 2010/03/12 19:22:59 Everywhere else, including line 17, pointers are d
+ if (g_base_path) {
+ delete g_base_path;
+ }
+ FilePath argv0_path = FilePath(argv0).DirName();
+ FilePath base_path = relative ? argv0_path.Append(relative) : argv0_path;
+ g_base_path = new FilePath(base_path);
+}
+
+void *MmapFile(const char* name, size_t* length) {
Alexey Marinichev 2010/03/12 19:22:59 Same thing here.
+ FilePath filename = g_base_path->Append(name);
+ int fd = open(filename.value().c_str(), O_RDONLY);
if (fd == -1)
return NULL;
« no previous file with comments | « client/deps/glbench/src/utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698