Mesa (master): progs: Try to read the texture from the current dir, if full path fails.
Jose Fonseca
jrfonseca at kemper.freedesktop.org
Mon Mar 16 12:02:06 UTC 2009
Module: Mesa
Branch: master
Commit: e5a3aa5672af11f69daa67182123cdf353eecbde
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e5a3aa5672af11f69daa67182123cdf353eecbde
Author: José Fonseca <jfonseca at vmware.com>
Date: Fri Mar 13 16:16:00 2009 +0000
progs: Try to read the texture from the current dir, if full path fails.
---
progs/util/readtex.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/progs/util/readtex.c b/progs/util/readtex.c
index 37d5fcd..8e923b6 100644
--- a/progs/util/readtex.c
+++ b/progs/util/readtex.c
@@ -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);
More information about the mesa-commit
mailing list