struct dirent * readdir(DIR *dir) { static int dummy_ino = 2; if (dir->index == dir->count) { Word rc; dir->count = 100; #if OS2 >= 2 rc = DosFindNext(dir->handle, dir->ffbuf, sizeof dir->ffbuf, &dir->count); #else rc = DosFindNext(dir->handle, (PFILEFINDBUF)dir->ffbuf, sizeof dir->ffbuf, &dir->count); #endif if (rc) { error(rc); return NULL; } dir->index = 0; dir->next = (FFBUF *)dir->ffbuf; } if (dir->index == dir->count) return NULL; memcpy(dir->entry.d_name, dir->next->achName, dir->next->cchName); dir->entry.d_name[dir->next->cchName] = '\0'; dir->entry.d_ino = dummy_ino++; dir->entry.d_reclen = dir->next->cchName; dir->entry.d_namlen = dir->next->cchName; dir->entry.d_size = dir->next->cbFile; dir->entry.d_attribute = dir->next->attrFile; dir->entry.d_time = *(USHORT *)&dir->next->ftimeLastWrite; dir->entry.d_date = *(USHORT *)&dir->next->fdateLastWrite; switch (dir->fstype) { case 'F': /* FAT */ case 'C': /* CDFS */ if (dir->next->attrFile & FILE_DIRECTORY) strupr(dir->entry.d_name); else strlwr(dir->entry.d_name); } #if OS2 >= 2 dir->next = (FFBUF *)((BYTE *)dir->next + dir->next->oNextEntryOffset); #else dir->next = (FFBUF *)((BYTE *)dir->next->achName + dir->next->cchName + 1); #endif ++dir->number; ++dir->index; return &dir->entry; }
Boolean DateiManager::treeExpanded (IContainerObject *o, IContainerControl *c) { disableUpdate (); Links.deleteTree (o); HDIR h = HDIR_CREATE; FILEFINDBUF3 b; ULONG Attribute = MUST_HAVE_DIRECTORY; ULONG n = 1; APIRET e; Verzeichnis *v = (Verzeichnis *)o; e = DosFindFirst (v->path () + "\\*.*", &h, Attribute, &b, sizeof (b), &n, FIL_STANDARD); while ( e == 0 ) { if ( IString (b.achName) != "." && IString (b.achName) != ".." ) { Verzeichnis *neu = new Verzeichnis (v->path () + "\\" + b.achName); c->addObject (neu, o); c->addObject (new Verzeichnis ("dummy"), neu); } e = DosFindNext (h, &b, sizeof (b), &n); } DosFindClose (h); enableUpdate (); return true; }
_WCRTLINK unsigned _dos_findnext( struct find_t *buf ) { /*****************************************************/ #if defined(__OS2_286__) if( _RWD_osmode == OS2_MODE ) { /* protected mode */ #endif APIRET rc; FF_BUFFER dir_buff; OS_UINT searchcount = 1; rc = DosFindNext( FIND_HANDLE_OF( buf ), (PVOID)&dir_buff, sizeof( dir_buff ), &searchcount ); if( rc != 0 ) { return( __set_errno_dos_reterr( rc ) ); } copydir( buf, &dir_buff ); #if defined(__OS2_286__) } else { /* real mode */ tiny_ret_t rc; void __far * old_dta; old_dta = TinyFarChangeDTA( buf ); /* set our DTA */ rc = TinyFindNext(); TinyFarSetDTA( old_dta ); /* restore DTA */ if( TINY_ERROR( rc ) ) { return( __set_errno_dos_reterr( TINY_INFO( rc ) ) ); } } #endif return( 0 ); }
//------------------------------ CMD_DosFindNext ------------------------------- void CMD_DosFindNext(HFILE hFile,LXIOCPA_DMN_CMDPARMPACKET* pParam ,PLXDOSFINDFIRSTSTRUCT p) { pParam->rc=DosFindNext(p->hDir ,&p->LXDOSFINDFIRSTUNION.fileFindBuf3 ,p->cbBuf,&p->cFileNames); }
LinkedStringList *__PHYSFS_platformEnumerateFiles(const char *dirname, int omitSymLinks) { char spec[CCHMAXPATH]; LinkedStringList *ret = NULL, *p = NULL; FILEFINDBUF3 fb; HDIR hdir = HDIR_CREATE; ULONG count = 1; APIRET rc; BAIL_IF_MACRO(strlen(dirname) > sizeof (spec) - 5, ERR_BAD_FILENAME, NULL); strcpy(spec, dirname); strcat(spec, (spec[strlen(spec) - 1] != '\\') ? "\\*.*" : "*.*"); rc = DosFindFirst(spec, &hdir, FILE_DIRECTORY | FILE_ARCHIVED | FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM, &fb, sizeof (fb), &count, FIL_STANDARD); BAIL_IF_MACRO(os2err(rc) != NO_ERROR, NULL, 0); while (count == 1) { if ((strcmp(fb.achName, ".") != 0) && (strcmp(fb.achName, "..") != 0)) ret = __PHYSFS_addToLinkedStringList(ret, &p, fb.achName, -1); DosFindNext(hdir, &fb, sizeof (fb), &count); } /* while */ DosFindClose(hdir); return(ret); } /* __PHYSFS_platformEnumerateFiles */
void AddToPlaylist(HWND hWnd, PSZ pszFilespec) { HDIR hFind = HDIR_SYSTEM; FILEFINDBUF3 FindBuffer = {0}; ULONG ulResultBufLen = sizeof(FILEFINDBUF3); ULONG ulFindCount = 1; APIRET rc = NO_ERROR; ULONG flAtttribute = FILE_ARCHIVED | FILE_SYSTEM | FILE_HIDDEN | FILE_READONLY; PSZ pszFilepath = new char[CCHMAXPATH]; PSZ pTemp = NULL; MakePathFromFilepath(pszFilepath, pszFilespec); pTemp = pszFilepath + strlen(pszFilepath); rc = DosFindFirst(pszFilespec, &hFind, flAtttribute, &FindBuffer, ulResultBufLen, &ulFindCount, FIL_STANDARD); while(rc == NO_ERROR) { strcpy(pTemp, FindBuffer.achName); if(IsValidFile(pszFilepath)) { plAddEntry(hWnd, pszFilepath); WinSetWindowText(WinQueryWindow(hWnd, QW_PARENT), pTemp); } ulFindCount = 1; rc = DosFindNext(hFind, &FindBuffer, ulResultBufLen, &ulFindCount); } DosFindClose(hFind); delete pszFilepath; }
static int findNextMatch (char *pFileName, char *wpName) { int x; APIRET rc = NO_ERROR; while (1) { ulFindCount = 1; if ((rc = DosFindNext(hdirFindHandle, &FindBuffer, ulResultBufLen, &ulFindCount)) != NO_ERROR) { if ((rc = DosFindClose(hdirFindHandle)) != NO_ERROR) printf ("DosFindClose error: return code = %lu\n", rc); return FALSE; } if ((FindBuffer.attrFile & FILE_DIRECTORY) == 0) { strcpy (wpName, pFileName); for (x = strlen(wpName)-1; wpName[x] != '\\' && wpName[x] !='/' && wpName[x] != ':' && x > 0; x--) {} /* avoid compiler warning */ if (x != 0) x++; strcpy (wpName + x, FindBuffer.achName); return TRUE; } } }
_WCRTLINK int _findnext( long handle, struct _finddata_t *fileinfo ) #endif #endif { #ifdef __NT__ WIN32_FIND_DATA ffb; BOOL rc; /*** Try to find another matching file ***/ rc = FIND_NEXT( (HANDLE)handle, &ffb ); if( rc == FALSE ) { return( __set_errno_nt() ); } if( !CHECK_FIND_NEXT_ATTR( (HANDLE)handle, FIND_ATTR, &ffb ) ) { return( __set_errno_dos( ERROR_FILE_NOT_FOUND ) ); } /*** Got one! ***/ #ifdef __INT64__ __F_NAME(__nt_finddatai64_cvt,__nt_wfinddatai64_cvt)( &ffb, fileinfo ); #else __F_NAME(__nt_finddata_cvt,__nt_wfinddata_cvt)( &ffb, fileinfo ); #endif #elif defined( __OS2__ ) APIRET rc; FF_BUFFER ffb; OS_UINT searchcount = 1; rc = DosFindNext( (HDIR)handle, &ffb, sizeof( ffb ), &searchcount ); if( rc != 0 ) { return( __set_errno_dos( rc ) ); } /*** Got one! ***/ #ifdef __INT64__ __F_NAME(__os2_finddatai64_cvt,__os2_wfinddatai64_cvt)( &ffb, fileinfo ); #else __F_NAME(__os2_finddata_cvt,__os2_wfinddata_cvt)( &ffb, fileinfo ); #endif #elif defined( __RDOS__ ) RDOSFINDTYPE * findbuf = (RDOSFINDTYPE*) handle; findbuf->entry++; if( __rdos_finddata_get( findbuf, fileinfo ) ) return( 0 ); else return( -1 ); #else /* DOS */ if( __F_NAME(_dos_findnext,_wdos_findnext)( (DOSFINDTYPE *)handle ) ) { return( -1 ); } #ifdef __INT64__ __F_NAME(__dos_finddatai64_cvt,__dos_wfinddatai64_cvt)( (DOSFINDTYPE *)handle, fileinfo ); #else __F_NAME(__dos_finddata_cvt,__dos_wfinddata_cvt)( (DOSFINDTYPE *)handle, fileinfo ); #endif #endif return( 0 ); }
void FilesCnr::getFiles() { PFILEFINDBUF3 pffb = NULL; OString FileSpec(scanDirectory); ULONG bufSize = sizeof(FILEFINDBUF3) * 200; HDIR hdir = HDIR_CREATE; ULONG ulMaxFiles = 200; APIRET rc; freeItems(); FileList.reset(); DosAllocMem((PPVOID)&pffb, bufSize, PAG_READ | PAG_WRITE | PAG_COMMIT); if (!pffb) return; FileSpec + "\\*"; DosError(FERR_DISABLEHARDERR); rc = DosFindFirst(FileSpec.text, &hdir, FILE_NORMAL | FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY, pffb, bufSize, &ulMaxFiles, FIL_STANDARD); while(!rc) { insertFiles(pffb, ulMaxFiles); rc = DosFindNext(hdir, pffb, bufSize, &ulMaxFiles); } DosFindClose(hdir); DosError(FERR_ENABLEHARDERR); DosFreeMem(pffb); }
void dummy_list_work (MAILSTREAM *stream,char *dir,char *pat,char *contents, long level) { unsigned long i = 1; FILEFINDBUF3 f; HDIR hd = HDIR_CREATE; struct stat sbuf; char tmp[MAILTMPLEN]; /* punt if bogus name */ if (!mailboxdir (tmp,dir,NIL)) return; /* make directory wildcard */ strcat (tmp,(tmp[strlen (tmp) -1] == '\\') ? "*.*" : "\\*.*"); /* do nothing if can't open directory */ if (!DosFindFirst (tmp,&hd,FILE_NORMAL,&f,sizeof (f),&i,FIL_STANDARD)) { /* list it if not at top-level */ if (!level && dir && pmatch_full (dir,pat,'\\')) dummy_listed (stream,'\\',dir,LATT_NOSELECT,contents); /* scan directory */ if (!dir || dir[strlen (dir) -1] == '\\') do { if (((f.name[0] != '.') || (f.name[1] && ((f.name[1] != '.') || f.name[2]))) && (strlen (f.name) <= NETMAXMBX)) { /* see if name is useful */ if (dir) sprintf (tmp,"%s%s",dir,f.name); else strcpy (tmp,f.name); /* make sure useful and can get info */ if ((pmatch_full (tmp,pat,'\\') || pmatch_full (strcat (tmp,"\\"),pat,'\\') || dmatch (tmp,pat,'\\')) && mailboxdir (tmp,dir,f.name) && tmp[0] && !stat (tmp,&sbuf)) { /* now make name we'd return */ if (dir) sprintf (tmp,"%s%s",dir,f.name); else strcpy (tmp,f.name); /* only interested in file type */ switch (sbuf.st_mode & S_IFMT) { case S_IFDIR: /* directory? */ if (pmatch_full (tmp,pat,'\\')) { if (!dummy_listed (stream,'\\',tmp,LATT_NOSELECT,contents))break; strcat (tmp,"\\");/* set up for dmatch call */ } /* try again with trailing \ */ else if (pmatch_full (strcat (tmp,"\\"),pat,'\\') && !dummy_listed (stream,'\\',tmp,LATT_NOSELECT,contents)) break; if (dmatch (tmp,pat,'\\') && (level < (long) mail_parameters (NIL,GET_LISTMAXLEVEL,NIL))) dummy_list_work (stream,tmp,pat,contents,level+1); break; case S_IFREG: /* ordinary name */ if (pmatch_full (tmp,pat,'\\') && !pmatch ("INBOX",tmp)) dummy_listed (stream,'\\',tmp,LATT_NOINFERIORS,contents); break; } } } i = 1; } while (!DosFindNext (h,&f,sizeof (f),&i)); } }
static USHORT _FillDirLb(HWND hDlg, ULONG CurDrive) { CHAR Path[CCHMAXPATH]; ULONG PathLen, NrOfFiles; APIRET rc; FILEFINDBUF3 FileInfo; HDIR hDir; WinSendDlgItemMsg(hDlg, LID_CD_DIRS, LM_DELETEALL, 0L, 0L); WinSendDlgItemMsg(hDlg, LID_SELECT_FILE_FILES, LM_DELETEALL, 0L, 0L); PathLen = CCHMAXPATH; if (DosQCurDir(CurDrive, (PUCHAR)Path, &PathLen)) return (1); if (strlen(Path) == 0) sprintf(TfText, "%c:\\*.*", (CHAR) (CurDrive + 64)); else sprintf(TfText, "%c:\\%s\\*.*", (CHAR) (CurDrive + 64), Path); _ShowTextField(hDlg); NrOfFiles = 1; hDir = HDIR_CREATE; rc = DosFindFirst2(TfText, &hDir, FILE_DIRECTORY | FILE_HIDDEN, &FileInfo, sizeof(FILEFINDBUF3), &NrOfFiles, FIL_STANDARD); while (!rc) { if (FileInfo.attrFile & FILE_DIRECTORY) { if (strlen(TfText) != 6 && strcmp(FileInfo.achName, ".") == 0) sprintf(FileInfo.achName, " <root %c:>", (CHAR) (CurDrive + 64)); if (strlen(TfText) != 6 || FileInfo.achName[0] != '.') { WinSendDlgItemMsg(hDlg, LID_CD_DIRS, LM_INSERTITEM, MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(FileInfo.achName)); } } NrOfFiles = 1; rc = DosFindNext(hDir, &FileInfo, sizeof(FILEFINDBUF3), &NrOfFiles); } DosFindClose(hDir); if (rc != ERROR_NO_MORE_FILES) return (1); return (0); }
static PFILELIST CheckFileMask(char *pchFile) { PFILELIST pFirst=NULL, pLast=NULL; PFILEFINDBUF3 pfindbuf, pResult; ULONG ulFindCount=SIZE_FINDBUFFER/sizeof(FILEFINDBUF3); HDIR hdir=HDIR_CREATE; /* Zeichen f. Delete und Trucate uebergehen */ if (*pchFile == '^' || *pchFile == '#') pchFile++; pfindbuf=malloc(SIZE_FINDBUFFER); if (DosFindFirst(pchFile, &hdir, FILE_ARCHIVED | FILE_READONLY, pfindbuf, SIZE_FINDBUFFER, &ulFindCount, FIL_STANDARD)) { /* nichts gefunden */ pFirst = calloc(1, sizeof(FILELIST)); strcpy(pFirst->pchFileName, pchFile); return pFirst; } do { pResult = pfindbuf; do { /* gefundenes File einhaengen */ if (pFirst) { pLast->next = calloc(1, sizeof(FILELIST)); pLast = pLast->next; } else pFirst = pLast = calloc(1, sizeof(FILELIST)); strcpy(pLast->pchFileName, pResult->achName); pLast->ulSize = pResult->cbFile; pLast->bFound = TRUE; /* weiter im Suchpuffer */ if (pResult->oNextEntryOffset) pResult = (PFILEFINDBUF3)(((PCHAR) pResult) + pResult->oNextEntryOffset); else pResult = NULL; } while (pResult); ulFindCount=SIZE_FINDBUFFER/sizeof(FILEFINDBUF3); } while (DosFindNext(hdir, pfindbuf, SIZE_FINDBUFFER, &ulFindCount)<ERROR_NO_MORE_FILES); DosFindClose(hdir); free(pfindbuf); return pFirst; }
BOOL FcbFindNext(xfcb FAR * lpXfcb) { BYTE FAR *lpDir; COUNT FcbDrive; psp FAR *lpPsp = MK_FP(cu_psp, 0); /* First, move the dta to a local and change it around to match */ /* our functions. */ lpDir = (BYTE FAR *) dta; dta = (BYTE FAR *) & Dmatch; /* Next initialze local variables by moving them from the fcb */ lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); /* Reconstrct the dirmatch structure from the fcb */ Dmatch.dm_drive = lpFcb->fcb_sftno; fbcopy(lpFcb->fcb_fname, (BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); DosUpFMem((BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); Dmatch.dm_attr_srch = wAttr; Dmatch.dm_entry = lpFcb->fcb_strtclst; Dmatch.dm_dircluster = lpFcb->fcb_dirclst; if ((xfcb FAR *) lpFcb != lpXfcb) { wAttr = lpXfcb->xfcb_attrib; fbcopy(lpXfcb, lpDir, 7); lpDir += 7; } else wAttr = D_ALL; if (DosFindNext() != SUCCESS) { dta = lpPsp->ps_dta; CritErrCode = 0x12; return FALSE; } *lpDir++ = FcbDrive; fmemcpy((struct dirent FAR *)lpDir, &SearchDir, sizeof(struct dirent)); lpFcb->fcb_dirclst = (UWORD)Dmatch.dm_dircluster; lpFcb->fcb_strtclst = Dmatch.dm_entry; lpFcb->fcb_sftno = Dmatch.dm_drive; #if 0 lpFcb->fcb_cublock = Dmatch.dm_entry; lpFcb->fcb_cublock *= 0x100; lpFcb->fcb_cublock += wAttr; #endif dta = lpPsp->ps_dta; return TRUE; }
/* (be gentle, this function isn't very robust.) */ static void cvt_path_to_correct_case(char *buf) { char *fname = buf + 3; /* point to first element. */ char *ptr = strchr(fname, '\\'); /* find end of first element. */ buf[0] = toupper(buf[0]); /* capitalize drive letter. */ /* * Go through each path element, and enumerate its parent dir until * a case-insensitive match is found. If one is (and it SHOULD be) * then overwrite the original element with the correct case. * If there's an error, or the path has vanished for some reason, it * won't hurt to have the original case, so we just keep going. */ while (fname != NULL) { char spec[CCHMAXPATH]; FILEFINDBUF3 fb; HDIR hdir = HDIR_CREATE; ULONG count = 1; APIRET rc; *(fname - 1) = '\0'; /* isolate parent dir string. */ strcpy(spec, buf); /* copy isolated parent dir... */ strcat(spec, "\\*.*"); /* ...and add wildcard search spec. */ if (ptr != NULL) /* isolate element to find (fname is the start). */ *ptr = '\0'; rc = DosFindFirst(spec, &hdir, FILE_DIRECTORY, &fb, sizeof (fb), &count, FIL_STANDARD); if (rc == NO_ERROR) { while (count == 1) /* while still entries to enumerate... */ { if (__PHYSFS_platformStricmp(fb.achName, fname) == 0) { strcpy(fname, fb.achName); break; /* there it is. Overwrite and stop searching. */ } /* if */ DosFindNext(hdir, &fb, sizeof (fb), &count); } /* while */ DosFindClose(hdir); } /* if */ *(fname - 1) = '\\'; /* unisolate parent dir. */ fname = ptr; /* point to next element. */ if (ptr != NULL) { *ptr = '\\'; /* unisolate element. */ ptr = strchr(++fname, '\\'); /* find next element. */ } /* if */ } /* while */ } /* cvt_file_to_correct_case */
FileList::FileList(char *dir) { if (dir) { // get the base path: // IDEA: Base path is always like "c:\tmp\*.xyz" // work back from eoln until we hit the first '\' (or '/') // that should be the full path. base_path = new char[1+strlen(dir)]; strcpy(base_path,dir); char *ptr = base_path + strlen(base_path); while (ptr > base_path) { if (*ptr == '\\' || *ptr == '/') break; else { *ptr = '\0'; ptr--; } } // now get the file list char *szDir = new char[4096]; FILEFINDBUF3 ffbFile; HDIR hdir; int rc; ULONG dirlen = 1; count = 0; hdir = HDIR_CREATE; rc = DosFindFirst(dir,&hdir,0,&ffbFile,sizeof(FILEFINDBUF3),&dirlen,FIL_STANDARD); if (rc == 0) do { if (*(ffbFile.achName) != '\0' && strcmp(ffbFile.achName,".") != 0 && strcmp(ffbFile.achName,"..") != 0) { list[count] = new char[1+strlen(ffbFile.achName)]; strcpy(list[count],ffbFile.achName); sizes[count] = ffbFile.cbFile; count++; } dirlen = 1; rc = DosFindNext(hdir,&ffbFile,sizeof(FILEFINDBUF3),&dirlen); } while(rc == 0 && dirlen == 1); DosFindClose(hdir); delete[] szDir; } }
int FindNext( DIRINFO PASPTR *dir, int fattr ) /********************************************/ { USHORT tmp; int cnt; tmp = 1; do { cnt = DosFindNext( 1, dir, sizeof( DIRINFO ), &tmp); if( cnt != 0 ) return( cnt ); } while( FileIgnore( dir, fattr ) ); return( cnt ); }
static BOOL EnumSystemFiles(void (*func)(const char *)) { APIRET rc; ULONG sysInfo = 0; char bootLetter[2]; char sysDir[_MAX_PATH] = ""; char filename[_MAX_PATH]; HDIR hdir = HDIR_CREATE; ULONG numFiles = 1; FILEFINDBUF3 fileBuf = {0}; ULONG buflen = sizeof(FILEFINDBUF3); if (DosQuerySysInfo(QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, (PVOID)&sysInfo, sizeof(ULONG)) == NO_ERROR) { bootLetter[0] = sysInfo + 'A' -1; bootLetter[1] = '\0'; strcpy(sysDir, bootLetter); strcpy(sysDir+1, ":\\OS2\\"); strcpy( filename, sysDir ); strcat( filename, "*.*" ); } rc =DosFindFirst( filename, &hdir, FILE_NORMAL, &fileBuf, buflen, &numFiles, FIL_STANDARD ); if( rc == NO_ERROR ) { do { // pass the full pathname to the callback sprintf( filename, "%s%s", sysDir, fileBuf.achName ); (*func)(filename); numFiles = 1; rc = DosFindNext( hdir, &fileBuf, buflen, &numFiles ); if( rc != NO_ERROR && rc != ERROR_NO_MORE_FILES ) printf( "DosFindNext errod code = %d\n", rc ); } while ( rc == NO_ERROR ); rc = DosFindClose(hdir); if( rc != NO_ERROR ) printf( "DosFindClose error code = %d", rc ); } else printf( "DosFindFirst error code = %d", rc ); return TRUE; }
char * _PR_MD_READ_DIR(_MDDir *d, PRIntn flags) { PRUword numFiles = 1; BOOL rv; char *fileName; USHORT fileAttr; if ( d ) { while (1) { if (d->firstEntry) { d->firstEntry = PR_FALSE; rv = NO_ERROR; } else { rv = DosFindNext(d->d_hdl, &(d->d_entry), sizeof(d->d_entry), &numFiles); } if (rv != NO_ERROR) { break; } fileName = GetFileFromDIR(d); fileAttr = GetFileAttr(d); if ( (flags & PR_SKIP_DOT) && (fileName[0] == '.') && (fileName[1] == '\0')) continue; if ( (flags & PR_SKIP_DOT_DOT) && (fileName[0] == '.') && (fileName[1] == '.') && (fileName[2] == '\0')) continue; /* * XXX * Is this the correct definition of a hidden file on OS/2? */ if ((flags & PR_SKIP_NONE) && (fileAttr & FILE_HIDDEN)) return fileName; else if ((flags & PR_SKIP_HIDDEN) && (fileAttr & FILE_HIDDEN)) continue; return fileName; } PR_ASSERT(NO_ERROR != rv); _PR_MD_MAP_READDIR_ERROR(rv); return NULL; } PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); return NULL; }
const char *Q_FindNextFile (void) { APIRET rc; ULONG cnt; if (findhandle == HDIR_CREATE) return NULL; while (1) { cnt = 1; rc = DosFindNext(findhandle, &findbuffer, sizeof(findbuffer), &cnt); if (rc != NO_ERROR) return NULL; if (!(findbuffer.attrFile & FILE_DIRECTORY)) return findbuffer.achName; } return NULL; }
struct DSTRUCT *rfind_nxt(struct DSTRUCT *dta) { struct DSTRUCT *my_dta; if (DosFindNext(hdir_ptr, &flist, sizeof(flist), & count)) return NULL; else { my_dta->ATTRIBUTE = (BYTE)(flist.attrFile & 0xff); my_dta->TIME = flist.ftimeCreation; my_dta->DATE = flist.fdateCreation; my_dta->FSIZE = flist.cbFile; strcpy(my_dta->NAME, flist.achName); return my_dta; } }
VOID FillDirListBox (HWND hwnd, CHAR *pcCurrentPath) { static CHAR szDrive [] = " :" ; FILEFINDBUF3 findbuf ; HDIR hDir = HDIR_CREATE ; SHORT sDrive ; ULONG ulDriveNum, ulDriveMap, ulCurPathLen, ulReturn, ulSearchCount = 1 ; DosQueryCurrentDisk (&ulDriveNum, &ulDriveMap) ; pcCurrentPath [0] = (CHAR) ulDriveNum + '@' ; pcCurrentPath [1] = ':' ; pcCurrentPath [2] = '\\' ; ulCurPathLen = CCHMAXPATH ; DosQueryCurrentDir (0, pcCurrentPath + 3, &ulCurPathLen) ; WinSetDlgItemText (hwnd, IDD_PATH, pcCurrentPath) ; WinSendDlgItemMsg (hwnd, IDD_DIRLIST, LM_DELETEALL, NULL, NULL) ; for (sDrive = 0 ; sDrive < 26 ; sDrive++) if (ulDriveMap & 1L << sDrive) { szDrive [1] = (CHAR) sDrive + 'A' ; WinSendDlgItemMsg (hwnd, IDD_DIRLIST, LM_INSERTITEM, MPFROM2SHORT (LIT_END, 0), MPFROMP (szDrive)) ; } ulReturn = DosFindFirst ("*.*", &hDir, FILE_DIRECTORY, &findbuf, sizeof findbuf, &ulSearchCount, FIL_STANDARD) ; while (!ulReturn) { if (findbuf.attrFile & 0x0010 && (findbuf.achName [0] != '.' || findbuf.achName [1])) WinSendDlgItemMsg (hwnd, IDD_DIRLIST, LM_INSERTITEM, MPFROM2SHORT (LIT_SORTASCENDING, 0), MPFROMP (findbuf.achName)) ; ulReturn = DosFindNext (hDir, &findbuf, sizeof findbuf, &ulSearchCount) ; } DosFindClose (hDir) ; }
unsigned LocalFindNext( void *info, unsigned info_len ) /*************************************************/ { FILEFINDBUF dta; USHORT count = 1; unsigned rc; info_len = info_len; rc = DosFindNext( 1, &dta, sizeof( dta ), &count ); if( rc != 0 ) return( StashErrCode( rc, OP_LOCAL ) ); if( count == 0 ) { DosFindClose( 1 ); return( -1 ); } makeDOSDTA( &dta, info ); return( 0 ); }
int ll_findnext (struct ll_findbuffer *buffer) { USHORT rc; ULONG count; HDIR hdir; FILEFINDBUF ffbuf; hdir = FHDIR (buffer); count = 1; rc = DosFindNext (hdir, &ffbuf, sizeof (ffbuf), &count); if (rc != 0 || count != 1) { DosFindClose (hdir); return 0; } fconv (buffer, &ffbuf); return 1; }
//------------------------- lxafs_linkinfo_correction -------------------------- static int lxafs_linkinfo_correction(char* newname,char* oldname) { int err=0; HDIR hDir=HDIR_CREATE; FILEFINDBUF3 fb; char filespec[LX_MAXPATH]; char newoldname[LX_MAXPATH]; char newnewname[LX_MAXPATH]; ULONG sz; ULONG cFileNames=1; sz=sizeof(FILEFINDBUF3); strncpy(filespec,newname,LX_MAXPATH-3); strcat(filespec,"/*"); if(!DosFindFirst(filespec,&hDir ,FILE_ARCHIVED|FILE_DIRECTORY|FILE_SYSTEM|FILE_HIDDEN|FILE_READONLY ,&fb,sz,&cFileNames,FIL_STANDARD)) { while(cFileNames) { if(strcmp(fb.achName,"..") && strcmp(fb.achName,".")) { strncpy(newoldname,oldname,LX_MAXPATH); strncpy(newnewname,newname,LX_MAXPATH); strcat(newoldname,"/"); strcat(newnewname,"/"); strcat(newoldname,fb.achName); strcat(newnewname,fb.achName); if((fb.attrFile&FILE_DIRECTORY)) lxafs_linkinfo_correction(newnewname,newoldname); lxafs_correct_linkinfo(newnewname,newoldname,newname,oldname); } if(DosFindNext(hDir,&fb,sz,&cFileNames) || cFileNames==0) { cFileNames=0; break; } } } if(hDir && hDir!=HDIR_CREATE) DosFindClose(hDir); return err; }
void Detail::zeige (IString const &d) { disableUpdate (); deleteAllObjects (); HDIR h = HDIR_CREATE; FILEFINDBUF3 b; ULONG Attribute = FILE_DIRECTORY|FILE_SYSTEM|FILE_HIDDEN|FILE_READONLY; ULONG n = 1; APIRET e; e = DosFindFirst (d + "\\*.*", &h, Attribute, &b, sizeof (b), &n, FIL_STANDARD); while ( e == 0 ) { addObject (new Datei (d + "\\" + b.achName)); e = DosFindNext (h, &b, sizeof (b), &n); } DosFindClose (h); sortByIconText (); enableUpdate (); }
USHORT Settings :: GetLanguages (HWND hwnd) { // find all dlls and add the names to the language list HDIR hdir; ULONG c, fl, ul; FILEFINDBUF3 findbuf; APIRET rc; PSZ psz; HMODULE hmod; fl = FILE_NORMAL; hdir = HDIR_CREATE; c = 1; rc = DosFindFirst ("*.dll", &hdir, fl, &findbuf, sizeof (findbuf), &c, FIL_STANDARD); while (!rc) { // we don't want the extension if ((psz = _getext (findbuf.achName))) *psz = '\0'; // try opening the dll and read the version etc. data if ((rc = DosLoadModule(PSZ(NULL), 0, findbuf.achName, &hmod)) == NO_ERROR) { PVOID pv; if (DosGetResource(hmod, RT_RCDATA, DLL_ID, &pv) == NO_ERROR) { if (strcmp(PSZ(pv), "Gotcha!") == 0) { psz = PSZ(pv)+strlen(PSZ(pv))+3; ul = WinInsertLboxItem (hwnd, LIT_END, psz); WinSendMsg(hwnd, LM_SETITEMHANDLE, MPFROMLONG(ul), MPFROMP (strdup(findbuf.achName))); } DosFreeResource(pv); } DosFreeModule(hmod); } c = 1; rc = DosFindNext (hdir, &findbuf, sizeof (findbuf), &c); } DosFindClose (hdir); return 1; }
VOID FillFileListBox (HWND hwnd) { FILEFINDBUF3 findbuf ; HDIR hDir = HDIR_CREATE ; ULONG ulReturn, ulSearchCount = 1 ; WinSendDlgItemMsg (hwnd, IDD_FILELIST, LM_DELETEALL, NULL, NULL) ; ulReturn = DosFindFirst ("*.*", &hDir, FILE_NORMAL, &findbuf, sizeof findbuf, &ulSearchCount, FIL_STANDARD) ; while (!ulReturn) { WinSendDlgItemMsg (hwnd, IDD_FILELIST, LM_INSERTITEM, MPFROM2SHORT (LIT_SORTASCENDING, 0), MPFROMP (findbuf.achName)) ; ulReturn = DosFindNext (hDir, &findbuf, sizeof findbuf, &ulSearchCount) ; } DosFindClose (hDir) ; }
int LocalFindNext( void *info, unsigned info_len ) /************************************************/ { #ifdef _M_I86 FILEFINDBUF dta; #else FILEFINDBUF3 dta; #endif APIRET count = 1; APIRET rc; info_len = info_len; rc = DosFindNext( 1, &dta, sizeof( dta ), &count ); if( rc != 0 ) return( -1 ); if( count == 0 ) { DosFindClose( 1 ); return( -1 ); } makeDOSDTA( &dta, info ); return( 0 ); }
static char *getdirent(char *dir) { int done; if (dir != NULL) { /* get first entry */ hdir = HDIR_CREATE; count = 1; done = DosFindFirst(dir, &hdir, attributes, &find, sizeof(find), &count, 0L); } else /* get next entry */ done = DosFindNext(hdir, &find, sizeof(find), &count); if (done == 0) return find.achName; else { DosFindClose(hdir); return NULL; } }
BOOL FcbDelete(xfcb FAR * lpXfcb) { COUNT FcbDrive; /* Build a traditional DOS file name */ CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); /* check for a device */ if (IsDevice(SecPathName)) { return FALSE; } else { BYTE FAR *lpOldDta = dta; dmatch Dmatch; dta = (BYTE FAR *) & Dmatch; if (DosFindFirst(D_ALL, SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS) { dta = lpOldDta; return FALSE; } do { truename(Dmatch.dm_name, SecPathName, FALSE); if (DosDelete(SecPathName) != SUCCESS) { dta = lpOldDta; return FALSE; } } while (DosFindNext() == SUCCESS); dta = lpOldDta; return TRUE; } }