2008-07-09 11:57 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbdate.h
* harbour/source/common/hbdate.c
+ added hb_timeStampEncode()
* harbour/include/hbapifs.h
* harbour/source/rtl/filesys.c
+ added hb_fsSetFileTime()
+ added POSIX file attributes with some macros to convert Harbour
definitions into OS ones.
+ added initial version of hb_fsSetAttr() - work in progress, I should
finish it in the evening.
* harbour/contrib/hbmzip/hbmzip.c
* added setting file attribute in DJGPP builds
! fixed some small typos in OS2 builds reported by David
* harbour/source/vm/fm.c
* changed hb_xrealloc() to be ANSI-C realloc() compatible
This commit is contained in:
@@ -8,6 +8,26 @@
|
||||
2008-12-31 13:59 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
|
||||
2008-07-09 11:57 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/include/hbdate.h
|
||||
* harbour/source/common/hbdate.c
|
||||
+ added hb_timeStampEncode()
|
||||
|
||||
* harbour/include/hbapifs.h
|
||||
* harbour/source/rtl/filesys.c
|
||||
+ added hb_fsSetFileTime()
|
||||
+ added POSIX file attributes with some macros to convert Harbour
|
||||
definitions into OS ones.
|
||||
+ added initial version of hb_fsSetAttr() - work in progress, I should
|
||||
finish it in the evening.
|
||||
|
||||
* harbour/contrib/hbmzip/hbmzip.c
|
||||
* added setting file attribute in DJGPP builds
|
||||
! fixed some small typos in OS2 builds reported by David
|
||||
|
||||
* harbour/source/vm/fm.c
|
||||
* changed hb_xrealloc() to be ANSI-C realloc() compatible
|
||||
|
||||
2008-07-09 10:20 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
|
||||
* contrib/make_b32_all.bat
|
||||
* contrib/make_vc_all.bat
|
||||
|
||||
@@ -642,7 +642,7 @@ static int hb_zipStoreFile( zipFile hZip, char* szFileName, char* szName, char*
|
||||
}
|
||||
#endif
|
||||
|
||||
zfi.tmz_date.tm_sec = fs3.ftimeLastWrite.twosec * 2;
|
||||
zfi.tmz_date.tm_sec = fs3.ftimeLastWrite.twosecs * 2;
|
||||
zfi.tmz_date.tm_min = fs3.ftimeLastWrite.minutes;
|
||||
zfi.tmz_date.tm_hour = fs3.ftimeLastWrite.hours;
|
||||
zfi.tmz_date.tm_mday = fs3.fdateLastWrite.day;
|
||||
@@ -846,14 +846,19 @@ static int hb_unzipExtractCurrentFile( unzFile hUnzip, char* szFileName, char* s
|
||||
{
|
||||
SetFileAttributesA( szName, ufi.external_fa & 0xFF );
|
||||
}
|
||||
#elif defined( HB_OS_UNIX )
|
||||
#elif defined( HB_OS_UNIX ) || defined( __DJGPP__ )
|
||||
{
|
||||
struct utimbuf utim;
|
||||
struct tm st;
|
||||
|
||||
chmod( szName, ( ufi.external_fa & 0x00070000 ) >> 16 |
|
||||
( ufi.external_fa & 0x00380000 ) >> 15 |
|
||||
( ufi.external_fa & 0x01C00000 ) >> 13 );
|
||||
# if defined( __DJGPP__ )
|
||||
_chmod( szName, 1, ufi.external_fa & 0xFF );
|
||||
# else
|
||||
chmod( szName, ( ufi.external_fa & 0x00070000 ) >> 16 |
|
||||
( ufi.external_fa & 0x00380000 ) >> 15 |
|
||||
( ufi.external_fa & 0x01C00000 ) >> 14 );
|
||||
# endif
|
||||
memset( &st, 0, sizeof( st ) );
|
||||
|
||||
st.tm_sec = ufi.tmu_date.tm_sec;
|
||||
st.tm_min = ufi.tmu_date.tm_min;
|
||||
@@ -869,7 +874,7 @@ static int hb_unzipExtractCurrentFile( unzFile hUnzip, char* szFileName, char* s
|
||||
}
|
||||
#elif defined( HB_OS_DOS )
|
||||
|
||||
# if defined(__DJGPP__) || defined(__RSX32__) || defined(__GNUC__)
|
||||
# if defined(__RSX32__) || defined(__GNUC__)
|
||||
{
|
||||
_chmod( szName, 1, ufi.external_fa & 0xFF );
|
||||
}
|
||||
@@ -902,9 +907,9 @@ static int hb_unzipExtractCurrentFile( unzFile hUnzip, char* szFileName, char* s
|
||||
FTIME ftime;
|
||||
|
||||
fdate.year = ufi.tmu_date.tm_year - 1980;
|
||||
fdate.month = ufi.tmu_date.tm_mo;
|
||||
fdate.month = ufi.tmu_date.tm_mon;
|
||||
fdate.day = ufi.tmu_date.tm_mday;
|
||||
ftime.hours = tmu_date.tm_hour;
|
||||
ftime.hours = ufi.tmu_date.tm_hour;
|
||||
ftime.minutes = ufi.tmu_date.tm_min;
|
||||
ftime.twosecs = ufi.tmu_date.tm_sec / 2;
|
||||
|
||||
|
||||
@@ -86,23 +86,54 @@ HB_EXTERN_BEGIN
|
||||
#define FXO_COPYNAME 0x8000 /* copy final szPath into pFilename */
|
||||
|
||||
/* File attributes flags */
|
||||
#define HB_FA_ALL 0
|
||||
#define HB_FA_READONLY 1
|
||||
#define HB_FA_HIDDEN 2
|
||||
#define HB_FA_SYSTEM 4
|
||||
#define HB_FA_LABEL 8
|
||||
#define HB_FA_DIRECTORY 16
|
||||
#define HB_FA_ARCHIVE 32
|
||||
#define HB_FA_DEVICE 64
|
||||
#define HB_FA_NORMAL 128
|
||||
#define HB_FA_TEMPORARY 256
|
||||
#define HB_FA_SPARSE 512
|
||||
#define HB_FA_REPARSE 1024
|
||||
#define HB_FA_COMPRESSED 2048
|
||||
#define HB_FA_OFFLINE 4096
|
||||
#define HB_FA_NOTINDEXED 8192
|
||||
#define HB_FA_ENCRYPTED 16384
|
||||
#define HB_FA_VOLCOMP 32768 /* volume supports compression. */
|
||||
#define HB_FA_ALL 0x00000000
|
||||
|
||||
#define HB_FA_READONLY 0x00000001
|
||||
#define HB_FA_HIDDEN 0x00000002
|
||||
#define HB_FA_SYSTEM 0x00000004
|
||||
#define HB_FA_LABEL 0x00000008
|
||||
#define HB_FA_DIRECTORY 0x00000010
|
||||
#define HB_FA_ARCHIVE 0x00000020
|
||||
#define HB_FA_DEVICE 0x00000040
|
||||
#define HB_FA_NORMAL 0x00000080
|
||||
|
||||
#define HB_FA_TEMPORARY 0x00000100
|
||||
#define HB_FA_SPARSE 0x00000200
|
||||
#define HB_FA_REPARSE 0x00000400
|
||||
#define HB_FA_COMPRESSED 0x00000800
|
||||
#define HB_FA_OFFLINE 0x00001000
|
||||
#define HB_FA_NOTINDEXED 0x00002000
|
||||
#define HB_FA_ENCRYPTED 0x00004000
|
||||
#define HB_FA_VOLCOMP 0x00008000 /* volume supports compression. */
|
||||
|
||||
#define HB_FA_SUID 0x08000000 /* set user ID on execution */
|
||||
#define HB_FA_SGID 0x04000000 /* set group ID on execution */
|
||||
#define HB_FA_SVTX 0x02000000 /* sticky bit */
|
||||
#define HB_FA_RUSR 0x01000000 /* read by owner */
|
||||
#define HB_FA_WUSR 0x00800000 /* write by owner */
|
||||
#define HB_FA_XUSR 0x00400000 /* execute/search by owner */
|
||||
#define HB_FA_RGRP 0x00200000 /* read by group */
|
||||
#define HB_FA_WGRP 0x00100000 /* write by group */
|
||||
#define HB_FA_XGRP 0x00080000 /* execute/search by group */
|
||||
#define HB_FA_ROTH 0x00040000 /* read by others */
|
||||
#define HB_FA_WOTH 0x00020000 /* write by others */
|
||||
#define HB_FA_XOTH 0x00010000 /* execute/search by others */
|
||||
|
||||
#define HB_FA_UGVS ( HB_FA_SUID | HB_FA_SGID | HB_FA_SVTX )
|
||||
#define HB_FA_RWXU ( HB_FA_RUSR | HB_FA_WUSR | HB_FA_XUSR )
|
||||
#define HB_FA_RWXG ( HB_FA_RGRP | HB_FA_WGRP | HB_FA_XGRP )
|
||||
#define HB_FA_RWXO ( HB_FA_ROTH | HB_FA_WOTH | HB_FA_XOTH )
|
||||
|
||||
/* macros to convert Harbour attributes to POSIX ones */
|
||||
#define HB_FA_POSIX_OTH(a) ( ( ( a ) & 0x00070000 ) >> 16 )
|
||||
#define HB_FA_POSIX_GRP(a) ( ( ( a ) & 0x00380000 ) >> 15 )
|
||||
#define HB_FA_POSIX_USR(a) ( ( ( a ) & 0x01C00000 ) >> 14 )
|
||||
#define HB_FA_POSIX_SID(a) ( ( ( a ) & 0x0E000000 ) >> 13 )
|
||||
|
||||
#define HB_FA_POSIX_ATTR(a) ( HB_FA_POSIX_OTH(a) | \
|
||||
HB_FA_POSIX_GRP(a) | \
|
||||
HB_FA_POSIX_USR(a) | \
|
||||
HB_FA_POSIX_SID(a) )
|
||||
|
||||
|
||||
extern HB_EXPORT BOOL hb_fsChDir ( BYTE * pszDirName ); /* change working directory */
|
||||
@@ -139,6 +170,8 @@ extern HB_EXPORT ULONG hb_fsSeek ( FHANDLE hFileHandle, LONG lOffset, U
|
||||
extern HB_EXPORT HB_FOFFSET hb_fsSeekLarge( FHANDLE hFileHandle, HB_FOFFSET llOffset, USHORT uiFlags ); /* reposition an open file using 64bit API */
|
||||
extern HB_EXPORT ULONG hb_fsTell ( FHANDLE hFileHandle ); /* retrieve the current position of a file */
|
||||
extern HB_EXPORT BOOL hb_fsSetDevMode ( FHANDLE hFileHandle, USHORT uiDevMode ); /* change the device mode of a file (text/binary) */
|
||||
extern HB_EXPORT BOOL hb_fsSetFileTime( BYTE * pszFileName, LONG lJulian, LONG lMillisec );
|
||||
extern HB_EXPORT BOOL hb_fsSetAttr ( BYTE * pszFileName, ULONG ulAttr );
|
||||
extern HB_EXPORT void hb_fsSetError ( USHORT uiError ); /* set the file system DOS error number */
|
||||
extern HB_EXPORT void hb_fsSetIOError ( BOOL fResult, USHORT uiOperation ); /* set the file system error number after IO operation */
|
||||
extern HB_EXPORT USHORT hb_fsWrite ( FHANDLE hFileHandle, const BYTE * pBuff, USHORT ulCount ); /* write to an open file from a buffer (<=64K) */
|
||||
|
||||
@@ -62,6 +62,7 @@ extern HB_EXPORT HB_ULONG hb_dateMilliSeconds( void );
|
||||
extern HB_EXPORT double hb_secondsCPU( int n );
|
||||
extern HB_EXPORT void hb_dateTimeStamp( LONG * plJulian, LONG * plMilliSec );
|
||||
extern HB_EXPORT char * hb_timeStampStr( char * szTime, LONG lMillisec );
|
||||
extern HB_EXPORT LONG hb_timeStampEncode( int iHour, int iMinutes, int iSeconds, int iMSec );
|
||||
extern HB_EXPORT void hb_timeStampDecode( LONG lMillisec, int * piHour, int * piMinutes, int * piSeconds, int * piMSec );
|
||||
extern HB_EXPORT void hb_timeStrGet( const char * szTime, int * piHour, int * piMinutes, int * piSeconds, int * piMSec );
|
||||
extern HB_EXPORT char * hb_dateTimeStampStr( char * szDateTime, LONG lJulian, LONG lMillisec );
|
||||
|
||||
@@ -327,6 +327,28 @@ HB_EXPORT void hb_dateTimeStr( char * pszTime )
|
||||
#endif
|
||||
}
|
||||
|
||||
HB_EXPORT LONG hb_timeStampEncode( int iHour, int iMinutes, int iSeconds, int iMSec )
|
||||
{
|
||||
LONG lMillisec;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_timeStampEncode(%d, %d, %d, %d)", iHour, iMinutes, iSeconds, iMSec));
|
||||
|
||||
if( iHour >= 0 && iHour < 24 &&
|
||||
iMinutes >= 0 && iMinutes < 60 &&
|
||||
iSeconds >= 0 && iSeconds < 60 &&
|
||||
iMSec >= 0 && iMSec < 1000 )
|
||||
{
|
||||
lMillisec = ( ( LONG ) ( iHour * 60 + iMinutes ) * 60 + iSeconds ) *
|
||||
1000 + iMSec;
|
||||
}
|
||||
else
|
||||
{
|
||||
lMillisec = 0;
|
||||
}
|
||||
|
||||
return lMillisec;
|
||||
}
|
||||
|
||||
HB_EXPORT void hb_timeStampDecode( LONG lMillisec, int * piHour, int * piMinutes,
|
||||
int * piSeconds, int * piMSec )
|
||||
{
|
||||
|
||||
@@ -90,10 +90,17 @@
|
||||
This has been corrected by ptucker
|
||||
*/
|
||||
|
||||
/* *nixes */
|
||||
#if !defined( _LARGEFILE64_SOURCE )
|
||||
# define _LARGEFILE64_SOURCE
|
||||
#endif
|
||||
|
||||
/* OS2 */
|
||||
#define INCL_DOSFILEMGR /* File Manager values */
|
||||
#define INCL_DOSERRORS /* DOS error values */
|
||||
#define INCL_DOSDATETIME /* DATETIME functions */
|
||||
|
||||
/* W32 */
|
||||
#define HB_OS_WIN_32_USED
|
||||
|
||||
#include <string.h>
|
||||
@@ -102,12 +109,15 @@
|
||||
#include "hbapi.h"
|
||||
#include "hbapifs.h"
|
||||
#include "hbapierr.h"
|
||||
#include "hbdate.h"
|
||||
#include "hb_io.h"
|
||||
#include "hbset.h"
|
||||
|
||||
#if defined(OS_UNIX_COMPATIBLE)
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#if defined( HB_OS_DARWIN )
|
||||
@@ -156,6 +166,8 @@
|
||||
#include <io.h>
|
||||
#elif defined(__DJGPP__)
|
||||
#include <dir.h>
|
||||
#include <utime.h>
|
||||
#include <time.h>
|
||||
#endif
|
||||
#if !defined(HAVE_POSIX_IO)
|
||||
#define HAVE_POSIX_IO
|
||||
@@ -367,47 +379,51 @@ static void convert_open_flags( BOOL fCreate, USHORT uiAttr, USHORT uiFlags,
|
||||
|
||||
#else
|
||||
|
||||
static void convert_open_flags( BOOL fCreate, USHORT uiAttr, USHORT uiFlags,
|
||||
static void convert_open_flags( BOOL fCreate, ULONG ulAttr, USHORT uiFlags,
|
||||
int *flags, unsigned *mode,
|
||||
int *share, int *attr )
|
||||
{
|
||||
HB_TRACE(HB_TR_DEBUG, ("convert_open_flags(%d, %hu, %hu, %p, %p, %p, %p)", fCreate, uiAttr, uiFlags, flags, mode, share, attr));
|
||||
HB_TRACE(HB_TR_DEBUG, ("convert_open_flags(%d, %lu, %hu, %p, %p, %p, %p)", fCreate, ulAttr, uiFlags, flags, mode, share, attr));
|
||||
|
||||
/* file access mode */
|
||||
#if defined( HB_OS_UNIX )
|
||||
*mode = ( uiAttr & FC_HIDDEN ) ? S_IRUSR : ( S_IRUSR | S_IRGRP | S_IROTH );
|
||||
if( !( uiAttr & FC_READONLY ) )
|
||||
*mode = HB_FA_POSIX_ATTR( ulAttr );
|
||||
if( *mode == 0 )
|
||||
{
|
||||
if( *mode & S_IRUSR ) *mode |= S_IWUSR;
|
||||
if( *mode & S_IRGRP ) *mode |= S_IWGRP;
|
||||
if( *mode & S_IROTH ) *mode |= S_IWOTH;
|
||||
}
|
||||
if( uiAttr & FC_SYSTEM )
|
||||
{
|
||||
if( *mode & S_IRUSR ) *mode |= S_IXUSR;
|
||||
if( *mode & S_IRGRP ) *mode |= S_IXGRP;
|
||||
if( *mode & S_IROTH ) *mode |= S_IXOTH;
|
||||
*mode = ( ulAttr & FC_HIDDEN ) ? S_IRUSR : ( S_IRUSR | S_IRGRP | S_IROTH );
|
||||
if( !( ulAttr & FC_READONLY ) )
|
||||
{
|
||||
if( *mode & S_IRUSR ) *mode |= S_IWUSR;
|
||||
if( *mode & S_IRGRP ) *mode |= S_IWGRP;
|
||||
if( *mode & S_IROTH ) *mode |= S_IWOTH;
|
||||
}
|
||||
if( ulAttr & FC_SYSTEM )
|
||||
{
|
||||
if( *mode & S_IRUSR ) *mode |= S_IXUSR;
|
||||
if( *mode & S_IRGRP ) *mode |= S_IXGRP;
|
||||
if( *mode & S_IROTH ) *mode |= S_IXOTH;
|
||||
}
|
||||
}
|
||||
#else
|
||||
*mode = S_IREAD |
|
||||
( ( uiAttr & FC_READONLY ) ? 0 : S_IWRITE ) |
|
||||
( ( uiAttr & FC_SYSTEM ) ? S_IEXEC : 0 );
|
||||
( ( ulAttr & FC_READONLY ) ? 0 : S_IWRITE ) |
|
||||
( ( ulAttr & FC_SYSTEM ) ? S_IEXEC : 0 );
|
||||
#endif
|
||||
|
||||
/* dos file attributes */
|
||||
#if defined(HB_FS_DOSATTR)
|
||||
if( uiAttr == FC_NORMAL )
|
||||
#if defined( HB_FS_DOSATTR )
|
||||
if( ulAttr == FC_NORMAL )
|
||||
{
|
||||
*attr = _A_NORMAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
*attr = _A_ARCH;
|
||||
if( uiAttr & FC_READONLY )
|
||||
if( ulAttr & FC_READONLY )
|
||||
*attr |= _A_READONLY;
|
||||
if( uiAttr & FC_HIDDEN )
|
||||
if( ulAttr & FC_HIDDEN )
|
||||
*attr |= _A_HIDDEN;
|
||||
if( uiAttr & FC_SYSTEM )
|
||||
if( ulAttr & FC_SYSTEM )
|
||||
*attr |= _A_SYSTEM;
|
||||
}
|
||||
#else
|
||||
@@ -446,7 +462,7 @@ static void convert_open_flags( BOOL fCreate, USHORT uiAttr, USHORT uiFlags,
|
||||
}
|
||||
|
||||
/* shared flags (HB_FS_SOPEN) */
|
||||
#if defined(_MSC_VER) || defined(__DMC__)
|
||||
#if defined( _MSC_VER ) || defined( __DMC__ )
|
||||
if( ( uiFlags & FO_DENYREAD ) == FO_DENYREAD )
|
||||
*share = _SH_DENYRD;
|
||||
else if( uiFlags & FO_EXCLUSIVE )
|
||||
@@ -874,6 +890,170 @@ HB_EXPORT BOOL hb_fsSetDevMode( FHANDLE hFileHandle, USHORT uiDevMode )
|
||||
#endif
|
||||
}
|
||||
|
||||
HB_EXPORT BOOL hb_fsSetFileTime( BYTE * pszFileName, LONG lJulian, LONG lMillisec )
|
||||
{
|
||||
BOOL fResult;
|
||||
int iYear, iMonth, iDay;
|
||||
int iHour, iMinute, iSecond, iMSec;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_fsSetFileTime(%s, %ld, %ld)", pszFileName, lJulian, lMillisec));
|
||||
|
||||
hb_dateDecode( lJulian, &iYear, &iMonth, &iDay );
|
||||
hb_timeStampDecode( lMillisec, &iHour, &iMinute, &iSecond, &iMSec );
|
||||
|
||||
#if defined( HB_OS_WIN_32 ) && !defined( __CYGWIN__ )
|
||||
{
|
||||
FHANDLE hFile = hb_fsOpen( pszFileName, FO_READWRITE | FO_SHARED );
|
||||
|
||||
fResult = hFile != FS_ERROR;
|
||||
if( fResult )
|
||||
{
|
||||
FILETIME ft, local_ft;
|
||||
SYSTEMTIME st;
|
||||
|
||||
if( lJulian <= 0 || lMillisec < 0 )
|
||||
GetLocalTime( &st );
|
||||
else
|
||||
memset( &st, 0, sizeof( st ) );
|
||||
|
||||
if( lJulian > 0 )
|
||||
{
|
||||
st.wYear = iYear;
|
||||
st.wMonth = iMonth;
|
||||
st.wDay = iDay;
|
||||
}
|
||||
if( lMillisec >= 0 )
|
||||
{
|
||||
st.wHour = iHour;
|
||||
st.wMinute = iMinute;
|
||||
st.wSecond = iSecond;
|
||||
st.wMilliseconds = iMSec;
|
||||
}
|
||||
SystemTimeToFileTime( &st, &local_ft );
|
||||
LocalFileTimeToFileTime( &local_ft, &ft );
|
||||
fResult = SetFileTime( DosToWinHandle( hFile ), NULL, &ft, &ft ) != 0;
|
||||
hb_fsClose( hFile );
|
||||
}
|
||||
}
|
||||
#elif defined( HB_OS_OS2 )
|
||||
{
|
||||
FILESTATUS3 fs3;
|
||||
APIRET ulrc;
|
||||
BOOL fFree;
|
||||
|
||||
pszFileName = hb_fsNameConv( pszFileName, &fFree );
|
||||
|
||||
ulrc = DosQueryPathInfo( pszFileName, FIL_STANDARD, &fs3, sizeof( fs3 ) );
|
||||
if( ulrc == NO_ERROR )
|
||||
{
|
||||
FDATE fdate;
|
||||
FTIME ftime;
|
||||
|
||||
if( lJulian <= 0 || lMillisec < 0 )
|
||||
{
|
||||
DATETIME dt;
|
||||
|
||||
DosGetDateTime( &dt );
|
||||
|
||||
fdate.year = dt.year - 1980;
|
||||
fdate.month = dt.month;
|
||||
fdate.day = dt.day;
|
||||
ftime.hours = dt.hours;
|
||||
ftime.minutes = dt.minutes;
|
||||
ftime.twosecs = dt.seconds / 2;
|
||||
}
|
||||
if( lJulian > 0 )
|
||||
{
|
||||
fdate.year = iYear - 1980;
|
||||
fdate.month = iMonth;
|
||||
fdate.day = iDay;
|
||||
}
|
||||
if( lMillisec >= 0 )
|
||||
{
|
||||
ftime.hours = iHour;
|
||||
ftime.minutes = iMinute;
|
||||
ftime.twosecs = iSecond / 2;
|
||||
}
|
||||
|
||||
fs3.fdateCreation = fs3.fdateLastAccess = fs3.fdateLastWrite = fdate;
|
||||
fs3.ftimeCreation = fs3.ftimeLastAccess = fs3.ftimeLastWrite = ftime;
|
||||
ulrc = DosSetPathInfo( pszFileName, FIL_STANDARD,
|
||||
&fs3, sizeof( fs3 ), DSPI_WRTTHRU );
|
||||
}
|
||||
fResult = ulrc == NO_ERROR;
|
||||
if( fFree )
|
||||
hb_xfree( pszFileName );
|
||||
}
|
||||
#elif defined( OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ )
|
||||
{
|
||||
BOOL fFree;
|
||||
|
||||
pszFileName = hb_fsNameConv( pszFileName, &fFree );
|
||||
|
||||
if( lJulian <= 0 && lMillisec )
|
||||
{
|
||||
fResult = utime( pszFileName, NULL ) == 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct utimbuf buf;
|
||||
struct tm new_value;
|
||||
|
||||
if( lJulian <= 0 || lMillisec < 0 )
|
||||
{
|
||||
time_t current_time;
|
||||
|
||||
current_time = time( NULL );
|
||||
# if _POSIX_C_SOURCE < 199506L || defined( HB_OS_DARWIN_5 )
|
||||
new_value = *localtime( ¤t_time );
|
||||
# else
|
||||
localtime_r( ¤t_time, &new_value );
|
||||
# endif
|
||||
}
|
||||
else
|
||||
memset( &new_value, 0, sizeof( new_value ) );
|
||||
|
||||
if( lJulian > 0 )
|
||||
{
|
||||
new_value.tm_year = iYear - 1900;
|
||||
new_value.tm_mon = iMonth - 1;
|
||||
new_value.tm_mday = iDay;
|
||||
}
|
||||
if( lMillisec >= 0 )
|
||||
{
|
||||
new_value.tm_hour = iHour;
|
||||
new_value.tm_min = iMinute;
|
||||
new_value.tm_sec = iSecond;
|
||||
}
|
||||
buf.actime = buf.modtime = mktime( &new_value );
|
||||
fResult = utime( pszFileName, &buf ) == 0;
|
||||
}
|
||||
if( fFree )
|
||||
hb_xfree( pszFileName );
|
||||
}
|
||||
#else
|
||||
{
|
||||
int TODO; /* To force warning */
|
||||
|
||||
fResult = FALSE;
|
||||
hb_fsSetError( (USHORT) FS_ERROR );
|
||||
}
|
||||
#endif
|
||||
|
||||
return fResult;
|
||||
}
|
||||
|
||||
HB_EXPORT BOOL hb_fsSetAttr( BYTE * pszFileName, ULONG ulAttr )
|
||||
{
|
||||
BOOL fResult;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_fsSetAttr(%s, %lu)", pszFileName, ulAttr));
|
||||
|
||||
fResult = ulAttr != 0 && pszFileName != NULL;
|
||||
|
||||
return fResult;
|
||||
}
|
||||
|
||||
HB_EXPORT USHORT hb_fsRead( FHANDLE hFileHandle, BYTE * pBuff, USHORT uiCount )
|
||||
{
|
||||
USHORT uiRead;
|
||||
@@ -887,7 +1067,7 @@ HB_EXPORT USHORT hb_fsRead( FHANDLE hFileHandle, BYTE * pBuff, USHORT uiCount )
|
||||
DWORD dwRead ;
|
||||
BOOL fResult;
|
||||
|
||||
fResult = ReadFile( DosToWinHandle(hFileHandle), pBuff, (DWORD)uiCount, &dwRead, NULL );
|
||||
fResult = ReadFile( DosToWinHandle( hFileHandle ), pBuff, ( DWORD ) uiCount, &dwRead, NULL );
|
||||
hb_fsSetIOError( fResult, 0 );
|
||||
|
||||
uiRead = fResult ? ( USHORT ) dwRead : 0;
|
||||
@@ -925,12 +1105,12 @@ HB_EXPORT USHORT hb_fsWrite( FHANDLE hFileHandle, const BYTE * pBuff, USHORT uiC
|
||||
|
||||
if( uiCount )
|
||||
{
|
||||
fResult = WriteFile( DosToWinHandle(hFileHandle), pBuff, uiCount, &dwWritten, NULL );
|
||||
fResult = WriteFile( DosToWinHandle( hFileHandle ), pBuff, uiCount, &dwWritten, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
dwWritten = 0;
|
||||
fResult = SetEndOfFile( DosToWinHandle(hFileHandle) );
|
||||
fResult = SetEndOfFile( DosToWinHandle( hFileHandle ) );
|
||||
}
|
||||
hb_fsSetIOError( fResult, 0 );
|
||||
|
||||
@@ -974,7 +1154,7 @@ HB_EXPORT ULONG hb_fsReadLarge( FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount
|
||||
|
||||
#if defined(HB_WIN32_IO)
|
||||
{
|
||||
hb_fsSetIOError( ReadFile( DosToWinHandle(hFileHandle),
|
||||
hb_fsSetIOError( ReadFile( DosToWinHandle( hFileHandle ),
|
||||
pBuff, ulCount, &ulRead, NULL ), 0 );
|
||||
}
|
||||
#elif defined(HB_FS_LARGE_OPTIMIZED)
|
||||
@@ -1053,7 +1233,7 @@ HB_EXPORT ULONG hb_fsWriteLarge( FHANDLE hFileHandle, const BYTE * pBuff, ULONG
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_fsSetIOError( SetEndOfFile( DosToWinHandle(hFileHandle) ), 0 );
|
||||
hb_fsSetIOError( SetEndOfFile( DosToWinHandle( hFileHandle ) ), 0 );
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -1547,13 +1727,13 @@ HB_EXPORT ULONG hb_fsSeek( FHANDLE hFileHandle, LONG lOffset, USHORT uiFlags )
|
||||
}
|
||||
else
|
||||
{
|
||||
ulPos = (DWORD) SetFilePointer( DosToWinHandle(hFileHandle), lOffset, NULL, (DWORD)Flags );
|
||||
ulPos = (DWORD) SetFilePointer( DosToWinHandle( hFileHandle ), lOffset, NULL, ( DWORD ) Flags );
|
||||
hb_fsSetIOError( (DWORD) ulPos != INVALID_SET_FILE_POINTER, 0 );
|
||||
}
|
||||
|
||||
if( (DWORD) ulPos == INVALID_SET_FILE_POINTER )
|
||||
{
|
||||
ulPos = (DWORD) SetFilePointer( DosToWinHandle(hFileHandle), 0, NULL, SEEK_CUR );
|
||||
ulPos = (DWORD) SetFilePointer( DosToWinHandle( hFileHandle ), 0, NULL, SEEK_CUR );
|
||||
}
|
||||
#else
|
||||
/* This DOS hack creates 2GB file size limit, Druzus */
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(HB_FM_STATISTICS) && !defined(HB_TR_LEVEL)
|
||||
#define HB_TR_LEVEL HB_TR_ERROR
|
||||
# define HB_TR_LEVEL HB_TR_ERROR
|
||||
#endif
|
||||
|
||||
|
||||
@@ -325,13 +325,28 @@ HB_EXPORT void * hb_xrealloc( void * pMem, ULONG ulSize ) /* reallocates m
|
||||
{
|
||||
HB_TRACE_FM(HB_TR_DEBUG, ("hb_xrealloc(%p, %lu)", pMem, ulSize));
|
||||
|
||||
#if 0
|
||||
/* disabled to make hb_xrealloc() ANSI-C realloc() compatible */
|
||||
if( ! pMem )
|
||||
hb_errInternal( HB_EI_XREALLOCNULL, NULL, NULL, NULL );
|
||||
|
||||
if( ulSize == 0 )
|
||||
hb_errInternal( HB_EI_XREALLOCNULLSIZE, NULL, NULL, NULL );
|
||||
#endif
|
||||
|
||||
#ifdef HB_FM_STATISTICS
|
||||
if( pMem == NULL )
|
||||
{
|
||||
if( ulSize == 0 )
|
||||
hb_errInternal( HB_EI_XREALLOCNULLSIZE, NULL, NULL, NULL );
|
||||
return hb_xgrab( ulSize );
|
||||
}
|
||||
else if( ulSize == 0 )
|
||||
{
|
||||
hb_xfree( pMem );
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
PHB_MEMINFO pMemBlock;
|
||||
ULONG ulMemSize;
|
||||
@@ -387,7 +402,22 @@ HB_EXPORT void * hb_xrealloc( void * pMem, ULONG ulSize ) /* reallocates m
|
||||
}
|
||||
#else
|
||||
|
||||
pMem = realloc( HB_FM_PTR( pMem ), HB_ALLOC_SIZE( ulSize ) );
|
||||
if( pMem == NULL )
|
||||
{
|
||||
if( ulSize == 0 )
|
||||
hb_errInternal( HB_EI_XREALLOCNULLSIZE, NULL, NULL, NULL );
|
||||
pMem = malloc( HB_ALLOC_SIZE( ulSize ) );
|
||||
}
|
||||
else if( ulSize == 0 )
|
||||
{
|
||||
free( HB_FM_PTR( pMem ) );
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pMem = realloc( HB_FM_PTR( pMem ), HB_ALLOC_SIZE( ulSize ) );
|
||||
}
|
||||
|
||||
if( !pMem )
|
||||
hb_errInternal( HB_EI_XREALLOC, NULL, NULL, NULL );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user