Hi,
On 2010.05.04 17:30, Alex Strickland wrote:
Maybe this small test will help someone to see how easy it is to read
and write non DBF files using netio RPC.
The primary purpose of NETIO was file sharing, so, it supports this
functionality even without RPC and without any Harbour level overhead.
Here is a sample code, how I copy data.dbf to MEMIO for a much faster
report generation using memory file instead of (possibly remote) file.
If you change "data.dbf" to "net:data.dbf" you'll have a function to
NETIO file to MEMIO file.
pFile = hb_fileExtOpen( "data.dbf", NULL, FO_READ | FO_DENYNONE |
FXO_DEFAULTS, NULL, NULL );
if( pFile )
{
if( hb_fileLock( pFile, 0, ( HB_FOFFSET ) -1, FL_LOCK |
FLX_EXCLUSIVE ) )
{
pFileTo = hb_fileExtOpen( "mem:data.dbf", NULL, FO_READWRITE |
FO_EXCLUSIVE | FXO_TRUNCATE | FXO_DEFAULTS, NULL, NULL );
if( pFileTo )
{
ulPos = 0;
pBuffer = hb_xgrab( 1048576 );
while( ( ulCount = hb_fileReadAt( pFile, pBuffer, 1048576,
ulPos ) ) > 0 )
{
hb_fileWriteAt( pFileTo, pBuffer, ulCount, ulPos );
if( ulCount != 1048576 )
break;
ulPos += 1048576;
}
hb_fileClose( pFileTo );
}
hb_fileLock( pFile, 0, ( HB_FOFFSET ) -1, FL_UNLOCK );
}
hb_fileClose( pFile );
}
If your next question is about, why IO API is not directly accessible
via Harbour level functions, the answer is: because IO API functionality
is not as wide as all Harbour level functions. So, many Harbour
functions could not be redirected via IO API.
Regards,
Mindaugas
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour