2015-07-31 14:51 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
2015-07-31 14:04 UTC+0200 Viktor Szakats (vszakats users.noreply.github.com)
* include/hbapifs.h
* src/rtl/filebuf.c
* src/rtl/vfile.c
+ add C-level hb_fileSizeGet() function
* update HB_VFSIZE() to use hb_fileSizeGet() when passed a filename
It means now HB_VFSIZE() works for non-virtual filenames
just like HB_FSIZE() did.
This commit is contained in:
@@ -10,6 +10,16 @@
|
||||
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
|
||||
*/
|
||||
|
||||
2015-07-31 14:51 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
2015-07-31 14:04 UTC+0200 Viktor Szakats (vszakats users.noreply.github.com)
|
||||
* include/hbapifs.h
|
||||
* src/rtl/filebuf.c
|
||||
* src/rtl/vfile.c
|
||||
+ add C-level hb_fileSizeGet() function
|
||||
* update HB_VFSIZE() to use hb_fileSizeGet() when passed a filename
|
||||
It means now HB_VFSIZE() works for non-virtual filenames
|
||||
just like HB_FSIZE() did.
|
||||
|
||||
2015-07-28 01:39 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* src/rtl/padx.c
|
||||
! fixed typo in hb_UPad[LRC]() functions - thanks to Grigory Filatov
|
||||
|
||||
@@ -374,6 +374,7 @@ extern HB_EXPORT HB_BOOL hb_fileDirRemove ( const char * pszDirName );
|
||||
extern HB_EXPORT double hb_fileDirSpace ( const char * pszDirName, HB_USHORT uiType );
|
||||
extern HB_EXPORT PHB_ITEM hb_fileDirectory ( const char * pszDirSpec, const char * pszAttr );
|
||||
|
||||
extern HB_EXPORT HB_FOFFSET hb_fileSizeGet ( const char * pszFileName, HB_BOOL bUseDirEntry );
|
||||
extern HB_EXPORT HB_BOOL hb_fileTimeGet ( const char * pszFileName, long * plJulian, long * plMillisec );
|
||||
extern HB_EXPORT HB_BOOL hb_fileTimeSet ( const char * pszFileName, long lJulian, long lMillisec );
|
||||
extern HB_EXPORT HB_BOOL hb_fileAttrGet ( const char * pszFileName, HB_FATTR * pulAttr );
|
||||
|
||||
@@ -57,8 +57,10 @@
|
||||
#include "hbapi.h"
|
||||
#include "hbapifs.h"
|
||||
#include "hbapierr.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbthread.h"
|
||||
#include "hbvm.h"
|
||||
#include "directry.ch"
|
||||
|
||||
#if defined( HB_OS_UNIX )
|
||||
# include <sys/types.h>
|
||||
@@ -1201,6 +1203,49 @@ HB_BOOL hb_fileTimeSet( const char * pszFileName, long lJulian, long lMillisec )
|
||||
return hb_fsSetFileTime( pszFileName, lJulian, lMillisec );
|
||||
}
|
||||
|
||||
HB_EXPORT HB_FOFFSET hb_fileSizeGet( const char * pszFileName, HB_BOOL bUseDirEntry )
|
||||
{
|
||||
int i = s_fileFindDrv( pszFileName );
|
||||
|
||||
if( i >= 0 )
|
||||
{
|
||||
HB_ERRCODE uiError;
|
||||
HB_FOFFSET nSize = 0;
|
||||
|
||||
if( bUseDirEntry )
|
||||
{
|
||||
PHB_ITEM pDir = hb_fileDirectory( pszFileName, "HS" );
|
||||
|
||||
uiError = hb_fsError();
|
||||
if( pDir )
|
||||
{
|
||||
PHB_ITEM pEntry = hb_arrayGetItemPtr( pDir, 1 );
|
||||
|
||||
if( pEntry )
|
||||
nSize = hb_arrayGetNInt( pEntry, F_SIZE );
|
||||
hb_itemRelease( pDir );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PHB_FILE pFile = hb_fileExtOpen( pszFileName, NULL, FO_READ | FO_COMPAT, NULL, NULL );
|
||||
if( pFile )
|
||||
{
|
||||
nSize = hb_fileSize( pFile );
|
||||
uiError = hb_fsError();
|
||||
hb_fileClose( pFile );
|
||||
}
|
||||
else
|
||||
uiError = hb_fsError();
|
||||
}
|
||||
hb_fsSetFError( uiError );
|
||||
|
||||
return nSize;
|
||||
}
|
||||
|
||||
return hb_fsFSize( pszFileName, bUseDirEntry );
|
||||
}
|
||||
|
||||
HB_BOOL hb_fileAttrGet( const char * pszFileName, HB_FATTR * pulAttr )
|
||||
{
|
||||
int i = s_fileFindDrv( pszFileName );
|
||||
|
||||
@@ -51,7 +51,6 @@
|
||||
#include "hbapierr.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbdate.h"
|
||||
#include "directry.ch"
|
||||
|
||||
/* extended FILE IO handle destructor */
|
||||
static HB_GARBAGE_FUNC( hb_file_Destructor )
|
||||
@@ -750,45 +749,12 @@ HB_FUNC( HB_VFTRUNC )
|
||||
HB_FUNC( HB_VFSIZE )
|
||||
{
|
||||
const char * pszFile = hb_parc( 1 );
|
||||
PHB_FILE pFile;
|
||||
|
||||
if( pszFile )
|
||||
{
|
||||
HB_ERRCODE uiError;
|
||||
HB_FOFFSET nSize = 0;
|
||||
|
||||
if( hb_parldef( 2, 1 ) )
|
||||
{
|
||||
PHB_ITEM pDir = hb_fileDirectory( pszFile, "HS" );
|
||||
|
||||
uiError = hb_fsError();
|
||||
if( pDir )
|
||||
{
|
||||
PHB_ITEM pEntry = hb_arrayGetItemPtr( pDir, 1 );
|
||||
|
||||
if( pEntry )
|
||||
nSize = hb_arrayGetNInt( pEntry, F_SIZE );
|
||||
hb_itemRelease( pDir );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pFile = hb_fileExtOpen( pszFile, NULL, FO_READ | FO_COMPAT, NULL, NULL );
|
||||
if( pFile )
|
||||
{
|
||||
nSize = hb_fileSize( pFile );
|
||||
uiError = hb_fsError();
|
||||
hb_fileClose( pFile );
|
||||
}
|
||||
else
|
||||
uiError = hb_fsError();
|
||||
}
|
||||
hb_fsSetFError( uiError );
|
||||
hb_retnint( nSize );
|
||||
}
|
||||
hb_retnint( hb_fileSizeGet( pszFile, hb_parldef( 2, 1 ) ) );
|
||||
else
|
||||
{
|
||||
pFile = hb_fileParam( 1 );
|
||||
PHB_FILE pFile = hb_fileParam( 1 );
|
||||
if( pFile )
|
||||
{
|
||||
hb_retnint( hb_fileSize( pFile ) );
|
||||
|
||||
Reference in New Issue
Block a user