From e5a3aa5672af11f69daa67182123cdf353eecbde Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 13 Mar 2009 16:16:00 +0000 Subject: progs: Try to read the texture from the current dir, if full path fails. --- progs/util/readtex.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'progs') diff --git a/progs/util/readtex.c b/progs/util/readtex.c index 37d5fcd0d3..8e923b6eb4 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); -- cgit v1.2.3