home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <io.h>
- #include <share.h>
- #include <fcntl.h>
- #include <errno.h>
- #include <sys\stat.h>
-
- #include "C:\IBMCPP\BBSDef.h"
-
- unsigned char TestFile(struct FileRecord *File, unsigned char *Path);
- unsigned char GetFileNameStartPos(unsigned char *Path);
-
- struct FileRecord File;
-
-
- unsigned int main(void)
- {
- int OrigFile, DestFile;
- unsigned short Counter=FALSE;
-
- #ifdef __IBMC__
- setvbuf(stdout, NULL, _IONBF, BUFSIZ);
- #endif
-
- if (sizeof(File)!=80) {
- puts("Filerecord size is not 80 bytes!");
- return EXIT_FILEERROR;
- }
-
-
- OrigFile=sopen("FILES.DAT", O_BINARY | O_RDONLY, SH_DENYNONE);
- DestFile=sopen("FILES2.DAT", O_BINARY | O_WRONLY | O_CREAT, SH_DENYNONE, S_IREAD | S_IWRITE);
-
- if (OrigFile==-1 || DestFile==-1) {
- if (OrigFile!=-1) close(OrigFile);
- if (DestFile!=-1) close(DestFile);
- puts("File open error..");
- return EXIT_FILEERROR;
- }
-
- while(read(OrigFile, &File, sizeof(File))==sizeof(File)) {
- if (File.Deleted) continue;
- printf("%u: %s\n", ++Counter, OnlyFileName);
- while (TRUE) {
- if (TestFile(&File, "D:\\PC\\GAMES\\")) break;
- if (TestFile(&File, "D:\\PC\\MISC\\")) break;
- if (TestFile(&File, "D:\\PC\\PROG\\")) break;
- if (TestFile(&File, "D:\\PC\\TELECOM\\")) break;
- if (TestFile(&File, "D:\\PC\\UTILS\\")) break;
-
- if (TestFile(&File, "D:\\TEXT\\GAMES\\")) break;
- if (TestFile(&File, "D:\\TEXT\\GENERAL\\")) break;
- if (TestFile(&File, "D:\\TEXT\\LYRICS\\")) break;
- if (TestFile(&File, "D:\\TEXT\\SEX\\")) break;
- break;
- }
- write(DestFile, &File, sizeof(File));
- }
- close(OrigFile);
- close(DestFile);
- return 0;
- }
-
- unsigned char TestFile(struct FileRecord *File, unsigned char *Path)
- {
- unsigned char Temp[128];
-
- strcpy(Temp, Path);
- strcat(Temp, pOnlyFileName);
- if (access(Temp, FALSE)) return FALSE;
-
- strcpy(File->Name, Temp);
- File->NameStartPos=GetFileNameStartPos(File->Name);
- return TRUE;
- }
-
- unsigned char GetFileNameStartPos(unsigned char *Path)
- {
- unsigned char i=FALSE;
- unsigned char FIND;
- while(*Path) {
- if (*Path=='\\') FIND=i+1;
- ++i; ++Path;
- }
- return FIND;
- }
-