Added better support for short and long filenames
This commit is contained in:
parent
85bd9bcd1e
commit
ffe9331fb0
26
ChangeLog
26
ChangeLog
@ -5,21 +5,47 @@ $Id$
|
||||
|
||||
v0.35.06
|
||||
|
||||
update:
|
||||
Run "mbfile check". This will create a error in the logfile
|
||||
for each file! It will update the filenames on disk to have
|
||||
both short and long filenames. Just ignore the errors!
|
||||
|
||||
general:
|
||||
This may become release 0.36.00 (again).
|
||||
Added better support for 8.3 and long filenames by creating
|
||||
hard links in the download directories.
|
||||
|
||||
mbsebbs:
|
||||
Several user input functions don't allow comma's anymore.
|
||||
Uploaded files will now also have a 8.3 hard link to the long
|
||||
filename.
|
||||
Filesearch on filename now uses regexp to find the files.
|
||||
|
||||
mbfido:
|
||||
TIC file forwarding now uses a list of qualified systems to
|
||||
forward to, and with this information builds more reliable
|
||||
seen-by lines.
|
||||
Imported tic files with a new banner file in the archive got
|
||||
the wrong filetime in the files database. The mbfile check
|
||||
command would detect and correct this.
|
||||
TIC files added to the bbs will now also have a 8.3 hard link.
|
||||
|
||||
mbcico:
|
||||
With filetransfer errors, the attempts counter was not
|
||||
increased.
|
||||
|
||||
mbfile:
|
||||
Finished complete support for 8.3 and long filenames.
|
||||
The check function now creates hard links in the download
|
||||
areas with the 8.3 filename to the long filename so that the
|
||||
files seem to exist under both names.
|
||||
The delete and move functions can now use 8.3 or long
|
||||
filenames as argument.
|
||||
|
||||
mbsetup:
|
||||
In filedatabase editor, if a file is deleted the name is
|
||||
displayed in light blue.
|
||||
|
||||
|
||||
v0.35.05 19-Oct-2002 - 13-Nov-2002.
|
||||
|
||||
|
@ -267,8 +267,8 @@
|
||||
266 change.c |Protocol now set to:
|
||||
267 file.c |Enter keyword to use for Search:
|
||||
268 file.c |File Search by Keyword
|
||||
269 file.c |Accepts wildcards such as : *.zip, *.gz, .tar*
|
||||
270 file.c | : *.zip is the same as .zip
|
||||
269 file.c |Accepts wildcards such as : *.zip, *.gz, *.*
|
||||
270 | : *.zip is the same as .zip
|
||||
271 file.c |Enter filename to search for :
|
||||
272 file.c |File Search by Filename
|
||||
273 file.c YN|Search for new since your last call [Y/n]:
|
||||
|
@ -267,7 +267,7 @@ JN|Node onbekend, toch doorgaan [j/N]:
|
||||
|Het protocol is nu:
|
||||
|Geef sleutelwoord om op te zoeken :
|
||||
|Bestanden zoeken op sleutelwoord
|
||||
|Accepteerd jokers zoals : *.zip, *.gz, .tar*
|
||||
|Accepteerd jokers zoals : *.zip, *.gz, *.*
|
||||
| : *.zip is hetzelfde als .zip
|
||||
|Geef bestandsnaam om naar te zoeken :
|
||||
|Bestanden zoeken op naam
|
||||
|
@ -267,7 +267,7 @@ YN|Node not known, continue anyway [y/N]:
|
||||
|Protocol now set to:
|
||||
|Enter keyword to use for Search:
|
||||
|File Search by Keyword
|
||||
|Accepts wildcards such as : *.zip, *.gz, .tar*
|
||||
|Accepts wildcards such as : *.zip, *.gz, *.*
|
||||
| : *.zip is the same as .zip
|
||||
|Enter filename to search for :
|
||||
|File Search by Filename
|
||||
|
@ -267,7 +267,7 @@ SN|Nodo desco
|
||||
|Protocolo predeterminado:
|
||||
|Palabra a buscar:
|
||||
|Buscar ficheiro por unha palabra
|
||||
|Aceptanse comodins coma : *.zip, *.gz, .tar*
|
||||
|Aceptanse comodins coma : *.zip, *.gz, *.*
|
||||
| : *.zip es lo mismo que .zip
|
||||
|Nome do ficheiro a buscar:
|
||||
|Buscar ficheiro por nome
|
||||
|
@ -267,7 +267,7 @@ JN|Adresse unbekannt, dennoch fortfahren [j/N]:
|
||||
|Standardprotokoll ist jetzt:
|
||||
|Bitte den Suchbegriff eingeben:
|
||||
|Dateisuche nach Schluesselwort
|
||||
|Akzeptiert Platzhalter wie: *.zip, *.gz, .tar*
|
||||
|Akzeptiert Platzhalter wie: *.zip, *.gz, *.*
|
||||
| *.zip entspricht .zip
|
||||
|Geben Sie den zu suchenden Dateinamen an:
|
||||
|Dateisuche nach Dateinamen
|
||||
|
@ -267,7 +267,7 @@ SN|Nodo sconosciuto, continua lo stesso [s/N]:
|
||||
|Protocollo impostato su:
|
||||
|Inserisci la parola da cercare:
|
||||
|Ricerca file per parola chiave
|
||||
|Accetto caratteri jolly come : *.zip, *.gz, .tar*
|
||||
|Accetto caratteri jolly come : *.zip, *.gz, *.*
|
||||
| : *.zip e' equivalente a .zip
|
||||
|Scegli il filename da cercare:
|
||||
|Ricerca per nome del file
|
||||
|
@ -267,7 +267,7 @@ SN|Nodo desconocido.
|
||||
|Protocolo predeterminado:
|
||||
|Palabra a buscar:
|
||||
|Buscar fichero por una palabra
|
||||
|Se aceptan comodines como : *.zip, *.gz, .tar*
|
||||
|Se aceptan comodines como : *.zip, *.gz, *.*
|
||||
| : *.zip es lo mismo que .zip
|
||||
|Nombre de fichero a buscar:
|
||||
|Buscar fichero por nombre
|
||||
|
@ -57,7 +57,7 @@ int Add_BBS()
|
||||
struct FILERecord frec;
|
||||
int rc, i, Insert, Done = FALSE, Found = FALSE;
|
||||
char fdbname[PATH_MAX], fdbtemp[PATH_MAX];
|
||||
char temp1[PATH_MAX], temp2[PATH_MAX], *fname;
|
||||
char temp1[PATH_MAX], temp2[PATH_MAX], *fname, *lname;
|
||||
FILE *fdb, *fdt;
|
||||
int Keep = 0, DidDelete = FALSE;
|
||||
fd_list *fdl = NULL;
|
||||
@ -142,6 +142,12 @@ int Add_BBS()
|
||||
return FALSE;
|
||||
}
|
||||
chmod(temp2, 0644);
|
||||
lname = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(lname, "%s/%s", TIC.BBSpath, frec.Name);
|
||||
if (link(temp2, lname)) {
|
||||
WriteError("$Create link %s to %s failed", lname, temp2);
|
||||
}
|
||||
free(lname);
|
||||
|
||||
sprintf(fdbtemp, "%s/fdb/fdb%ld.temp", getenv("MBSE_ROOT"), tic.FileArea);
|
||||
|
||||
@ -365,6 +371,9 @@ int Add_BBS()
|
||||
sprintf(temp2, "%s/%s", area.Path, file.LName);
|
||||
if (unlink(temp2) != 0)
|
||||
WriteError("$Can't unlink file %s", temp2);
|
||||
sprintf(temp2, "%s/%s", area.Path, file.Name);
|
||||
if (unlink(temp2) != 0)
|
||||
WriteError("$Can't unlink file %s", temp2);
|
||||
}
|
||||
fclose(fdb);
|
||||
fclose(fdt);
|
||||
|
@ -52,7 +52,7 @@ extern int do_novir; /* Suppress virus check */
|
||||
void AdoptFile(int Area, char *File, char *Description)
|
||||
{
|
||||
FILE *fp;
|
||||
char *temp, *temp2, *tmpdir, *unarc, *pwd;
|
||||
char *temp, *temp2, *tmpdir, *unarc, *pwd, *lname;
|
||||
char Desc[256], TDesc[256];
|
||||
int IsArchive = FALSE, MustRearc = FALSE, UnPacked = FALSE;
|
||||
int IsVirus = FALSE, File_Id = FALSE;
|
||||
@ -279,8 +279,17 @@ void AdoptFile(int Area, char *File, char *Description)
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
if (AddFile(fdb, Area, temp2, File) == FALSE) {
|
||||
die(MBERR_GENERAL);
|
||||
if (strcmp(fdb.Name, fdb.LName)) {
|
||||
lname = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(lname, "%s/%s", area.Path, fdb.Name);
|
||||
if (AddFile(fdb, Area, temp2, File, lname) == FALSE) {
|
||||
die(MBERR_GENERAL);
|
||||
}
|
||||
free(lname);
|
||||
} else {
|
||||
if (AddFile(fdb, Area, temp2, File, NULL) == FALSE) {
|
||||
die(MBERR_GENERAL);
|
||||
}
|
||||
}
|
||||
Syslog('+', "File %s added to area %d", File, Area);
|
||||
|
||||
|
@ -67,7 +67,7 @@ void Check(void)
|
||||
{
|
||||
FILE *pAreas, *pFile;
|
||||
int i, iAreas, iAreasNew = 0, Fix, inArea, iTotal = 0, iErrors = 0;
|
||||
char *sAreas, *fAreas, *newdir, *temp;
|
||||
char *sAreas, *fAreas, *newdir, *temp, *lname;
|
||||
DIR *dp;
|
||||
struct dirent *de;
|
||||
int Found, Update;
|
||||
@ -80,6 +80,7 @@ void Check(void)
|
||||
fAreas = calloc(PATH_MAX, sizeof(char));
|
||||
newdir = calloc(PATH_MAX, sizeof(char));
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
lname = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
if (!do_quiet) {
|
||||
colour(3, 0);
|
||||
@ -221,12 +222,25 @@ void Check(void)
|
||||
|
||||
strcpy(temp, file.LName);
|
||||
name_mangle(temp);
|
||||
sprintf(lname, "%s/%s", area.Path, temp);
|
||||
if (strcmp(file.Name, temp)) {
|
||||
Syslog('!', "Converted %s to %s", file.Name, temp);
|
||||
strncpy(file.Name, temp, 12);
|
||||
iErrors++;
|
||||
Update = TRUE;
|
||||
}
|
||||
/*
|
||||
* Check hard link to the short/mangled filename.
|
||||
*/
|
||||
if (strcmp(file.Name, file.LName)) {
|
||||
if (file_exist(lname, F_OK)) {
|
||||
if (link(newdir, lname)) {
|
||||
WriteError("$Can't create link %s to %s", lname, newdir);
|
||||
} else {
|
||||
Syslog('!', "Created hard link area %d LFN %s to 8.3 %s", i, file.LName, file.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (file_time(newdir) != file.FileDate) {
|
||||
Syslog('!', "Date mismatch area %d file %s", i, file.LName);
|
||||
file.FileDate = file_time(newdir);
|
||||
@ -267,7 +281,7 @@ void Check(void)
|
||||
Found = FALSE;
|
||||
rewind(pFile);
|
||||
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
||||
if (strcmp(file.LName, de->d_name) == 0) {
|
||||
if ((strcmp(file.LName, de->d_name) == 0) || (strcmp(file.Name, de->d_name) == 0)) {
|
||||
if (!Found) {
|
||||
Found = TRUE;
|
||||
} else {
|
||||
@ -331,6 +345,7 @@ void Check(void)
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
free(lname);
|
||||
free(temp);
|
||||
free(newdir);
|
||||
free(sAreas);
|
||||
|
@ -94,7 +94,7 @@ void Delete(int UnDel, int Area, char *File)
|
||||
colour(CYAN, BLACK);
|
||||
|
||||
while (fread(&fdb, sizeof(fdb), 1, fp) == 1) {
|
||||
if (! strcmp(fdb.LName, File)) {
|
||||
if ((! strcmp(fdb.LName, File) || (! strcmp(fdb.Name, File)))) {
|
||||
if (UnDel && fdb.Deleted) {
|
||||
fdb.Deleted = FALSE;
|
||||
Syslog('+', "Marked file %s in area %d for undeletion", File, Area);
|
||||
|
@ -51,7 +51,7 @@ extern int do_novir; /* Suppress virus scanning */
|
||||
|
||||
void ImportFiles(int Area)
|
||||
{
|
||||
char *pwd, *temp, *temp2, *tmpdir, *String, *token, *dest, *unarc;
|
||||
char *pwd, *temp, *temp2, *tmpdir, *String, *token, *dest, *unarc, *lname;
|
||||
FILE *fbbs;
|
||||
int Append = FALSE, Files = 0, rc, i, j = 0, k = 0, x, Doit;
|
||||
int Imported = 0, Errors = 0, Present = FALSE;
|
||||
@ -73,6 +73,7 @@ void ImportFiles(int Area)
|
||||
tmpdir = calloc(PATH_MAX, sizeof(char));
|
||||
String = calloc(4096, sizeof(char));
|
||||
dest = calloc(PATH_MAX, sizeof(char));
|
||||
lname = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
getcwd(pwd, PATH_MAX);
|
||||
if (CheckFDB(Area, area.Path))
|
||||
@ -151,10 +152,19 @@ void ImportFiles(int Area)
|
||||
printf("Adding \b\b\b\b\b\b\b\b\b\b");
|
||||
fflush(stdout);
|
||||
}
|
||||
if (AddFile(fdb, Area, dest, temp)) {
|
||||
Imported++;
|
||||
} else
|
||||
Errors++;
|
||||
if (strcmp(fdb.Name, fdb.LName)) {
|
||||
if (AddFile(fdb, Area, dest, temp, lname)) {
|
||||
Imported++;
|
||||
} else {
|
||||
Errors++;
|
||||
}
|
||||
} else {
|
||||
if (AddFile(fdb, Area, dest, temp, NULL)) {
|
||||
Imported++;
|
||||
} else {
|
||||
Errors++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Errors++;
|
||||
}
|
||||
@ -252,6 +262,7 @@ void ImportFiles(int Area)
|
||||
}
|
||||
|
||||
sprintf(dest, "%s/%s", area.Path, fdb.LName);
|
||||
sprintf(lname, "%s/%s", area.Path, fdb.Name);
|
||||
Append = TRUE;
|
||||
fdb.Size = statfile.st_size;
|
||||
fdb.FileDate = statfile.st_mtime;
|
||||
@ -354,15 +365,23 @@ void ImportFiles(int Area)
|
||||
printf("Adding \b\b\b\b\b\b\b\b\b\b");
|
||||
fflush(stdout);
|
||||
}
|
||||
if (AddFile(fdb, Area, dest, temp))
|
||||
Imported++;
|
||||
else
|
||||
Errors++;
|
||||
if (strcmp(fdb.Name, fdb.LName)) {
|
||||
if (AddFile(fdb, Area, dest, temp, lname))
|
||||
Imported++;
|
||||
else
|
||||
Errors++;
|
||||
} else {
|
||||
if (AddFile(fdb, Area, dest, temp, NULL))
|
||||
Imported++;
|
||||
else
|
||||
Errors++;
|
||||
}
|
||||
} else {
|
||||
Errors++;
|
||||
}
|
||||
}
|
||||
|
||||
free(lname);
|
||||
free(dest);
|
||||
free(String);
|
||||
free(pwd);
|
||||
|
@ -52,10 +52,10 @@ extern int do_quiet; /* Suppress screen output */
|
||||
*/
|
||||
void Move(int From, int To, char *File)
|
||||
{
|
||||
char *frompath, *topath, *temp1, *temp2;
|
||||
char *frompath, *topath, *temp1, *temp2, *fromlink, *tolink;
|
||||
struct FILERecord fdb;
|
||||
FILE *fp1, *fp2;
|
||||
int rc = FALSE;
|
||||
int rc = FALSE, Found = FALSE;
|
||||
|
||||
IsDoing("Move file");
|
||||
colour(LIGHTRED, BLACK);
|
||||
@ -88,9 +88,35 @@ void Move(int From, int To, char *File)
|
||||
}
|
||||
if (CheckFDB(From, area.Path))
|
||||
die(MBERR_GENERAL);
|
||||
|
||||
/*
|
||||
* Find the file in the "from" area, check LFN and 8.3 names.
|
||||
*/
|
||||
temp1 = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(temp1, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), From);
|
||||
if ((fp1 = fopen(temp1, "r")) == NULL)
|
||||
die(MBERR_GENERAL);
|
||||
while (fread(&fdb, sizeof(fdb), 1, fp1) == 1) {
|
||||
if ((strcmp(fdb.LName, File) == 0) || strcmp(fdb.Name, File) == 0) {
|
||||
Found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(fp1);
|
||||
if (!Found) {
|
||||
WriteError("File %s not found in area %d", File, From);
|
||||
if (!do_quiet)
|
||||
printf("File %s not found in area %d\n", File, From);
|
||||
free(temp1);
|
||||
die(MBERR_GENERAL);
|
||||
}
|
||||
|
||||
frompath = xstrcpy(area.Path);
|
||||
frompath = xstrcat(frompath, (char *)"/");
|
||||
frompath = xstrcat(frompath, File);
|
||||
frompath = xstrcat(frompath, fdb.LName);
|
||||
fromlink = xstrcpy(area.Path);
|
||||
fromlink = xstrcat(fromlink, (char *)"/");
|
||||
fromlink = xstrcat(fromlink, fdb.Name);
|
||||
|
||||
/*
|
||||
* Check Destination area
|
||||
@ -113,13 +139,15 @@ void Move(int From, int To, char *File)
|
||||
}
|
||||
if (CheckFDB(To, area.Path))
|
||||
die(MBERR_GENERAL);
|
||||
|
||||
topath = xstrcpy(area.Path);
|
||||
topath = xstrcat(topath, (char *)"/");
|
||||
topath = xstrcat(topath, File);
|
||||
topath = xstrcat(topath, fdb.LName);
|
||||
tolink = xstrcpy(area.Path);
|
||||
tolink = xstrcat(tolink, (char *)"/");
|
||||
tolink = xstrcat(tolink, fdb.Name);
|
||||
|
||||
temp1 = calloc(PATH_MAX, sizeof(char));
|
||||
temp2 = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(temp1, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), From);
|
||||
sprintf(temp2, "%s/fdb/fdb%d.temp", getenv("MBSE_ROOT"), From);
|
||||
|
||||
if ((fp1 = fopen(temp1, "r")) == NULL)
|
||||
@ -133,11 +161,19 @@ void Move(int From, int To, char *File)
|
||||
* file.
|
||||
*/
|
||||
while (fread(&fdb, sizeof(fdb), 1, fp1) == 1) {
|
||||
if (strcmp(fdb.LName, File))
|
||||
if (strcmp(fdb.LName, File) && strcmp(fdb.Name, File))
|
||||
fwrite(&fdb, sizeof(fdb), 1, fp2);
|
||||
else {
|
||||
rc = AddFile(fdb, To, topath, frompath);
|
||||
if (strcmp(fdb.Name, fdb.LName))
|
||||
rc = AddFile(fdb, To, topath, frompath, tolink);
|
||||
else
|
||||
rc = AddFile(fdb, To, topath, frompath, NULL);
|
||||
if (rc) {
|
||||
/*
|
||||
* Remove old 8.3 name
|
||||
*/
|
||||
if (strcmp(fdb.Name, fdb.LName))
|
||||
unlink(fromlink);
|
||||
/*
|
||||
* Try to move thumbnail if it exists
|
||||
*/
|
||||
@ -189,7 +225,9 @@ void Move(int From, int To, char *File)
|
||||
free(temp1);
|
||||
free(temp2);
|
||||
free(frompath);
|
||||
free(fromlink);
|
||||
free(topath);
|
||||
free(tolink);
|
||||
}
|
||||
|
||||
|
||||
|
193
mbfido/mbfpack.c
193
mbfido/mbfpack.c
@ -53,113 +53,116 @@ extern int do_index; /* Reindex filebases */
|
||||
*/
|
||||
void PackFileBase(void)
|
||||
{
|
||||
FILE *fp, *pAreas, *pFile;
|
||||
int i, iAreas, iAreasNew = 0, rc;
|
||||
int iTotal = 0, iRemoved = 0;
|
||||
char *sAreas, *fAreas, *fTmp, fn[PATH_MAX];
|
||||
FILE *fp, *pAreas, *pFile;
|
||||
int i, iAreas, iAreasNew = 0, rc, iTotal = 0, iRemoved = 0;
|
||||
char *sAreas, *fAreas, *fTmp, fn[PATH_MAX];
|
||||
|
||||
sAreas = calloc(PATH_MAX, sizeof(char));
|
||||
fAreas = calloc(PATH_MAX, sizeof(char));
|
||||
fTmp = calloc(PATH_MAX, sizeof(char));
|
||||
sAreas = calloc(PATH_MAX, sizeof(char));
|
||||
fAreas = calloc(PATH_MAX, sizeof(char));
|
||||
fTmp = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
IsDoing("Pack filebase");
|
||||
if (!do_quiet) {
|
||||
colour(3, 0);
|
||||
printf("Packing file database...\n");
|
||||
}
|
||||
IsDoing("Pack filebase");
|
||||
if (!do_quiet) {
|
||||
colour(3, 0);
|
||||
printf("Packing file database...\n");
|
||||
}
|
||||
|
||||
sprintf(sAreas, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
|
||||
sprintf(sAreas, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
|
||||
|
||||
if ((pAreas = fopen (sAreas, "r")) == NULL) {
|
||||
WriteError("Can't open %s", sAreas);
|
||||
die(MBERR_INIT_ERROR);
|
||||
}
|
||||
if ((pAreas = fopen (sAreas, "r")) == NULL) {
|
||||
WriteError("Can't open %s", sAreas);
|
||||
die(MBERR_INIT_ERROR);
|
||||
}
|
||||
|
||||
fread(&areahdr, sizeof(areahdr), 1, pAreas);
|
||||
fseek(pAreas, 0, SEEK_END);
|
||||
iAreas = (ftell(pAreas) - areahdr.hdrsize) / areahdr.recsize;
|
||||
fread(&areahdr, sizeof(areahdr), 1, pAreas);
|
||||
fseek(pAreas, 0, SEEK_END);
|
||||
iAreas = (ftell(pAreas) - areahdr.hdrsize) / areahdr.recsize;
|
||||
|
||||
for (i = 1; i <= iAreas; i++) {
|
||||
for (i = 1; i <= iAreas; i++) {
|
||||
|
||||
fseek(pAreas, ((i-1) * areahdr.recsize) + areahdr.hdrsize, SEEK_SET);
|
||||
fread(&area, areahdr.recsize, 1, pAreas);
|
||||
fseek(pAreas, ((i-1) * areahdr.recsize) + areahdr.hdrsize, SEEK_SET);
|
||||
fread(&area, areahdr.recsize, 1, pAreas);
|
||||
|
||||
if (area.Available && !area.CDrom) {
|
||||
if (area.Available && !area.CDrom) {
|
||||
|
||||
if (!diskfree(CFG.freespace))
|
||||
die(MBERR_DISK_FULL);
|
||||
if (!diskfree(CFG.freespace))
|
||||
die(MBERR_DISK_FULL);
|
||||
|
||||
if (!do_quiet) {
|
||||
printf("\r%4d => %-44s", i, area.Name);
|
||||
fflush(stdout);
|
||||
}
|
||||
Marker();
|
||||
|
||||
sprintf(fAreas, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), i);
|
||||
sprintf(fTmp, "%s/fdb/fdb%d.temp", getenv("MBSE_ROOT"), i);
|
||||
|
||||
if ((pFile = fopen(fAreas, "r")) == NULL) {
|
||||
Syslog('!', "Creating new %s", fAreas);
|
||||
if ((pFile = fopen(fAreas, "a+")) == NULL) {
|
||||
WriteError("$Can't create %s", fAreas);
|
||||
die(MBERR_GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
if ((fp = fopen(fTmp, "a+")) == NULL) {
|
||||
WriteError("$Can't create %s", fTmp);
|
||||
die(MBERR_GENERAL);
|
||||
}
|
||||
|
||||
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
||||
|
||||
iTotal++;
|
||||
|
||||
if ((!file.Deleted) && (!file.Double) && (strcmp(file.Name, "") != 0)) {
|
||||
fwrite(&file, sizeof(file), 1, fp);
|
||||
} else {
|
||||
iRemoved++;
|
||||
if (file.Double) {
|
||||
Syslog('+', "Removed double record file \"%s\" from area %d", file.LName, i);
|
||||
} else {
|
||||
Syslog('+', "Removed file \"%s\" from area %d", file.LName, i);
|
||||
sprintf(fn, "%s/%s", area.Path, file.LName);
|
||||
rc = unlink(fn);
|
||||
if (rc)
|
||||
Syslog('+', "Unlink %s failed, result %d", fn, rc);
|
||||
/*
|
||||
* If a dotted version (thumbnail) exists, remove it silently
|
||||
*/
|
||||
sprintf(fn, "%s/.%s", area.Path, file.LName);
|
||||
unlink(fn);
|
||||
}
|
||||
do_index = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
fclose(pFile);
|
||||
|
||||
if ((rename(fTmp, fAreas)) == 0) {
|
||||
unlink(fTmp);
|
||||
chmod(fAreas, 00660);
|
||||
}
|
||||
iAreasNew++;
|
||||
|
||||
} /* if area.Available */
|
||||
}
|
||||
|
||||
fclose(pAreas);
|
||||
Syslog('+', "Pack Areas [%5d] Files [%5d] Removed [%5d]", iAreasNew, iTotal, iRemoved);
|
||||
|
||||
if (!do_quiet) {
|
||||
printf("\r \r");
|
||||
if (!do_quiet) {
|
||||
printf("\r%4d => %-44s", i, area.Name);
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
Marker();
|
||||
|
||||
free(fTmp);
|
||||
free(sAreas);
|
||||
free(fAreas);
|
||||
sprintf(fAreas, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), i);
|
||||
sprintf(fTmp, "%s/fdb/fdb%d.temp", getenv("MBSE_ROOT"), i);
|
||||
|
||||
if ((pFile = fopen(fAreas, "r")) == NULL) {
|
||||
Syslog('!', "Creating new %s", fAreas);
|
||||
if ((pFile = fopen(fAreas, "a+")) == NULL) {
|
||||
WriteError("$Can't create %s", fAreas);
|
||||
die(MBERR_GENERAL);
|
||||
}
|
||||
}
|
||||
|
||||
if ((fp = fopen(fTmp, "a+")) == NULL) {
|
||||
WriteError("$Can't create %s", fTmp);
|
||||
die(MBERR_GENERAL);
|
||||
}
|
||||
|
||||
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
||||
|
||||
iTotal++;
|
||||
|
||||
if ((!file.Deleted) && (!file.Double) && (strcmp(file.Name, "") != 0)) {
|
||||
fwrite(&file, sizeof(file), 1, fp);
|
||||
} else {
|
||||
iRemoved++;
|
||||
if (file.Double) {
|
||||
Syslog('+', "Removed double record file \"%s\" from area %d", file.LName, i);
|
||||
} else {
|
||||
Syslog('+', "Removed file \"%s\" from area %d", file.LName, i);
|
||||
sprintf(fn, "%s/%s", area.Path, file.LName);
|
||||
rc = unlink(fn);
|
||||
if (rc)
|
||||
Syslog('+', "Unlink %s failed, result %d", fn, rc);
|
||||
sprintf(fn, "%s/%s", area.Path, file.Name);
|
||||
rc = unlink(fn);
|
||||
if (rc)
|
||||
Syslog('+', "Unlink %s failed, result %d", fn, rc);
|
||||
/*
|
||||
* If a dotted version (thumbnail) exists, remove it silently
|
||||
*/
|
||||
sprintf(fn, "%s/.%s", area.Path, file.LName);
|
||||
unlink(fn);
|
||||
}
|
||||
do_index = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
fclose(pFile);
|
||||
|
||||
if ((rename(fTmp, fAreas)) == 0) {
|
||||
unlink(fTmp);
|
||||
chmod(fAreas, 00660);
|
||||
}
|
||||
iAreasNew++;
|
||||
|
||||
} /* if area.Available */
|
||||
}
|
||||
|
||||
fclose(pAreas);
|
||||
Syslog('+', "Pack Areas [%5d] Files [%5d] Removed [%5d]", iAreasNew, iTotal, iRemoved);
|
||||
|
||||
if (!do_quiet) {
|
||||
printf("\r \r");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
free(fTmp);
|
||||
free(sAreas);
|
||||
free(fAreas);
|
||||
}
|
||||
|
||||
|
||||
|
@ -309,12 +309,16 @@ int UnpackFile(char *File)
|
||||
* directory. The fdb record already has all needed
|
||||
* information.
|
||||
*/
|
||||
int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath)
|
||||
int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath, char *LinkPath)
|
||||
{
|
||||
char *temp1, *temp2;
|
||||
FILE *fp1, *fp2;
|
||||
int i, rc, Insert, Done = FALSE, Found = FALSE;
|
||||
|
||||
/*
|
||||
* Copy file to the final destination and make a hard link with the
|
||||
* 8.3 filename to the long filename.
|
||||
*/
|
||||
mkdirs(DestPath, 0775);
|
||||
if ((rc = file_cp(FromPath, DestPath))) {
|
||||
WriteError("Can't copy file in place");
|
||||
@ -323,6 +327,15 @@ int AddFile(struct FILERecord fdb, int Area, char *DestPath, char *FromPath)
|
||||
return FALSE;
|
||||
}
|
||||
chmod(DestPath, 0644);
|
||||
if (LinkPath) {
|
||||
if ((rc = link(DestPath, LinkPath))) {
|
||||
WriteError("Can't create link %s", LinkPath);
|
||||
if (!do_quiet)
|
||||
printf("Can't create link %s, %s\n", LinkPath, strerror(rc));
|
||||
unlink(DestPath);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
temp1 = calloc(PATH_MAX, sizeof(char));
|
||||
temp2 = calloc(PATH_MAX, sizeof(char));
|
||||
|
@ -9,7 +9,7 @@ void Help(void); /* Show help screen */
|
||||
void Marker(void); /* Eyecatcher */
|
||||
void DeleteVirusWork(void); /* Delete unarc directory */
|
||||
int UnpackFile(char *File); /* Unpack archive */
|
||||
int AddFile(struct FILERecord, int, char *, char *);
|
||||
int AddFile(struct FILERecord, int, char *, char *, char *);
|
||||
int CheckFDB(int, char *); /* Check FDB of area */
|
||||
int LoadAreaRec(int); /* Load Area record */
|
||||
|
||||
|
@ -695,16 +695,24 @@ int ProcessTic(fa_list *sbl)
|
||||
* If the file is converted, we set the date of the original
|
||||
* received file as the file creation date.
|
||||
*/
|
||||
sprintf(Temp, "%s/%s", TIC.Inbound, TIC.NewName);
|
||||
if ((MustRearc || DidBanner) && CFG.ct_KeepDate) {
|
||||
if ((tic.Touch) && (tic.FileArea)) {
|
||||
ut.actime = mktime(localtime(&TIC.FileDate));
|
||||
ut.modtime = mktime(localtime(&TIC.FileDate));
|
||||
sprintf(Temp, "%s/%s", TIC.Inbound, TIC.NewName);
|
||||
utime(Temp, &ut);
|
||||
Syslog('-', "Restamp filedate %s to %s", Temp, rfcdate(ut.modtime));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Now make sure the file timestamp is updated. The file may be restamped,
|
||||
* altered by banners etc.
|
||||
*/
|
||||
TIC.FileDate = file_time(Temp);
|
||||
|
||||
/*
|
||||
* If not passthru, import in the BBS.
|
||||
*/
|
||||
if (tic.FileArea) {
|
||||
|
||||
Syslog('+', "Import: %s Area: %s", TIC.NewName, TIC.TicIn.Area);
|
||||
@ -795,21 +803,6 @@ int ProcessTic(fa_list *sbl)
|
||||
tic_out++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Now start forwarding files
|
||||
*/
|
||||
// First = TRUE;
|
||||
// while (GetTicSystem(&Link, First)) {
|
||||
// First = FALSE;
|
||||
// if ((Link.aka.zone) && (Link.sendto) && (!Link.pause)) {
|
||||
// if (!((TIC.Aka.zone == Link.aka.zone) && (TIC.Aka.net == Link.aka.net) &&
|
||||
// (TIC.Aka.node == Link.aka.node) && (TIC.Aka.point == Link.aka.point))) {
|
||||
// tic_out++;
|
||||
// ForwardFile(Link.aka, sbl);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
Magic_ExecCommand();
|
||||
@ -818,8 +811,8 @@ int ProcessTic(fa_list *sbl)
|
||||
Magic_AdoptFile();
|
||||
|
||||
sprintf(Temp, "%s/%s", TIC.Inbound, TIC.TicName);
|
||||
|
||||
unlink(Temp);
|
||||
|
||||
free(Temp);
|
||||
tidy_qualify(&qal);
|
||||
return 0;
|
||||
|
252
mbsebbs/file.c
252
mbsebbs/file.c
@ -712,149 +712,129 @@ int KeywordScan()
|
||||
*/
|
||||
int FilenameScan()
|
||||
{
|
||||
FILE *pAreas, *pFile;
|
||||
int z, y, Found, Count = 0;
|
||||
char *Name;
|
||||
char *tmpname, *tmpname2;
|
||||
char temp[81];
|
||||
_Tag T;
|
||||
unsigned long OldArea;
|
||||
FILE *pAreas, *pFile;
|
||||
int Found, Count = 0;
|
||||
char *p, *q, mask[256];
|
||||
char *Name;
|
||||
_Tag T;
|
||||
unsigned long OldArea;
|
||||
|
||||
Name = calloc(81, sizeof(char));
|
||||
tmpname = calloc(81, sizeof(char));
|
||||
tmpname2 = calloc(81, sizeof(char));
|
||||
OldArea = iAreaNumber;
|
||||
Name = calloc(81, sizeof(char));
|
||||
OldArea = iAreaNumber;
|
||||
|
||||
iLineCount = 2; /* Reset Line Counter to Zero */
|
||||
arecno = 1; /* Reset Area Number to One */
|
||||
iLineCount = 2; /* Reset Line Counter to Zero */
|
||||
arecno = 1; /* Reset Area Number to One */
|
||||
|
||||
Enter(2);
|
||||
/* Accepts wildcards such as : *.zip, *.gz, .tar */
|
||||
pout(15, 0, (char *) Language(269));
|
||||
Enter(1);
|
||||
/* : *.zip is the same as .zip */
|
||||
pout(15, 0, (char *) Language(270));
|
||||
Enter(2);
|
||||
/* Accepts wildcards such as : *.zip, *.gz, *.* */
|
||||
pout(15, 0, (char *) Language(269));
|
||||
|
||||
Enter(2);
|
||||
/* Enter filename to search for : */
|
||||
pout(11, 0, (char *) Language(271));
|
||||
Enter(2);
|
||||
/* Enter filename to search for : */
|
||||
pout(11, 0, (char *) Language(271));
|
||||
|
||||
colour(CFG.InputColourF, CFG.InputColourB);
|
||||
GetstrC(Name, 80);
|
||||
colour(CFG.InputColourF, CFG.InputColourB);
|
||||
GetstrC(Name, 80);
|
||||
|
||||
if ((strcmp(Name, "")) == 0) {
|
||||
free(tmpname);
|
||||
free(Name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* If there is a file extension, strip it off, it are mostly
|
||||
* archiver extensions, and who knows what we're using as
|
||||
* archiver.
|
||||
*/
|
||||
if (strchr(Name, '.') != NULL)
|
||||
strcpy(tmpname, strtok(Name, "."));
|
||||
else
|
||||
strcpy(tmpname, tl(Name));
|
||||
strcpy(Name, "");
|
||||
y = strlen(tmpname);
|
||||
for(z = 0; z < y; z++) {
|
||||
if(tmpname[z] != '*') {
|
||||
sprintf(temp, "%c", tmpname[z]);
|
||||
strcat(Name, temp);
|
||||
}
|
||||
}
|
||||
tl(Name);
|
||||
Syslog('+', "FilenameScan(): \"%s\"", Name);
|
||||
|
||||
clear();
|
||||
/* File Search by Filename */
|
||||
pout(15, 0, (char *) Language(272));
|
||||
Enter(1);
|
||||
InitTag();
|
||||
|
||||
if ((pAreas = OpenFareas(FALSE)) == NULL)
|
||||
return 0;
|
||||
|
||||
while (fread(&area, areahdr.recsize, 1, pAreas) == 1) {
|
||||
if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) {
|
||||
|
||||
if ((pFile = OpenFileBase(arecno, FALSE)) != NULL) {
|
||||
|
||||
Found = FALSE;
|
||||
Sheader();
|
||||
Nopper();
|
||||
|
||||
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
||||
|
||||
strcpy(tmpname, file.Name);
|
||||
strcpy(tmpname2, file.LName);
|
||||
tl(tmpname);
|
||||
tl(tmpname2);
|
||||
if (((strstr(tmpname, Name)) != NULL) || ((strstr(tmpname2, Name)) != NULL)) {
|
||||
if (!Found) {
|
||||
Enter(2);
|
||||
if (iLC(2) == 1) {
|
||||
free(Name);
|
||||
free(tmpname);
|
||||
free(tmpname2);
|
||||
SetFileArea(OldArea);
|
||||
return 1;
|
||||
}
|
||||
Found = TRUE;
|
||||
}
|
||||
|
||||
memset(&T, 0, sizeof(T));
|
||||
T.Area = arecno;
|
||||
T.Active = FALSE;
|
||||
T.Cost = file.Cost;
|
||||
T.Size = file.Size;
|
||||
strncpy(T.SFile, file.Name, 12);
|
||||
strncpy(T.LFile, file.LName, 81);
|
||||
SetTag(T);
|
||||
Count++;
|
||||
if (ShowOneFile() == 1) {
|
||||
free(Name);
|
||||
free(tmpname);
|
||||
free(tmpname2);
|
||||
SetFileArea(OldArea);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
} /* End of while */
|
||||
|
||||
fclose(pFile);
|
||||
if (Found) {
|
||||
Enter(2);
|
||||
if (iLC(2) == 1) {
|
||||
free(Name);
|
||||
free(tmpname);
|
||||
free(tmpname2);
|
||||
SetFileArea(OldArea);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
} /* End Check for LTSec */
|
||||
} /* if access */
|
||||
arecno++; /* Go to next file area */
|
||||
|
||||
} /* End of Main */
|
||||
|
||||
Syslog('+', "Found %d files", Count);
|
||||
fclose(pAreas);
|
||||
if ((strcmp(Name, "")) == 0) {
|
||||
free(Name);
|
||||
free(tmpname);
|
||||
free(tmpname2);
|
||||
printf("\n");
|
||||
if (Count)
|
||||
Mark();
|
||||
else
|
||||
Pause();
|
||||
SetFileArea(OldArea);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a regexp string for the users search mask.
|
||||
*/
|
||||
p = tl(Name);
|
||||
q = mask;
|
||||
*q++ = '^';
|
||||
while ((*p) && (q < (mask + sizeof(mask) - 4))) {
|
||||
switch (*p) {
|
||||
case '\\': *q++ = '\\'; *q++ = '\\'; break;
|
||||
case '?': *q++ = ','; break;
|
||||
case '.': *q++ = '\\'; *q++ = '.'; break;
|
||||
case '+': *q++ = '\\'; *q++ = '+'; break;
|
||||
case '*': *q++ = '.'; *q++ = '*'; break;
|
||||
default: *q++ = toupper(*p); break;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
*q++ = '$';
|
||||
*q++ = '\0';
|
||||
Syslog('+', "FilenameScan(): \"%s\" -> \"%s\"", Name, mask);
|
||||
free(Name);
|
||||
re_comp(mask);
|
||||
|
||||
clear();
|
||||
/* File Search by Filename */
|
||||
pout(15, 0, (char *) Language(272));
|
||||
Enter(1);
|
||||
InitTag();
|
||||
|
||||
if ((pAreas = OpenFareas(FALSE)) == NULL)
|
||||
return 0;
|
||||
|
||||
while (fread(&area, areahdr.recsize, 1, pAreas) == 1) {
|
||||
if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) {
|
||||
|
||||
if ((pFile = OpenFileBase(arecno, FALSE)) != NULL) {
|
||||
|
||||
Found = FALSE;
|
||||
Sheader();
|
||||
Nopper();
|
||||
|
||||
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
||||
|
||||
if (re_exec(file.Name) || re_exec(file.LName)) {
|
||||
if (!Found) {
|
||||
Enter(2);
|
||||
if (iLC(2) == 1) {
|
||||
SetFileArea(OldArea);
|
||||
return 1;
|
||||
}
|
||||
Found = TRUE;
|
||||
}
|
||||
|
||||
memset(&T, 0, sizeof(T));
|
||||
T.Area = arecno;
|
||||
T.Active = FALSE;
|
||||
T.Cost = file.Cost;
|
||||
T.Size = file.Size;
|
||||
strncpy(T.SFile, file.Name, 12);
|
||||
strncpy(T.LFile, file.LName, 81);
|
||||
SetTag(T);
|
||||
Count++;
|
||||
if (ShowOneFile() == 1) {
|
||||
SetFileArea(OldArea);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
} /* End of while */
|
||||
|
||||
fclose(pFile);
|
||||
if (Found) {
|
||||
Enter(2);
|
||||
if (iLC(2) == 1) {
|
||||
SetFileArea(OldArea);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
} /* End Check for LTSec */
|
||||
} /* if access */
|
||||
arecno++; /* Go to next file area */
|
||||
|
||||
} /* End of Main */
|
||||
|
||||
Syslog('+', "Found %d files", Count);
|
||||
fclose(pAreas);
|
||||
printf("\n");
|
||||
if (Count)
|
||||
Mark();
|
||||
else
|
||||
Pause();
|
||||
SetFileArea(OldArea);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -847,13 +847,12 @@ int Addfile(char *File, int AreaNum, int fileid)
|
||||
{
|
||||
FILE *id, *pFileDB, *pPrivate;
|
||||
int err = 1, iDesc = 1, iPrivate = FALSE, GotId = FALSE, lines, i, j;
|
||||
char *Filename, *temp1, *idname = NULL, *Desc[26];
|
||||
char *Filename, *temp1, *idname = NULL, *Desc[26], *lname, temp[81];
|
||||
struct stat statfile;
|
||||
char temp[81];
|
||||
|
||||
Filename = calloc(PATH_MAX, sizeof(char));
|
||||
temp1 = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
lname = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
sprintf(Filename, "%s/%s", area.Path, File);
|
||||
|
||||
@ -863,7 +862,7 @@ int Addfile(char *File, int AreaNum, int fileid)
|
||||
* if it fails it will return a zero which will not
|
||||
* increase his uploads stats
|
||||
*/
|
||||
if(stat(Filename, &statfile) != 0) {
|
||||
if (stat(Filename, &statfile) != 0) {
|
||||
|
||||
colour(10, 0);
|
||||
/* Upload was unsuccessful for: */
|
||||
@ -872,6 +871,7 @@ int Addfile(char *File, int AreaNum, int fileid)
|
||||
fclose(pFileDB);
|
||||
free(Filename);
|
||||
free(temp1);
|
||||
free(lname);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -885,6 +885,12 @@ int Addfile(char *File, int AreaNum, int fileid)
|
||||
file.Crc32 = file_crc(Filename, TRUE);
|
||||
strcpy(file.Uploader, exitinfo.sUserName);
|
||||
file.UploadDate = time(NULL);
|
||||
if (strcmp(file.Name, file.LName)) {
|
||||
sprintf(lname, "%s/%s", area.Path, file.Name);
|
||||
if (link(Filename, lname)) {
|
||||
WriteError("$Can't create link %s to %s", lname, Filename);
|
||||
}
|
||||
}
|
||||
|
||||
if (area.PwdUP) {
|
||||
colour(9,0);
|
||||
|
262
mbsetup/m_fdb.c
262
mbsetup/m_fdb.c
@ -121,152 +121,152 @@ void EditFile()
|
||||
|
||||
void E_F(long areanr)
|
||||
{
|
||||
FILE *fil;
|
||||
char temp[PATH_MAX];
|
||||
int i, y, o, records, Ondisk;
|
||||
char help[81];
|
||||
static char *menu = (char *)"0";
|
||||
long offset;
|
||||
time_t Time;
|
||||
struct stat statfile;
|
||||
unsigned long crc, crc1;
|
||||
FILE *fil;
|
||||
char temp[PATH_MAX], help[81];
|
||||
int i, y, o, records, Ondisk;
|
||||
static char *menu = (char *)"0";
|
||||
long offset;
|
||||
time_t Time;
|
||||
struct stat statfile;
|
||||
unsigned long crc, crc1;
|
||||
|
||||
clr_index();
|
||||
|
||||
sprintf(temp, "%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), areanr);
|
||||
if ((fil = fopen(temp, "r+")) == NULL) {
|
||||
working(2, 0, 0);
|
||||
return;
|
||||
}
|
||||
if (! check_free())
|
||||
return;
|
||||
|
||||
fseek(fil, 0, SEEK_END);
|
||||
records = ftell(fil) / sizeof(file);
|
||||
o = 0;
|
||||
|
||||
for (;;) {
|
||||
|
||||
clr_index();
|
||||
set_color(WHITE, BLACK);
|
||||
mvprintw(5, 4, "14. EDIT FILES DATABASE");
|
||||
|
||||
sprintf(temp, "%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), areanr);
|
||||
if ((fil = fopen(temp, "r+")) == NULL) {
|
||||
working(2, 0, 0);
|
||||
return;
|
||||
}
|
||||
if (! check_free())
|
||||
return;
|
||||
y = 8;
|
||||
working(1, 0, 0);
|
||||
|
||||
fseek(fil, 0, SEEK_END);
|
||||
records = ftell(fil) / sizeof(file);
|
||||
o = 0;
|
||||
set_color(YELLOW, BLUE);
|
||||
mvprintw(7, 1, " Nr Filename Size Date Time Description ");
|
||||
/* 1234 12345678901234 12345678 12-34-1998 12:45 123456789012345678901234567890*/
|
||||
set_color(CYAN, BLACK);
|
||||
|
||||
for (;;) {
|
||||
for (i = 1; i <= 10; i++) {
|
||||
if ((o + i) <= records) {
|
||||
offset = ((o + i) - 1) * sizeof(file);
|
||||
fseek(fil, offset, SEEK_SET);
|
||||
fread(&file, sizeof(file), 1, fil);
|
||||
|
||||
clr_index();
|
||||
set_color(WHITE, BLACK);
|
||||
mvprintw(5, 4, "14. EDIT FILES DATABASE");
|
||||
mvprintw(y, 1, (char *)"%4d.", o + i);
|
||||
|
||||
y = 8;
|
||||
working(1, 0, 0);
|
||||
sprintf(temp, "%s/%s", area.Path, file.LName);
|
||||
Ondisk = ((stat(temp, &statfile)) != -1);
|
||||
|
||||
set_color(YELLOW, BLUE);
|
||||
mvprintw(7, 1, " Nr Filename Size Date Time Description ");
|
||||
/* 1234 12345678901234 12345678 12-34-1998 12:45 123456789012345678901234567890*/
|
||||
set_color(CYAN, BLACK);
|
||||
|
||||
for (i = 1; i <= 10; i++) {
|
||||
if ((o + i) <= records) {
|
||||
offset = ((o + i) - 1) * sizeof(file);
|
||||
fseek(fil, offset, SEEK_SET);
|
||||
fread(&file, sizeof(file), 1, fil);
|
||||
|
||||
set_color(WHITE, BLACK);
|
||||
mvprintw(y, 1, (char *)"%4d.", o + i);
|
||||
|
||||
sprintf(temp, "%s/%s", area.Path, file.LName);
|
||||
Ondisk = ((stat(temp, &statfile)) != -1);
|
||||
|
||||
if (Ondisk)
|
||||
set_color(CYAN, BLACK);
|
||||
else
|
||||
set_color(LIGHTRED, BLACK);
|
||||
mvprintw(y, 8, (char *)"%-14s", file.Name);
|
||||
|
||||
if (Ondisk) {
|
||||
if (file.Size == statfile.st_size)
|
||||
set_color(CYAN, BLACK);
|
||||
else
|
||||
set_color(LIGHTRED, BLACK);
|
||||
mvprintw(y,23, (char *)"%8ld", file.Size);
|
||||
|
||||
if (file.FileDate == statfile.st_mtime)
|
||||
set_color(CYAN, BLACK);
|
||||
else
|
||||
set_color(LIGHTRED, BLACK);
|
||||
Time = file.FileDate;
|
||||
mvprintw(y,32, (char *)"%s %s", StrDateDMY(Time), StrTimeHM(Time));
|
||||
}
|
||||
|
||||
set_color(CYAN, BLACK);
|
||||
sprintf(temp, "%s", file.Desc[0]);
|
||||
temp[30] = '\0';
|
||||
mvprintw(y,49, (char *)"%s", temp);
|
||||
y++;
|
||||
}
|
||||
}
|
||||
working(0, 0, 0);
|
||||
|
||||
if (records)
|
||||
if (records > 10)
|
||||
sprintf(help, "^1..%d^ Edit, ^-^ Return, ^N^/^P^ Page", records);
|
||||
else
|
||||
sprintf(help, "^1..%d^ Edit, ^-^ Return", records);
|
||||
if (file.Deleted)
|
||||
set_color(LIGHTBLUE, BLACK);
|
||||
else if (Ondisk)
|
||||
set_color(CYAN, BLACK);
|
||||
else
|
||||
sprintf(help, "^-^ Return");
|
||||
set_color(LIGHTRED, BLACK);
|
||||
mvprintw(y, 8, (char *)"%-14s", file.Name);
|
||||
|
||||
showhelp(help);
|
||||
if (Ondisk) {
|
||||
if (file.Size == statfile.st_size)
|
||||
set_color(CYAN, BLACK);
|
||||
else
|
||||
set_color(LIGHTRED, BLACK);
|
||||
mvprintw(y,23, (char *)"%8ld", file.Size);
|
||||
|
||||
while(TRUE) {
|
||||
mvprintw(LINES - 4, 6, "Enter your choice >");
|
||||
menu = (char *)"-";
|
||||
menu = edit_field(LINES - 4, 26, 6, '!', menu);
|
||||
locate(LINES - 4, 6);
|
||||
clrtoeol();
|
||||
|
||||
if (strncmp(menu, "-", 1) == 0) {
|
||||
fclose(fil);
|
||||
open_bbs();
|
||||
return;
|
||||
}
|
||||
|
||||
if (records > 10) {
|
||||
if (strncmp(menu, "N", 1) == 0)
|
||||
if ((o + 10) < records) {
|
||||
o += 10;
|
||||
break;
|
||||
}
|
||||
|
||||
if (strncmp(menu, "P", 1) == 0)
|
||||
if ((o - 10) >= 0) {
|
||||
o -= 10;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((atoi(menu) > 0) && (atoi(menu) <= records)) {
|
||||
working(1, 0, 0);
|
||||
offset = (atoi(menu) - 1) * sizeof(file);
|
||||
fseek(fil, offset, SEEK_SET);
|
||||
fread(&file, sizeof(file), 1, fil);
|
||||
crc = 0xffffffff;
|
||||
crc = upd_crc32((char *)&file, crc, sizeof(file));
|
||||
|
||||
sprintf(temp, "%s/%s", area.Path, file.LName);
|
||||
if (stat(temp, &statfile) == -1)
|
||||
file.Missing = TRUE;
|
||||
|
||||
EditFile();
|
||||
|
||||
crc1 = 0xffffffff;
|
||||
crc1 = upd_crc32((char *)&file, crc1, sizeof(file));
|
||||
|
||||
if (crc != crc1) {
|
||||
if (yes_no((char *)"Record is changed, save") == 1) {
|
||||
working(1, 0, 0);
|
||||
fseek(fil, offset, SEEK_SET);
|
||||
fwrite(&file, sizeof(file), 1, fil);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (file.FileDate == statfile.st_mtime)
|
||||
set_color(CYAN, BLACK);
|
||||
else
|
||||
set_color(LIGHTRED, BLACK);
|
||||
Time = file.FileDate;
|
||||
mvprintw(y,32, (char *)"%s %s", StrDateDMY(Time), StrTimeHM(Time));
|
||||
}
|
||||
|
||||
set_color(CYAN, BLACK);
|
||||
sprintf(temp, "%s", file.Desc[0]);
|
||||
temp[30] = '\0';
|
||||
mvprintw(y,49, (char *)"%s", temp);
|
||||
y++;
|
||||
}
|
||||
}
|
||||
working(0, 0, 0);
|
||||
|
||||
if (records)
|
||||
if (records > 10)
|
||||
sprintf(help, "^1..%d^ Edit, ^-^ Return, ^N^/^P^ Page", records);
|
||||
else
|
||||
sprintf(help, "^1..%d^ Edit, ^-^ Return", records);
|
||||
else
|
||||
sprintf(help, "^-^ Return");
|
||||
|
||||
showhelp(help);
|
||||
|
||||
while(TRUE) {
|
||||
mvprintw(LINES - 4, 6, "Enter your choice >");
|
||||
menu = (char *)"-";
|
||||
menu = edit_field(LINES - 4, 26, 6, '!', menu);
|
||||
locate(LINES - 4, 6);
|
||||
clrtoeol();
|
||||
|
||||
if (strncmp(menu, "-", 1) == 0) {
|
||||
fclose(fil);
|
||||
open_bbs();
|
||||
return;
|
||||
}
|
||||
|
||||
if (records > 10) {
|
||||
if (strncmp(menu, "N", 1) == 0)
|
||||
if ((o + 10) < records) {
|
||||
o += 10;
|
||||
break;
|
||||
}
|
||||
|
||||
if (strncmp(menu, "P", 1) == 0)
|
||||
if ((o - 10) >= 0) {
|
||||
o -= 10;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((atoi(menu) > 0) && (atoi(menu) <= records)) {
|
||||
working(1, 0, 0);
|
||||
offset = (atoi(menu) - 1) * sizeof(file);
|
||||
fseek(fil, offset, SEEK_SET);
|
||||
fread(&file, sizeof(file), 1, fil);
|
||||
crc = 0xffffffff;
|
||||
crc = upd_crc32((char *)&file, crc, sizeof(file));
|
||||
|
||||
sprintf(temp, "%s/%s", area.Path, file.LName);
|
||||
if (stat(temp, &statfile) == -1)
|
||||
file.Missing = TRUE;
|
||||
|
||||
EditFile();
|
||||
|
||||
crc1 = 0xffffffff;
|
||||
crc1 = upd_crc32((char *)&file, crc1, sizeof(file));
|
||||
|
||||
if (crc != crc1) {
|
||||
if (yes_no((char *)"Record is changed, save") == 1) {
|
||||
working(1, 0, 0);
|
||||
fseek(fil, offset, SEEK_SET);
|
||||
fwrite(&file, sizeof(file), 1, fil);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user