Implemented name DOS 8.3 name mangling

This commit is contained in:
Michiel Broek
2001-11-27 22:55:00 +00:00
parent 406abe81e6
commit cae45854ab
6 changed files with 175 additions and 492 deletions

View File

@@ -273,16 +273,12 @@ void AdoptFile(int Area, char *File, char *Description)
*/
chdir(pwd);
DeleteVirusWork();
if (strlen(File) < 13) {
strcpy(fdb.Name, File);
for (i = 0; i < strlen(File); i++)
fdb.Name[i] = toupper(fdb.Name[i]);
} else {
WriteError("Long filename conversion not supported");
if (!do_quiet)
printf("Long filename conversion not supported\n");
die(0);
}
/*
* Convert to 8.3 DOS filename
*/
strcpy(temp2, File);
name_mangle(temp2, TRUE);
strcpy(fdb.Name, temp2);
strcpy(fdb.LName, File);
fdb.Size = file_size(File);
fdb.Crc32 = file_crc(File, TRUE);

View File

@@ -64,7 +64,7 @@ void Check(void)
FILE *pAreas, *pFile;
int i, iAreas, iAreasNew = 0;
int iTotal = 0, iErrors = 0;
char *sAreas, *fAreas, *newdir;
char *sAreas, *fAreas, *newdir, *temp;
DIR *dp;
struct dirent *de;
int Found, Update;
@@ -74,6 +74,7 @@ void Check(void)
sAreas = calloc(PATH_MAX, sizeof(char));
fAreas = calloc(PATH_MAX, sizeof(char));
newdir = calloc(PATH_MAX, sizeof(char));
temp = calloc(PATH_MAX, sizeof(char));
if (!do_quiet) {
colour(3, 0);
@@ -154,6 +155,15 @@ void Check(void)
*/
Marker();
Update = FALSE;
strcpy(temp, file.LName);
name_mangle(temp, TRUE);
if (strcmp(file.Name, temp)) {
Syslog('!', "Converted %s to %s", file.Name, temp);
strncpy(file.Name, temp, 12);
iErrors++;
Update = TRUE;
}
if (file_time(newdir) != file.FileDate) {
Syslog('!', "Date mismatch area %d file %s", i, file.LName);
file.FileDate = file_time(newdir);
@@ -236,6 +246,7 @@ void Check(void)
fflush(stdout);
}
free(temp);
free(newdir);
free(sAreas);
free(fAreas);

View File

@@ -187,8 +187,31 @@ void ImportFiles(int Area)
memset(&fdb, 0, sizeof(fdb));
token = strtok(String, " \t");
strcpy(fdb.Name, token);
strcpy(fdb.LName, tl(token));
strcpy(fdb.LName, token);
/*
* Test filename against name on disk, first normal case,
* then lowercase and finally uppercase.
*/
sprintf(temp,"%s/%s", pwd, fdb.LName);
if (stat(temp,&statfile) != 0) {
strcpy(fdb.LName, tl(token));
sprintf(temp,"%s/%s", pwd, fdb.LName);
if (stat(temp,&statfile) != 0) {
strcpy(fdb.LName, tu(token));
if (stat(temp,&statfile) != 0) {
WriteError("Cannot locate file on disk! Skipping... -> %s\n",temp);
Append = FALSE;
}
}
}
/*
* Create DOS 8.3 filename
*/
strcpy(temp, fdb.LName);
name_mangle(temp, TRUE);
strcpy(fdb.Name, temp);
if (do_annon)
fdb.Announced = TRUE;
Syslog('f', "File: %s (%s)", fdb.Name, fdb.LName);
@@ -237,14 +260,6 @@ void ImportFiles(int Area)
}
}
sprintf(temp,"%s/%s", pwd, fdb.LName);
if (stat(temp,&statfile) != 0) {
sprintf(temp,"%s/%s", pwd, fdb.Name);
if (stat(temp,&statfile) != 0) {
WriteError("Cannot locate file on disk! Skipping... -> %s\n",temp);
Append = FALSE;
}
}
sprintf(dest, "%s/%s", area.Path, fdb.LName);
Append = TRUE;
fdb.Size = statfile.st_size;