diff --git a/bpic/bpic.c b/bpic/bpic.c index f5fa8d9..1a99b68 100644 --- a/bpic/bpic.c +++ b/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) { diff --git a/bpic/makefile b/bpic/makefile index 05d3823..6891554 100644 --- a/bpic/makefile +++ b/bpic/makefile @@ -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)