bpic now loads assets relative to the dat file provided

instead of assuming everything to be loaded is in the current working
directory
This commit is contained in:
Gered 2019-11-05 18:55:49 -05:00
parent 2482fe7bbb
commit 810f1244b8
2 changed files with 32 additions and 4 deletions

View file

@ -13,6 +13,29 @@
unsigned long rTable[MAX_RBA+1]; unsigned long rTable[MAX_RBA+1];
//=============================================================================
// for dealing with paths
//=============================================================================
char dataPath[200] = "";
char tempFilename[200] = "";
void FindFilePaths(const char *dataFile) {
char *end;
if (dataFile) {
end = strrchr(dataFile, '\\');
if (end)
strncpy(dataPath, dataFile, ((end+1) - dataFile));
}
}
char* GetCombinedPath(const char *base, const char *file) {
strncpy(tempFilename, base, 200);
strncat(tempFilename, file, 200);
return tempFilename;
}
/**************************************************************************** /****************************************************************************
** ** ** **
@ -62,6 +85,8 @@ if (argc < 3)
return(1); return(1);
} }
FindFilePaths(argv[1]);
xferbuf = malloc(64000); xferbuf = malloc(64000);
if (xferbuf == NULL) if (xferbuf == NULL)
{ {
@ -107,8 +132,8 @@ while (1)
continue; continue;
printf("Processing....%s\n",dbuf); printf("Processing....%s\n",dbuf);
GetCombinedPath(dataPath, dbuf);
InHandle = open(dbuf,O_RDWR|O_BINARY); InHandle = open(tempFilename,O_RDWR|O_BINARY);
if (InHandle < 1) if (InHandle < 1)
{ {

View file

@ -1,5 +1,8 @@
target_config = debug target_config = debug
test_dat_file = ..\example\assets\example.dat
test_out_file = pics.dtf
target_name = bpic target_name = bpic
object_files = bpic.obj object_files = bpic.obj
@ -41,9 +44,9 @@ clean : .SYMBOLIC
.NOCHECK .NOCHECK
run : $(target_name).exe run : $(target_name).exe
$(target_name).exe $(target_name).exe $(test_dat_file) $(test_out_file)
.NOCHECK .NOCHECK
debug : $(target_name).exe debug : $(target_name).exe
wd /swap /trap=rsi $(target_name).exe wd /swap /trap=rsi $(target_name).exe $(test_dat_file) $(test_out_file)