summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt1
-rw-r--r--src/common/grfio.c36
2 files changed, 33 insertions, 4 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 10912eae0..cbefe77b9 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -1,6 +1,7 @@
Date Added
2011/01/01
+ * Fixed local files could not be aliased with resnametable.txt in grfio (bugreport:2203, since r5152). [Ai4rei]
* Cleanups to grfio. [Ai4rei]
- Replaced strncpy with safestrncpy (bugreport:3080).
- Ensured, that all local paths are normalized and work whether or not the data dir ends with '/'.
diff --git a/src/common/grfio.c b/src/common/grfio.c
index 9f57f4e25..3c0960f30 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -13,6 +13,7 @@
#include "../common/showmsg.h"
#include "../common/malloc.h"
#include "../common/strlib.h"
+#include "../common/utils.h"
//----------------------------
@@ -458,7 +459,7 @@ void* grfio_reads(char* fname, int* size)
char lfname[256];
int declen;
- grfio_localpath_create(lfname, sizeof(lfname), fname);
+ grfio_localpath_create(lfname, sizeof(lfname), ( entry && entry->fnd ) ? entry->fnd : fname);
in = fopen(lfname, "rb");
if (in != NULL) {
@@ -708,9 +709,10 @@ static int grfio_entryread(char* grfname, int gentry)
*------------------------------------------*/
static void grfio_resourcecheck(void)
{
- char w1[256], w2[256], src[256], dst[256], restable[256], line[256];
+ char w1[256], w2[256], src[256], dst[256], restable[256], line[256], local[256];
char *ptr, *buf;
FILELIST* entry;
+ FILELIST fentry;
int size;
FILE* fp;
int i = 0;
@@ -732,13 +734,26 @@ static void grfio_resourcecheck(void)
// create new entries reusing the original's info
if (entry != NULL)
{// alias for GRF resource
- FILELIST fentry;
memcpy(&fentry, entry, sizeof(FILELIST));
safestrncpy(fentry.fn, src, sizeof(fentry.fn));
fentry.fnd = aStrdup(dst);
filelist_modify(&fentry);
i++;
}
+ else
+ {
+ grfio_localpath_create(local, sizeof(local), dst);
+
+ if( exists(local) )
+ {// alias for local resource
+ memset(&fentry, 0, sizeof(fentry));
+ //fentry.gentry = 0;
+ safestrncpy(fentry.fn, src, sizeof(fentry.fn));
+ fentry.fnd = aStrdup(dst);
+ filelist_modify(&fentry);
+ i++;
+ }
+ }
}
}
fclose(fp);
@@ -761,13 +776,26 @@ static void grfio_resourcecheck(void)
entry = filelist_find(dst);
if (entry != NULL)
{// alias for GRF resource
- FILELIST fentry;
memcpy(&fentry, entry, sizeof(FILELIST));
safestrncpy(fentry.fn, src, sizeof(fentry.fn));
fentry.fnd = aStrdup(dst);
filelist_modify(&fentry);
i++;
}
+ else
+ {
+ grfio_localpath_create(local, sizeof(local), dst);
+
+ if( exists(local) )
+ {// alias for local resource
+ memset(&fentry, 0, sizeof(fentry));
+ //fentry.gentry = 0;
+ safestrncpy(fentry.fn, src, sizeof(fentry.fn));
+ fentry.fnd = aStrdup(dst);
+ filelist_modify(&fentry);
+ i++;
+ }
+ }
}
ptr = strchr(ptr, '\n'); // Next line
if (!ptr) break;