Fixed mbfile adopt command

This commit is contained in:
Michiel Broek 2004-12-22 12:12:10 +00:00
parent a9b52fc476
commit db587ddcd8
5 changed files with 52 additions and 13 deletions

View File

@ -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.

2
TODO
View File

@ -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

View File

@ -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);

View File

@ -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;
}

View File

@ -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