/* We only support "apitrace trace" on POSIX-like systems (not WIN32) */
#ifndef _WIN32
-#include <sys/stat.h>
#ifdef __APPLE__
#define CLI_TRACE_VARIABLE "DYLD_LIBRARY_PATH"
#define CLI_TRACE_WRAPPER "glxtrace.so"
#endif
-static int
-file_exists(const char *path)
-{
- struct stat st;
- int err;
-
- err = stat(path, &st);
- if (err)
- return 0;
-
- if (! S_ISREG(st.st_mode))
- return 0;
-
- return 1;
-}
-
static os::Path
find_wrapper(const char *filename)
{
complete.join(filename);
#endif
- if (file_exists(complete))
+ if (complete.exists())
return complete;
/* Second, look in the directory for installed wrappers. */
complete = APITRACE_WRAPPER_INSTALL_DIR;
complete.join(filename);
- if (file_exists(complete))
+ if (complete.exists())
return complete;
std::cerr << "error: cannot find " << filename << " (looked in " <<
return path;
}
+bool
+Path::exists(void) const
+{
+ struct stat st;
+ int err;
+
+ err = stat(str(), &st);
+ if (err) {
+ return false;
+ }
+
+ if (!S_ISREG(st.st_mode))
+ return false;
+
+ return true;
+}
+
void
log(const char *format, ...)
{
return path;
}
+bool
+Path::exists(void) const
+{
+ DWORD attrs = GetFileAttributesA(str());
+ return attrs != INVALID_FILE_ATTRIBUTES;
+}
+
void
log(const char *format, ...)
{