Hi Przemek
I needed two function - hb_vfDirectory() and hb_vfCopyFile(). I had implemented them like, little lengthy but is working for me. I put the feature request to simplify the whole process. I believe it is beyond my capabilities to implement them in the core instead of the fact that you provided enough insight how it can be done.
Thanks you for responding. We know that you are busy with other important tasks.
FUNCTION __pullDirList( cPath, cServer )
LOCAL cStdOut, cCmd, aDir, cFile, aFiles, d_, cFileName, cExt
IF ! Empty( cServer )
cCmd := "ssh " + cServer + " ls " + cPath + " -lAst --full-time"
hb_processRun( cCmd, NIL, @cStdOut, NIL, .T. )
IF ! Empty( cStdOut )
aFiles := hb_ATokens( cStdOut, .T. )
aDir := {}
FOR EACH cFile IN aFiles
cFile := StrTran( cFile, Space( 5 ), " " )
cFile := StrTran( cFile, Space( 4 ), " " )
cFile := StrTran( cFile, Space( 3 ), " " )
cFile := StrTran( cFile, Space( 2 ), " " )
AAdd( aDir, hb_ATokens( cFile, " " ) )
NEXT
IF ! Empty( aDir )
d_:= {}
FOR EACH aFiles IN aDir
IF Len( aFiles ) >= 10
// translate to hb_vfDirectory() structure
hb_FNameSplit( aFiles[ 10 ], NIL, @cFileName, @cExt )
AAdd( d_, { cFileName + cExt, Val( aFiles[ 6 ] ), hb_StrToTS( aFiles[ 7 ] + " " + Left( aFiles[ 8 ], 12 ) ), Left( aFiles[ 8 ], 12 ) } )
ENDIF
NEXT
ENDIF
ENDIF
ELSE
d_:= hb_vfDirectory( cPath )
ENDIF
RETURN d_
FUNCTION __takeBackup( cServer, cPath )
LOCAL cStdOut, cName
LOCAL hLog := hb_Hash()
LOCAL cCmd := "rsync -a " + cServer + ":" + cPath + " /data/backups"
? cCmd
? "Transferring backup .20 to .23 ....", hb_TSToStr( hb_DateTime() )
hb_processRun( cCmd, NIL, @cStdOut, NIL, .F. ) // actual
? "Finished transfer .................", hb_TSToStr( hb_DateTime() )
? cStdOut
RETURN NIL
Regards
Pritpal Bedi
a student of software analysis and concepts