From db587ddcd809c17d79e5b4f63a00b0a3e8c4e0a8 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Wed, 22 Dec 2004 12:12:10 +0000 Subject: [PATCH] Fixed mbfile adopt command --- ChangeLog | 4 ++++ TODO | 2 -- mbfido/mbfadopt.c | 40 +++++++++++++++++++++++++++++----------- mbfido/mbfutil.c | 18 ++++++++++++++++++ mbfido/mbfutil.h | 1 + 5 files changed, 52 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 29de1658..d8cd5dd9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,10 @@ v0.71.1 28-Nov-2004 mbnewuser: During hangup we set sighup to ignore. + mbfile: + The adopt command now first checks if the filename is 8.3 or a + long filename and the correct format for import is then set. + examples: Removed bbs list items from the English menus and txtfiles and the Spanish menus and txtfiles. diff --git a/TODO b/TODO index d9c766a7..1dba85cd 100644 --- a/TODO +++ b/TODO @@ -146,8 +146,6 @@ mbfile: N: It is not possible to import areas that run of cd-roms. Do we still need cd-rom support with current hd prices? - N: The adopt command switches the LFN and 8.3 name. - N: The import command doesn't work with long filenames. N: Several import commands shoudlcheck ownership of the files before diff --git a/mbfido/mbfadopt.c b/mbfido/mbfadopt.c index 46a42264..1a43cf1f 100644 --- a/mbfido/mbfadopt.c +++ b/mbfido/mbfadopt.c @@ -257,16 +257,34 @@ void AdoptFile(int Area, char *File, char *Description) chdir(pwd); DeleteVirusWork(); /* - * Convert to 8.3 DOS filename + * Work out the kind of filename, is it a long filename + * or a 8.3 DOS filename. The file on disk must become + * 8.3 for import. */ - strcpy(temp2, File); - name_mangle(temp2); - strcpy(f_db.Name, temp2); - strcpy(f_db.LName, File); - f_db.Size = file_size(File); - f_db.Crc32 = file_crc(File, TRUE); - f_db.FileDate = file_time(File); - sprintf(temp2, "%s/%s", area.Path, File); + if (is_real_8_3(File)) { + Syslog('f', "Adopt, file is 8.3"); + strcpy(f_db.Name, File); + strcpy(f_db.LName, File); + for (i = 0; i < strlen(File); i++) + if (isupper(f_db.LName[i])) + f_db.LName[i] = tolower(f_db.LName[i]); + } else { + Syslog('f', "Adopt, file is LFN"); + strcpy(temp2, File); + name_mangle(temp2); + if (rename(File, temp2)) { + Syslog('+', "Can't rename %s to %s", File, temp2); + if (!do_quiet) + printf("\nCan't rename %s to %s\n", File, temp2); + die(MBERR_GENERAL); + } + strcpy(f_db.Name, temp2); + strcpy(f_db.LName, File); + } + f_db.Size = file_size(f_db.Name); + f_db.Crc32 = file_crc(f_db.Name, TRUE); + f_db.FileDate = file_time(f_db.Name); + sprintf(temp2, "%s/%s", area.Path, f_db.Name); if (!do_quiet) { printf("Adding \b\b\b\b\b\b\b\b\b\b"); @@ -275,8 +293,8 @@ void AdoptFile(int Area, char *File, char *Description) if (strcmp(f_db.Name, f_db.LName)) { lname = calloc(PATH_MAX, sizeof(char)); - sprintf(lname, "%s/%s", area.Path, f_db.Name); - if (AddFile(f_db, Area, temp2, File, lname) == FALSE) { + sprintf(lname, "%s/%s", area.Path, f_db.LName); + if (AddFile(f_db, Area, temp2, f_db.Name, lname) == FALSE) { die(MBERR_GENERAL); } free(lname); diff --git a/mbfido/mbfutil.c b/mbfido/mbfutil.c index 2a4d2990..643bc035 100644 --- a/mbfido/mbfutil.c +++ b/mbfido/mbfutil.c @@ -307,6 +307,11 @@ int AddFile(struct FILE_record f_db, int Area, char *DestPath, char *FromPath, c int rc; struct _fdbarea *fdb_area = NULL; + Syslog('f', "AddFile Area : %d", Area); + Syslog('f', "AddFile DestPath: %s", MBSE_SS(DestPath)); + Syslog('f', "AddFile FromPath: %s", MBSE_SS(FromPath)); + Syslog('f', "AddFile LinkPath: %s", MBSE_SS(LinkPath)); + /* * Copy file to the final destination and make a hard link with the * 8.3 filename to the long filename. @@ -442,3 +447,16 @@ int LoadAreaRec(int Area) } + +int is_real_8_3(char *File) +{ + int i; + + if (! is_8_3(File)) + return FALSE; + for (i = 0; i < strlen(File); i++) + if (isalpha(File[i]) && islower(File[i])) + return FALSE; + return TRUE; +} + diff --git a/mbfido/mbfutil.h b/mbfido/mbfutil.h index 024036b4..467c6610 100644 --- a/mbfido/mbfutil.h +++ b/mbfido/mbfutil.h @@ -12,5 +12,6 @@ int UnpackFile(char *File); /* Unpack archive */ int AddFile(struct FILE_record, int, char *, char *, char *); int CheckFDB(int, char *); /* Check FDB of area */ int LoadAreaRec(int); /* Load Area record */ +int is_real_8_3(char *); /* Check for 8.3 uppercase */ #endif