Added new filecase test function

This commit is contained in:
Michiel Broek 2003-02-27 20:57:36 +00:00
parent 81aa0911a5
commit edad301e0a
4 changed files with 70 additions and 22 deletions

View File

@ -11,6 +11,11 @@ v0.37.2 23-Feb-2003.
System prepared for setting the official FTSC product code,
this will be 0x11FF. The code is not yet activated.
common.a:
New function to get the real case of a filename.
mbfido:
Finding the inbound tic file now uses the new function.
v0.37.1 14-Jan-2003 - 23-Feb-2003

View File

@ -283,6 +283,8 @@ long file_crc(char *path, int);
time_t file_time(char *path);
int mkdirs(char *name, mode_t);
int diskfree(int);
int getfilecase(char *, char *);
/*

View File

@ -4,7 +4,7 @@
* Purpose ...............: Basic File I/O
*
*****************************************************************************
* Copyright (C) 1997-2002
* Copyright (C) 1997-2003
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -346,3 +346,34 @@ int diskfree(int needed)
}
/*
* Give a directory path and a filename, locate that filename in that
* directory and return the filename with the correct case. This is
* to be able to detect filename.ext, FILENAME.EXT and FiLeNaMe.ExT
*/
int getfilecase(char *path, char *file)
{
DIR *dp;
struct dirent *de;
int i, rc = FALSE;
if ((dp = opendir(path)) == NULL) {
WriteError("$Can't opendir(%s)", path);
return rc;
}
while ((de = readdir(dp))) {
if (strcasecmp(de->d_name, file) == 0) {
for (i = 0; i < strlen(de->d_name); i++)
file[i] = de->d_name[i];
rc = TRUE;
break;
}
}
closedir(dp);
return rc;
}

View File

@ -168,8 +168,8 @@ int LoadTic(char *inb, char *tfn)
char *Temp, *Temp2, *Buf, *Log = NULL, RealName[256];
int i, j, rc, bufsize, DescCnt = FALSE;
fa_list *sbl = NULL;
DIR *dp;
struct dirent *de;
// DIR *dp;
// struct dirent *de;
if (CFG.slow_util && do_quiet)
usleep(1);
@ -427,27 +427,36 @@ int LoadTic(char *inb, char *tfn)
* Find out what the real name of the file is,
* most likely this is a 8.3 filename.
*/
if ((dp = opendir(TIC.Inbound)) == NULL) {
WriteError("$Can't opendir(%s)", TIC.Inbound);
return 1;
}
while ((de = readdir(dp))) {
/*
* Check 8.3 FN
*/
if (strcasecmp(de->d_name, TIC.TicIn.File) == 0) {
strncpy(RealName, de->d_name, 255);
break;
}
/*
* Check LFN
*/
if (strcasecmp(de->d_name, TIC.TicIn.FullName) == 0) {
strncpy(RealName, de->d_name, 255);
break;
// if ((dp = opendir(TIC.Inbound)) == NULL) {
// WriteError("$Can't opendir(%s)", TIC.Inbound);
// return 1;
// }
// while ((de = readdir(dp))) {
// /*
// * Check 8.3 FN
// */
// if (strcasecmp(de->d_name, TIC.TicIn.File) == 0) {
// strncpy(RealName, de->d_name, 255);
// break;
// }
// /*
// * Check LFN
// */
// if (strcasecmp(de->d_name, TIC.TicIn.FullName) == 0) {
// strncpy(RealName, de->d_name, 255);
// break;
// }
// }
// closedir(dp);
strncpy(RealName, TIC.TicIn.File, 255);
Syslog('f', "getfilecase(%s, %s)", TIC.Inbound, RealName);
if (! getfilecase(TIC.Inbound, RealName)) {
strncpy(RealName, TIC.TicIn.FullName, 255);
Syslog('f', "getfilecase(%s, %s)", TIC.Inbound, RealName);
if (! getfilecase(TIC.Inbound, RealName)) {
memset(&RealName, 0, sizeof(RealName));
}
}
closedir(dp);
}
if (strlen(RealName) == 0) {
@ -458,6 +467,7 @@ int LoadTic(char *inb, char *tfn)
TIC.Orphaned = TRUE;
WriteError("Can't find file in inbound");
} else {
Syslog('f', "Returned RealName %s", RealName);
/*
* If no LFN received in the ticfile and the file in the inbound is the same as the 8.3 name
* but only the case is different, then treat the real filename as LFN.