diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 0ad3ceec9c..66a88e1d5a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,11 @@ +19990626-13:35 Ryszard Glab + +* source/rtl/copyfile.c + * added code to copy also the file permissions on *nix + +* source/rtl/files.c + * 'access' function should use F_OK constant instead of 0 on *nix + 19990626-13:12 Ryszard Glab * tests/working/Makefile diff --git a/harbour/source/rtl/copyfile.c b/harbour/source/rtl/copyfile.c index dc079189a6..e448e9ad59 100644 --- a/harbour/source/rtl/copyfile.c +++ b/harbour/source/rtl/copyfile.c @@ -8,6 +8,11 @@ #include #include +#ifdef OS_UNIX_COMPATIBLE + #include + #include +#endif + #define BUFFER_SIZE 8192 static long hb_fsCopy(BYTEP ,BYTEP ) ; @@ -36,6 +41,10 @@ static long hb_fsCopy(BYTEP source,BYTEP dest) USHORT usCount; ULONG ulCount = 0L; PHB_ITEM pError; +#ifdef OS_UNIX_COMPATIBLE + struct stat struFileInfo; + int iSuccess; +#endif sHANDLE = hb_fsOpen(source, FO_READ); if ( hb_fsError() ) { @@ -45,6 +54,9 @@ static long hb_fsCopy(BYTEP source,BYTEP dest) hb_errRelease(pError); return( -1L) ; } +#ifdef OS_UNIX_COMPATIBLE + iSuccess =fstat( sHANDLE, &struFileInfo ); +#endif dHANDLE = hb_fsCreate(dest,FC_NORMAL); if ( hb_fsError() ) { @@ -71,6 +83,10 @@ static long hb_fsCopy(BYTEP source,BYTEP dest) hb_fsWrite(dHANDLE,buffer,usCount); hb_xfree(buffer); hb_fsClose(sHANDLE); +#ifdef OS_UNIX_COMPATIBLE + if( iSuccess == 0 ) + fchmod( dHANDLE, struFileInfo.st_mode ); +#endif hb_fsClose(dHANDLE); return( ulCount ); } diff --git a/harbour/source/rtl/files.c b/harbour/source/rtl/files.c index 66eab950df..fee55e76b8 100644 --- a/harbour/source/rtl/files.c +++ b/harbour/source/rtl/files.c @@ -659,7 +659,12 @@ HARBOUR HB_FILE( void ) if( arg1_it ) { +/*TODO: Check if F_OK is defined in all compilers */ +#ifdef OS_UNIX_COMPATIBLE + hb_retl( access(hb_parc(1), F_OK) == 0 ); +#else hb_retl( access(hb_parc(1), 0) == 0 ); +#endif } else hb_retl(0); return;