diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a4289528ee..32b0b1b7ac 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,13 @@ past entries belonging to these authors: Viktor Szakats. */ +2009-05-12 18:05 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/filesys.c + + added support for millisecond precision in hb_fsGetFileTime()/ + hb_fsSetFileTime() in Linux builds. Please note that file time + precision depends also on used file system and Linux kernel so + it does not have to work in all cases. + 2009-05-12 16:10 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * utils/hbmk2/hbmk2.prg + Added -hbrun option which will run the target without trying to diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index 7bf08808c5..263b9451b3 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -122,6 +122,9 @@ #include #include #include + #if defined( HB_OS_LINUX ) + #include + #endif #endif #if ( defined(__DMC__) || defined(__BORLANDC__) || \ @@ -971,8 +974,13 @@ BOOL hb_fsGetFileTime( BYTE * pszFileName, LONG * plJulian, LONG * plMillisec ) # endif *plJulian = hb_dateEncode( ft.tm_year + 1900, ft.tm_mon + 1, ft.tm_mday ); +#if defined( HB_OS_LINUX ) && ( defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) ) && \ + defined( __GLIBC__ ) && defined( __GLIBC_MINOR__ ) && \ + ( __GLIBC__ > 2 || ( __GLIBC__ == 2 && __GLIBC_MINOR__ >= 6 ) ) + *plMillisec = hb_timeEncode( ft.tm_hour, ft.tm_min, ft.tm_sec, sStat.st_mtim.tv_nsec / 1000000 ); +#else *plMillisec = hb_timeEncode( ft.tm_hour, ft.tm_min, ft.tm_sec, 0 ); - +#endif fResult = TRUE; } hb_fsSetIOError( fResult, 0 ); @@ -1193,7 +1201,6 @@ BOOL hb_fsSetFileTime( BYTE * pszFileName, LONG lJulian, LONG lMillisec ) } else { - struct utimbuf buf; struct tm new_value; time_t tim; @@ -1229,8 +1236,20 @@ BOOL hb_fsSetFileTime( BYTE * pszFileName, LONG lJulian, LONG lMillisec ) # else new_value = *gmtime( &tim ); # endif - buf.actime = buf.modtime = mktime( &new_value ); - fResult = utime( ( char * ) pszFileName, &buf ) == 0; +#if defined( HB_OS_LINUX ) + { + struct timeval times[2]; + times[ 0 ].tv_sec = times[ 1 ].tv_sec = mktime( &new_value ); + times[ 0 ].tv_usec = times[ 1 ].tv_usec = iMSec * 1000; + fResult = utimes( ( char * ) pszFileName, times ) == 0; + } +#else + { + struct utimbuf buf; + buf.actime = buf.modtime = mktime( &new_value ); + fResult = utime( ( char * ) pszFileName, &buf ) == 0; + } +#endif } hb_fsSetIOError( fResult, 0 ); hb_vmLock();