2024-05-09 23:23 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

359 views
Skip to first unread message

Przemysław Czerpak

unread,
May 10, 2024, 12:57:22 AMMay 10
to harbou...@googlegroups.com
2024-05-09 23:23 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* include/hbapifs.h
* src/rtl/fscopy.c
+ added new C function:
HB_BOOL hb_fileCopyEx( const char * pszSource, const char * pszDest,
HB_SIZE nBufSize, HB_BOOL fTime,
PHB_ITEM pCallBack );
Unlike hb_fileCopy() it is never redirected to remote server and copy
operation is always done locally.
pCallBack is codeblock or function symbol, it's executed at the
beginning and then on each nBufSize bytes written and receives two
parameters: nBytesWritten, nTotalSize.
Warning: nTotalSize could be 0 when non regular files like pipes or
sockets are copied.

* src/rtl/vfile.c
+ added new PRG function:
hb_vfCopyFile( <cFileSrc>, <cFileDst>, [<nBufSize>=65536], ;
[<lTimePreserve>=.t.], [<bCallBack>] ) --> <nResult>
It's wrapper to hb_fileCopyEx() C function.
For very big files setting <nBufSize> to greater value, i.e. 16777216
may increase performance.

best regards
Przemek

Grigory Filatov

unread,
May 12, 2024, 11:34:48 AMMay 12
to Harbour Developers
Hi Przemek,

Thanks for the new function hb_fileCopyEx().

I noticed that there is a small typo in this  C function.
The following code snippet
...
      if( fResult )
      {
         HB_FATTR ulAttr;

         if( hb_fileAttrGet( pszSource, &ulAttr ) )
            hb_fileAttrSet( pszDest, ulAttr );

         if( fTime )
         {
            long lJulian, lMillisec;

            if( hb_fileTimeGet( pszSource, &lJulian, &lMillisec ) )
               hb_fileTimeSet( hb_parcx( 1 ), lJulian, lMillisec );
         }
      }
      hb_fsSetError( errCode );
   }

should be rewritten as

      if( fResult )
      {
         HB_FATTR ulAttr;

         if( hb_fileAttrGet( pszSource, &ulAttr ) )
            hb_fileAttrSet( pszDest, ulAttr );

         if( fTime )
         {
            long lJulian, lMillisec;

            if( hb_fileTimeGet( pszDest, &lJulian, &lMillisec ) )
               hb_fileTimeSet( hb_parcx( 1 ), lJulian, lMillisec );
         }
      }
      hb_fsSetError( errCode );
   }

Thank you for your attention.

Best regards,
Grigory Filatov

пятница, 10 мая 2024 г. в 06:57:22 UTC+2, Przemysław Czerpak:

Grigory Filatov

unread,
May 12, 2024, 12:49:26 PMMay 12
to Harbour Developers
Hi,

Sorry for my mistake in the previous reply.

The updated code should be
...
         if( fTime )
         {
            long lJulian, lMillisec;

            if( hb_fileTimeGet( pszSource, &lJulian, &lMillisec ) )
               hb_fileTimeSet( pszDest, lJulian, lMillisec );
         }

TIA,
Grigory

воскресенье, 12 мая 2024 г. в 17:34:48 UTC+2, Grigory Filatov:

Pritpal Bedi

unread,
May 13, 2024, 9:58:14 PMMay 13
to Harbour Developers
Thank you very much Przemek

This function will leverage my HbQt applications to remain responsive and client/server applications more informative.

Thanks again.

Pritpal
a student of software analysis & concepts

jmcqu...@gmail.com

unread,
May 17, 2024, 12:14:08 PMMay 17
to Harbour Developers
Not sure about information on changelog.
Result ok only using hb_vfCopyFileEx()

PROCEDURE Main

   SetMode(25,80)
   CLS
   hb_vfCopyFileEx( "d:\download\flagship-linux-7465-all.tgz", "d:\temp\test.xxx",,,{|...|test2(...)} )
   ? x, y
   Inkey(0)

   RETURN

FUNCTION Test2( a, b )

   ? a, b

   RETURN Nil

...
31981568   32059818
32047104   32059818
32059818   32059818
32059818   32059818

José M. C. Quintas

Pritpal Bedi

unread,
May 24, 2024, 1:02:32 PMMay 24
to Harbour Developers
Hi Jose

It is perfect implementation. 
You can finetune certain interface elments, for example, display a statusbar showing the progress of copy operations just like the Windows explorer does. Also you can release time-slice to the operating system in case a number of concurrent connections are downloading same file. Possibilities are endless with this function.

Thanks Przemek for this funtion.

Pritpal Bedi
a student of software analysis & concepts

Reply all
Reply to author
Forward
0 new messages