#include #include #include #include #include #include #include #include #include "file.h" #ifdef __BORLANDC__ #include #endif #ifdef __WATCOMC__ #include #endif #ifdef _MSC_VER #include "windows.h" #endif void enumdir(char *path, DIRFUNCPTR func,void *context) { // #ifdef WIN95 #ifdef __BORLANDC__ ffblk ff; int done=findfirst(path,&ff,0); while (!done) { if (!func(ff.ff_name,context)) break; done=findnext(&ff); } #endif #ifdef __WATCOMC__ find_t ff; int done=_dos_findfirst(path,0,&ff); while (!done) { if (!func(ff.name,context)) break; done=_dos_findnext(&ff); } _dos_findclose(&ff); #endif #ifdef _MSC_VER WIN32_FIND_DATA ff; HANDLE h=FindFirstFile(path,&ff); if (h==INVALID_HANDLE_VALUE) return; do { if (!func(ff.cFileName,context)) break; } while (FindNextFile(h,&ff)); FindClose(h); #endif // #endif /* #ifdef DOS find_doslf ff; unsigned h=findfirst_doslf(path,&ff); if (!h) return; do { if (!func(ff.filename,context)) break; } while (findnext_doslf(h,&ff)); findclose_doslf(h); #endif*/ } //--------------------------------------------- //--------------------------------------------- #include "message.h" int FILEIO::open(char *filename) { if (h) close(); //already open _fmode=O_BINARY; #ifdef WIN95 h=::open(filename,O_RDWR|O_BINARY); #endif #ifdef DOS h=open_doslf(filename); #endif if (h==-1) {h=0; return -1;} //error return 0; } int FILEIO::create(char *filename) { if (h) close(); _fmode=O_BINARY; #ifdef WIN95 #ifdef __WATCOMC__ h=creat(filename,S_IWRITE|S_IREAD); #endif #ifdef __BORLANDC__ h=_rtl_creat(filename,0); #endif #ifdef _MSC_VER h=creat(filename,S_IWRITE|S_IREAD); #endif #endif #ifdef DOS h=creat(filename,S_IWRITE|S_IREAD); // h=create_doslf(filename); #endif if (h==-1) {h=0; return -1;} //error return 0; } void FILEIO::close() { if (!h) return; ::close(h); h=0; } int FILEIO::read(void *t,unsigned size) { if (!h) return -1; return ::read(h,t,size) %s %d",path,cpath,regs.x.eax); } unsigned open_doslf(char *path) { char s[256]; //canonicalized path canonicalize_doslf(path,s); return open(s,O_RDWR|O_BINARY); }; unsigned create_doslf(char *path) { char s[256]; //canonicalized path canonicalize_doslf(path,s); return creat(s,S_IWRITE|S_IREAD); }; #endif */ /* //dos long file name functions #ifdef DOS struct QWORD {unsigned low,high;}; typedef unsigned DWORD; struct find_doslf //structure for long file names dir searching { DWORD attrib; QWORD createtime; QWORD accesstime; QWORD modifytime; DWORD sizehigh,sizelow; char reserved[8]; char filename[260]; }; unsigned findfirst_doslf(char *path,find_doslf *ff); unsigned findnext_doslf(unsigned handle,find_doslf *ff); void findclose_doslf(unsigned handle); unsigned open_doslf(char *path); unsigned create_doslf(char *path); #endif */