Exemplo n.º 1
0
int closedir (DIR *dir)
{
    APIRET ulrc = DosFindClose (dir->handle);

    free(dir);
    return (int)ulrc;
}
Exemplo n.º 2
0
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;
		}
	}
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
Arquivo: os2.c Projeto: UIKit0/paragui
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 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);
}
Exemplo n.º 7
0
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);
}
Exemplo n.º 8
0
HB_BOOL hb_fsOS2QueryPathInfo( const char * pszPathName,
                               HB_FOFFSET * pnSize, HB_FATTR * pnAttr,
                               long * plJulian, long * plMillisec )
{
   HDIR hdirFindHandle = HDIR_CREATE;
   HB_FILEFINDBUF3L findBuffer;
   ULONG ulFindCount = 1;
   char * pszFree;
   APIRET ret;
   HB_BOOL fIsWSeB = hb_isWSeB();

   pszPathName = hb_fsNameConv( pszPathName, &pszFree );
   ret = DosFindFirst( ( PCSZ ) pszPathName, &hdirFindHandle,
                       FILE_ARCHIVED | FILE_DIRECTORY |
                       FILE_SYSTEM | FILE_HIDDEN | FILE_READONLY,
                       &findBuffer, sizeof( findBuffer ), &ulFindCount,
                       fIsWSeB ? FIL_STANDARDL : FIL_STANDARD );
   hb_fsSetError( ( HB_ERRCODE ) ret );
   if( hdirFindHandle != HDIR_CREATE )
      DosFindClose( hdirFindHandle );
   if( pszFree )
      hb_xfree( pszFree );

   if( ret == NO_ERROR )
   {
      if( fIsWSeB )
      {
         if( pnSize )
            *pnSize = ( HB_FOFFSET ) findBuffer.ffbl.cbFile;
         if( pnAttr )
            *pnAttr = hb_fsAttrFromRaw( ( HB_FATTR ) findBuffer.ffbl.attrFile );
         if( plJulian )
            *plJulian = hb_dateEncode( findBuffer.ffbl.fdateLastWrite.year + 1980,
                                       findBuffer.ffbl.fdateLastWrite.month,
                                       findBuffer.ffbl.fdateLastWrite.day );
         if( plMillisec )
            *plMillisec = hb_timeEncode( findBuffer.ffbl.ftimeLastWrite.hours,
                                         findBuffer.ffbl.ftimeLastWrite.minutes,
                                         findBuffer.ffbl.ftimeLastWrite.twosecs * 2, 0 );
      }
      else
      {
         if( pnSize )
            *pnSize = ( HB_FOFFSET ) findBuffer.ffb.cbFile;
         if( pnAttr )
            *pnAttr = hb_fsAttrFromRaw( ( HB_FATTR ) findBuffer.ffb.attrFile );
         if( plJulian )
            *plJulian = hb_dateEncode( findBuffer.ffb.fdateLastWrite.year + 1980,
                                       findBuffer.ffb.fdateLastWrite.month,
                                       findBuffer.ffb.fdateLastWrite.day );
         if( plMillisec )
            *plMillisec = hb_timeEncode( findBuffer.ffb.ftimeLastWrite.hours,
                                         findBuffer.ffb.ftimeLastWrite.minutes,
                                         findBuffer.ffb.ftimeLastWrite.twosecs * 2, 0 );
      }
      return HB_TRUE;
   }
   return HB_FALSE;
}
Exemplo n.º 9
0
void Q_FindClose (void)
{
	if (findhandle != HDIR_CREATE) {
		DosFindClose(findhandle);
		findhandle = HDIR_CREATE;
		findbuffer.oNextEntryOffset = 0;
	}
}
Exemplo n.º 10
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;
}
Exemplo n.º 11
0
void hb_fsFindClose( PHB_FFIND ffind )
{
   if( ffind )
   {
      if( ffind->pszFree )
         hb_xfree( ffind->pszFree );

      /* Do platform dependant cleanup */

      if( ffind->info )
      {
         PHB_FFIND_INFO info = ( PHB_FFIND_INFO ) ffind->info;

         if( ! ffind->bFirst )
         {
            hb_vmUnlock();

#if defined( HB_OS_DOS )

#  if defined( __WATCOMC__ )
            _dos_findclose( &info->entry );
#  elif ! defined( __DJGPP__ ) && ! defined( __BORLANDC__ )
            findclose( &info->entry );
#  endif

#elif defined( HB_OS_OS2 )

            if( info->hFindFile != HDIR_CREATE )
               DosFindClose( info->hFindFile );
            if( info->entry )
               DosFreeMem( info->entry );

#elif defined( HB_OS_WIN )

            if( info->hFindFile != INVALID_HANDLE_VALUE )
               FindClose( info->hFindFile );

#elif defined( HB_OS_UNIX )

            if( info->dir )
               closedir( info->dir );

#else
            {
               /* Intentionally do nothing */
               int iTODO; /* TODO: for given platform */
            }
#endif

            hb_vmLock();
         }

         hb_xfree( info );
      }

      hb_xfree( ffind );
   }
}
Exemplo n.º 12
0
Arquivo: os2.c Projeto: UIKit0/paragui
/* (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 */
Exemplo n.º 13
0
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;
    }
}
Exemplo n.º 14
0
static void fix_component(char *path, char *lastcomp)
{
    FILEFINDBUF3 fb3;
    HDIR hDir = HDIR_CREATE;
    ULONG numNames = 1;
    ULONG rc = DosFindFirst( (UCHAR *)path, &hDir, FILE_NORMAL|FILE_DIRECTORY, &fb3, sizeof(fb3), &numNames, FIL_STANDARD );

    if (rc == 0)
        strcpy(lastcomp, fb3.achName);

    DosFindClose(hDir);
}
Exemplo n.º 15
0
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;
}
Exemplo n.º 16
0
FileFind::~FileFind() {
    delete [] Directory;
    if (Pattern)
        delete [] Pattern;
#if defined(USE_DIRENT)
    if (dir)
        closedir(dir);
#elif defined(OS2) && !defined(USE_DIRENT)
    if (dir)
        DosFindClose(dir);
#elif defined(NT) && !defined(USE_DIRENT)
    if (dir)
        FindClose((HANDLE)dir);
#endif
}
Exemplo n.º 17
0
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) ;
     }
Exemplo n.º 18
0
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 );
}
Exemplo n.º 19
0
PRInt32
_PR_MD_CLOSE_DIR(_MDDir *d)
{
   PRInt32 rc;

    if ( d ) {
      rc = DosFindClose(d->d_hdl);
      if(rc == NO_ERROR){
        d->magic = (PRUint32)-1;
        return PR_SUCCESS;
		} else {
			_PR_MD_MAP_CLOSEDIR_ERROR(rc);
        	return PR_FAILURE;
		}
    }
    PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
    return PR_FAILURE;
}
Exemplo n.º 20
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;
}
Exemplo n.º 21
0
//------------------------- 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;
}
Exemplo n.º 22
0
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 ();
}
Exemplo n.º 23
0
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;
}
Exemplo n.º 24
0
_WCRTLINK unsigned _dos_findclose( struct find_t *buf ) {
/******************************************************/

    APIRET      rc;

#if defined(__OS2_286__)
    if( _RWD_osmode == OS2_MODE ) {        /* protected mode */
#endif
        if( FIND_HANDLE_OF( buf ) != BAD_HANDLE ) {
            rc = DosFindClose( FIND_HANDLE_OF( buf ) );
            if( rc != 0 ) {
                return( __set_errno_dos_reterr( rc ) );
            }
        }
#if defined(__OS2_286__)
    } else {
        buf = buf;
    }
#endif
    return( 0 );
}
Exemplo n.º 25
0
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) ;
     }
Exemplo n.º 26
0
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 );
}
Exemplo n.º 27
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;
  }
}
Exemplo n.º 28
0
void
seekdir(DIR *dir, long off)
{
	if (dir->number > off) {
		char name[MAXPATHLEN+2];
		Word rc;

		DosFindClose(dir->handle);

		strcpy(name, dir->name);
		strcat(name, "*");

		dir->handle = HDIR_CREATE;
		dir->count = 32767;
#if OS2 >= 2
		rc = DosFindFirst(name, &dir->handle, dir->attrmask,
			dir->ffbuf, sizeof dir->ffbuf, &dir->count, FIL_STANDARD);
#else
		rc = DosFindFirst((PSZ)name, &dir->handle, dir->attrmask,
			(PFILEFINDBUF)dir->ffbuf, sizeof dir->ffbuf, &dir->count, 0);
#endif
		switch (rc) {
		default:
			error(rc);
			return;
		case NO_ERROR:
		case ERROR_NO_MORE_FILES:
			;
		}

		dir->number = 0;
		dir->index = 0;
		dir->next = (FFBUF *)dir->ffbuf;
	}

	while (dir->number < off && readdir(dir))
		;
}
Exemplo n.º 29
0
DIR *opendir (char *path)
{
    APIRET ulrc;
    ULONG cnt = 1;
    DIR *dir;
    char *name;

    if (!(dir = (DIR*)calloc(1, sizeof(DIR)))) {
        return NULL;
    }
    if (name = (char*)calloc(1, strlen(path) + 3)) {
        strcat(strcpy(name, path),path[strlen(path) - 1] == '\\' ? "*" : "\\*");
        dir->handle = HDIR_CREATE;
        ulrc = DosFindFirst(name, &(dir->handle), _A_ANY, &(dir->buffer), sizeof(struct _FILEFINDBUF3), &cnt, FIL_STANDARD);
        free(name);
    }
    if (!name || ulrc) {
        DosFindClose (dir->handle);
        free(dir);
        dir = NULL;
    }
    return dir;
}
Exemplo n.º 30
0
/* Closes the handle to a find request; that is, ends a search. */
ULONG
findclose( HDIR hdir )
{
  return DosFindClose( hdir );
}