]> git.cworth.org Git - apitrace/blobdiff - common/trace_tools_trace.cpp
Add abstractions for (un)setting OS environ variables.
[apitrace] / common / trace_tools_trace.cpp
index f14617d6142d8ad1e6decbbd789f1783ebd5e711..dc40896a222fee0968d8bdf4f883b863b9e1c8ed 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "os_string.hpp"
 #include "os_process.hpp"
+#include "trace_resource.hpp"
 #include "trace_tools.hpp"
 
 
@@ -52,39 +53,6 @@ namespace trace {
 #endif
 
 
-os::String
-findFile(const char *relPath,
-         const char *absPath,
-         bool verbose)
-{
-    os::String complete;
-
-    /* First look in the same directory from which this process is
-     * running, (to support developers running a compiled program that
-     * has not been installed. */
-    os::String process_dir = os::getProcessName();
-
-    process_dir.trimFilename();
-
-    complete = process_dir;
-    complete.join(relPath);
-
-    if (complete.exists())
-        return complete;
-
-    /* Second, look in the directory for installed wrappers. */
-    complete = absPath;
-    if (complete.exists())
-        return complete;
-
-    if (verbose) {
-        std::cerr << "error: cannot find " << relPath << " or " << absPath << "\n";
-    }
-
-    return "";
-}
-
-
 int
 traceProgram(API api,
              char * const *argv,
@@ -143,10 +111,10 @@ traceProgram(API api,
     }
 
     /* FIXME: Don't modify the current environment */
-    setenv(TRACE_VARIABLE, wrapper.str(), 1);
+    os::setEnvironment(TRACE_VARIABLE, wrapper.str());
 
     if (output) {
-        setenv("TRACE_FILE", output, 1);
+        os::setEnvironment("TRACE_FILE", output);
     }
 
     if (verbose) {
@@ -160,9 +128,9 @@ traceProgram(API api,
 
     int status = os::execute(argv);
 
-    unsetenv(TRACE_VARIABLE);
+    os::unsetEnvironment(TRACE_VARIABLE);
     if (output) {
-        unsetenv("TRACE_FILE");
+        os::unsetEnvironment("TRACE_FILE");
     }
     
     return status;