progs: Try to read the texture from the current dir, if full path fails.
authorJosé Fonseca <jfonseca@vmware.com>
Fri, 13 Mar 2009 16:16:00 +0000 (16:16 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 16 Mar 2009 12:01:44 +0000 (12:01 +0000)
progs/util/readtex.c

index 37d5fcd0d3a83f94a9be3f4eee6fdd250ab899cb..8e923b6eb47126952e9dd5cf2caa2b858bcc5d50 100644 (file)
@@ -102,9 +102,15 @@ static rawImageRec *RawImageOpen(const char *fileName)
       fprintf(stderr, "Out of memory!\n");
       return NULL;
    }
-   if ((raw->file = fopen(fileName, "rb")) == NULL) {
-      perror(fileName);
-      return NULL;
+   raw->file = fopen(fileName, "rb");
+   if (raw->file == NULL) {
+      const char *baseName = strrchr(fileName, '/');
+      if(baseName)
+         raw->file = fopen(baseName + 1, "rb");
+      if(raw->file == NULL) {
+         perror(fileName);
+         return NULL;
+      }
    }
 
    fread(raw, 1, 12, raw->file);