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:
parent
2482fe7bbb
commit
810f1244b8
29
bpic/bpic.c
29
bpic/bpic.c
|
@ -13,6 +13,29 @@
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
FindFilePaths(argv[1]);
|
||||
|
||||
xferbuf = malloc(64000);
|
||||
if (xferbuf == NULL)
|
||||
{
|
||||
|
@ -107,8 +132,8 @@ while (1)
|
|||
continue;
|
||||
|
||||
printf("Processing....%s\n",dbuf);
|
||||
|
||||
InHandle = open(dbuf,O_RDWR|O_BINARY);
|
||||
GetCombinedPath(dataPath, dbuf);
|
||||
InHandle = open(tempFilename,O_RDWR|O_BINARY);
|
||||
|
||||
if (InHandle < 1)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
target_config = debug
|
||||
|
||||
test_dat_file = ..\example\assets\example.dat
|
||||
test_out_file = pics.dtf
|
||||
|
||||
target_name = bpic
|
||||
|
||||
object_files = bpic.obj
|
||||
|
@ -41,9 +44,9 @@ clean : .SYMBOLIC
|
|||
|
||||
.NOCHECK
|
||||
run : $(target_name).exe
|
||||
$(target_name).exe
|
||||
$(target_name).exe $(test_dat_file) $(test_out_file)
|
||||
|
||||
.NOCHECK
|
||||
debug : $(target_name).exe
|
||||
wd /swap /trap=rsi $(target_name).exe
|
||||
wd /swap /trap=rsi $(target_name).exe $(test_dat_file) $(test_out_file)
|
||||
|
||||
|
|
Loading…
Reference in a new issue