]> git.cworth.org Git - apitrace/blobdiff - cli/cli_diff_images.cpp
Set binary mode when outputing PNM from glretrace via stdout.
[apitrace] / cli / cli_diff_images.cpp
index 91f07c11871666c3a816dfd59f25ac9267c8ec06..626a34fc7790f4a56fb5070d81f2246c9deb72db 100644 (file)
 
 #include "cli.hpp"
 #include "os_string.hpp"
-#include "trace_tools.hpp"
+#include "os_process.hpp"
+#include "trace_resource.hpp"
 
 static const char *synopsis = "Identify differences between two image dumps.";
 
 static os::String
 find_command(void)
 {
-#define CLI_DIFF_IMAGES_COMMAND "snapdiff.py"
-
-    return trace::findFile("scripts/" CLI_DIFF_IMAGES_COMMAND,
-     APITRACE_SCRIPTS_INSTALL_DIR "/" CLI_DIFF_IMAGES_COMMAND,
-                           true);
-
+    return trace::findScript("snapdiff.py");
 }
 
 static void
 usage(void)
 {
-    char *args[3];
-
     os::String command = find_command();
+    if (!command.length()) {
+        exit(1);
+    }
 
+    char *args[3];
     args[0] = (char *) command.str();
     args[1] = (char *) "--help";
     args[2] = NULL;
 
-#ifdef _WIN32
-    std::cerr << "The 'apitrace diff-images' command is not yet supported on this O/S.\n";
-#else
-    execv(command.str(), args);
-#endif
-
-    std::cerr << "Error: Failed to execute " << args[0] << "\n";
+    os::execute(args);
 }
 
 static int
 command(int argc, char *argv[])
 {
     int i;
-    char **args = new char* [argc+2];
+    int ret;
 
     os::String command = find_command();
+    if (!command.length()) {
+        return 1;
+    }
 
+    char **args = new char* [argc + 1];
     args[0] = (char *) command.str();
-
-    for (i = 0; i < argc; i++) {
-        args[i+1] = argv[i];
+    for (i = 1; i < argc; i++) {
+        args[i] = argv[i];
     }
+    args[argc] = NULL;
 
-    args[i+1] = NULL;
-
-#ifdef _WIN32
-    std::cerr << "The 'apitrace diff-images' command is not yet supported on this O/S.\n";
-#else
-    execv(command.str(), args);
-#endif
+    ret = os::execute(args);
 
-    std::cerr << "Error: Failed to execute " << args[0] << "\n";
+    delete [] args;
 
-    return 1;
+    return ret;
 }
 
 const Command diff_images_command = {