git » fp-git.git » commit 15d5ab2

plv checksum corruption is now a warning

author ecalot
2005-03-26 13:25:07 UTC
committer ecalot
2005-03-26 13:25:07 UTC
parent 9bd8302bd25cd1cf182870fc73d44af5f0453d08

plv checksum corruption is now a warning

PR/src/include/en.lang.pr.h +1 -0
PR/src/lib/formats/plv.c +5 -2
PR/src/lib/pr.c +9 -2

diff --git a/PR/src/include/en.lang.pr.h b/PR/src/include/en.lang.pr.h
index 7fca0e2..9988520 100644
--- a/PR/src/include/en.lang.pr.h
+++ b/PR/src/include/en.lang.pr.h
@@ -66,6 +66,7 @@ pr.h: Princed Resources : English language strings
 #define PR_TEXT_IMPORT_SUCCESS    "'%s' successfully imported\n"
 #define PR_TEXT_IMPORT_ERRORS     "'%s' has errors, skipped\n"
 #define PR_TEXT_IMPORT_DONE       "Importing done, %d files imported ok, %d files with error\n"
+#define PR_TEXT_IMPORT_PLV_WARN   "Warning: PLV file may be corrupt\n"
 
 #define PR_TEXT_EXPORT_WORKING    "'%s' successfully exported\n"
 #define PR_TEXT_EXPORT_ERROR      "'%s' has errors, aborting...\n"
diff --git a/PR/src/lib/formats/plv.c b/PR/src/lib/formats/plv.c
index 45b7753..5c0b2ea 100644
--- a/PR/src/lib/formats/plv.c
+++ b/PR/src/lib/formats/plv.c
@@ -160,6 +160,8 @@ int mFormatExportPlv(const unsigned char* data, const char *vFileext,unsigned lo
 	return ok;
 }
 
+extern FILE* outputStream;
+
 int mFormatImportPlv(unsigned char* data, tResource *res) {
 	/* declare variables */
 	unsigned char* pos;
@@ -179,10 +181,11 @@ int mFormatImportPlv(unsigned char* data, tResource *res) {
 	if (oldSize<=PLV_HEADER_A_SIZE+1+PLV_HEADER_B_SIZE+res->size) return 0;
 
 	/* validate checksum */
-	if (!checkSum(pos,res->size)) return 0;
+	if (!checkSum(pos,res->size))
+		fprintf(outputStream,PR_TEXT_IMPORT_PLV_WARN);
 
 	/* save data */
 	mWriteFileInDatFileIgnoreChecksum(pos,res->size--);
-
+	
 	return 1;
 }
diff --git a/PR/src/lib/pr.c b/PR/src/lib/pr.c
index 8dd9501..d884694 100644
--- a/PR/src/lib/pr.c
+++ b/PR/src/lib/pr.c
@@ -201,9 +201,14 @@ int prImportDatOpt(const char* vDatFile, const char* vDirName, const char* vResF
 	int a;
 	const char* aux;
 	char* currentDatFileName;
+	char* currentDatFile;
+
+	currentDatFile=strallocandcopy(vDatFile);
+
+	parseGivenPath(currentDatFile);
 
 	if (vDatFileName==NULL) { /* if no special dat file was specified, a path parsed will be used */
-		aux=getFileNameFromPath(vDatFile);
+		aux=getFileNameFromPath(currentDatFile);
 	} else {
 		aux=vDatFileName;
 	}
@@ -216,9 +221,11 @@ int prImportDatOpt(const char* vDatFile, const char* vDirName, const char* vResF
 		a-=2;
 	} else {
 		/* importing errors/no errors */
-		a=compile (vDatFile, vDirName,r,opt,currentDatFileName,backupExtension);
+		a=compile (currentDatFile, vDirName,r,opt,currentDatFileName,backupExtension);
 	}
 	free(currentDatFileName);
+	free(currentDatFile);
+	freePartialList();
 	return a;
 }