Saludos estimados
No se si existe en FWH o en xHB alguna funcion que realice la busqueda de un archivo en una unidad y sus directorios y subdirectorios ?? si alguien tiene el dato o alguna funcion se lo agradecere ...
Xbrowse( HB_DirScan( "C:\", "mifile.txt", "A" ) )
https://github.com/harbour/core/blob/master/src/rtl/dirscan.prg
#include "FiveWin.ch"
#include "directry.ch"
#include "fileio.ch"
PROC TestDScan()
LOCAL aFFList := HB_DirScan( "C:\TEMP" )
LOCAL x1Row
/*
FOR EACH x1Row IN aFFList
? PAD( x1Row[ 1 ], 23 ), ; // Name
TRAN( x1Row[ 2 ], '999,999,999,999' ), ; // Size
x1Row[ 3 ], ; // Date
x1Row[ 4 ], ; // Time
x1Row[ 5 ] // Attributes
NEXT x1Row
*/
Xbrowse( HB_DirScan( "C:\TEMP", "TESTE", "A" ) )
RETURN NIL // TestDScan()
STATIC FUNCTION hb_doScan( cPath, cMask, cAttr, cPathSep )
LOCAL aFile
LOCAL lMatch
LOCAL aResult := {}
FOR EACH aFile IN hb_vfDirectory( cPath + hb_osFileMask(), cAttr + "D" )
lMatch := hb_FileMatch( aFile[ F_NAME ], cMask )
IF "D" $ aFile[ F_ATTR ]
IF lMatch .AND. "D" $ cAttr
AAdd( aResult, aFile )
ENDIF
IF !( aFile[ F_NAME ] == "." .OR. aFile[ F_NAME ] == ".." .OR. aFile[ F_NAME ] == "" )
AEval( hb_DoScan( cPath + aFile[ F_NAME ] + cPathSep, cMask, cAttr, cPathSep ), ;
{| x | x[ F_NAME ] := aFile[ F_NAME ] + cPathSep + x[ F_NAME ], ;
AAdd( aResult, x ) } )
ENDIF
ELSEIF lMatch
AAdd( aResult, aFile )
ENDIF
NEXT
RETURN aResult
FUNCTION hb_DirScan( cPath, cFileMask, cAttr )
RETURN hb_DoScan( hb_DirSepAdd( hb_defaultValue( cPath, "" ) ), ;
iif( HB_ISSTRING( cFileMask ), cFileMask, hb_osFileMask() ), ;
hb_defaultValue( cAttr, "" ), ;
hb_ps() )
FUNCTION hb_DirRemoveAll( cDir )
LOCAL aFile, cPath, cFile, nAttr
IF ! Empty( cDir ) .AND. hb_vfDirExists( cDir )
cPath := hb_DirSepDel( cDir )
IF hb_vfAttrGet( cPath, @nAttr ) .AND. ! hb_bitAnd( nAttr, HB_FA_READONLY ) == 0
hb_vfAttrSet( cPath, hb_bitXor( nAttr, HB_FA_READONLY ) )
ENDIF
cPath := hb_DirSepAdd( cPath )
FOR EACH aFile IN hb_vfDirectory( cPath + hb_osFileMask(), "HSDL" )
IF "D" $ aFile[ F_ATTR ] .AND. ! "L" $ aFile[ F_ATTR ]
IF !( aFile[ F_NAME ] == "." .OR. aFile[ F_NAME ] == ".." .OR. aFile[ F_NAME ] == "" )
IF ! hb_DirRemoveAll( cPath + aFile[ F_NAME ] )
RETURN .F.
ENDIF
ENDIF
ELSE
cFile := cPath + aFile[ F_NAME ]
IF "R" $ aFile[ F_ATTR ] .AND. hb_vfAttrGet( cFile, @nAttr )
hb_vfAttrSet( cFile, hb_bitAnd( nAttr, hb_bitNot( HB_FA_READONLY ) ) )
ENDIF
IF ! hb_vfErase( cFile ) == 0
RETURN .F.
ENDIF
ENDIF
NEXT
RETURN hb_vfDirRemove( cDir ) == 0
ENDIF
RETURN .T.
FUNCTION hb_FileDelete( cFileMask, cAttr )
LOCAL lAny := .F., aFile, cPath, cFile, cAttrMask, nAttr
IF HB_ISSTRING( cFileMask ) .AND. ! Empty( cFileMask ) .AND. ;
! hb_vfDirExists( cFileMask )
cPath := hb_FNameDir( cFileMask )
cAttrMask := StrTran( hb_defaultValue( cAttr, "" ), "D" ) + "L"
FOR EACH aFile IN hb_vfDirectory( cFileMask, cAttrMask )
cFile := cPath + aFile[ F_NAME ]
IF "R" $ aFile[ F_ATTR ] .AND. hb_vfAttrGet( cFile, @nAttr )
hb_vfAttrSet( cFile, hb_bitAnd( nAttr, hb_bitNot( HB_FA_READONLY ) ) )
ENDIF
IF hb_vfErase( cFile ) == 0
lAny := .T.
ENDIF
NEXT
ENDIF
RETURN lAny
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 70 guests