From ff27efa1f2686f86a93a097f72c2c843fd3de493 Mon Sep 17 00:00:00 2001 From: Bruno Cantero Date: Sun, 1 Aug 1999 18:37:29 +0000 Subject: [PATCH] ChangeLogTag:19990801-20:20 GMT+1 Bruno Cantero --- harbour/ChangeLog | 6 +++ harbour/source/rtl/files.c | 72 ++++++++++++++++++++++++++----- harbour/tests/working/buildvc.bat | 2 +- 3 files changed, 68 insertions(+), 12 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 733b92f4a8..2ca7e34233 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,9 @@ +19990801-20:20 GMT+1 Bruno Cantero + * source/rtl/files.c + Changed for MSVC + * tests/working/buildvc.bat + Added a include path to harbour + 19990801-18:14 CET Victor Szel ! source/compiler/harbour.y - hb_INITSTATICS() -> HB_INITSTATICS() (case adjusted) diff --git a/harbour/source/rtl/files.c b/harbour/source/rtl/files.c index bd75c1edc2..8809d911b3 100644 --- a/harbour/source/rtl/files.c +++ b/harbour/source/rtl/files.c @@ -161,7 +161,7 @@ HB_INIT_SYMBOLS_END( Files__InitSymbols ); /* Convert HARBOUR flags to IO subsystem flags */ -#if defined(HAVE_POSIX_IO) +#if defined(HAVE_POSIX_IO) || defined(_MSC_VER) static int convert_open_flags( int flags ) { @@ -247,8 +247,14 @@ FHANDLE hb_fsOpen ( BYTEP name, USHORT flags ) handle = open((char *)name,convert_open_flags(flags)); last_error = errno; #else + #if defined( _MSC_VER ) + errno = 0; + handle = _open( ( char * ) name, convert_open_flags( flags ) ); + last_error = errno; + #else handle = FS_ERROR; last_error = FS_ERROR; + #endif #endif return handle; } @@ -271,31 +277,56 @@ FHANDLE hb_fsCreate ( BYTEP name, USHORT flags ) last_error = errno; } #else + #if defined( _MSC_VER ) + errno = 0; + convert_create_flags( flags, &oflag, &pmode ); + handle = _open( ( char * ) name, oflag, pmode ); + if( handle == FS_ERROR ) + { + /* This if block is required, because errno will be set + if the file did not exist and had to be created, even + when the create is successful! */ + last_error = errno; + } + #else handle = FS_ERROR; last_error = FS_ERROR; + #endif #endif return handle; } void hb_fsClose ( FHANDLE handle ) { -#if defined(HAVE_POSIX_IO) - close(handle); +#if defined( HAVE_POSIX_IO ) + close( handle ); return; +#else + #if defined( _MSC_VER ) + _close( handle ); + return; + #endif #endif } USHORT hb_fsRead ( FHANDLE handle, BYTEP buff, USHORT count ) { USHORT bytes; -#if defined(HAVE_POSIX_IO) +#if defined( HAVE_POSIX_IO ) errno = 0; - bytes = read(handle,buff,count); + bytes = read( handle, buff, count ); last_error = errno; if( bytes == 65535U ) bytes = 0; #else + #if defined( _MSC_VER ) + errno = 0; + bytes = _read( handle, buff, count ); + last_error = errno; + if( bytes == 65535U ) bytes = 0; + #else bytes = 0; last_error = FS_ERROR; + #endif #endif return bytes; } @@ -303,13 +334,19 @@ USHORT hb_fsRead ( FHANDLE handle, BYTEP buff, USHORT count ) USHORT hb_fsWrite ( FHANDLE handle, BYTEP buff, USHORT count ) { USHORT bytes; -#if defined(HAVE_POSIX_IO) +#if defined( HAVE_POSIX_IO ) errno = 0; - bytes = write(handle,buff,count); + bytes = write( handle, buff, count ); last_error = errno; #else + #if defined( _MSC_VER ) + errno = 0; + bytes = _write( handle, buff, count ); + last_error = errno; + #else bytes = 0; last_error = FS_ERROR; + #endif #endif return bytes; } @@ -319,11 +356,17 @@ ULONG hb_fsSeek ( FHANDLE handle, LONG offset, USHORT flags ) ULONG position; #if defined(HAVE_POSIX_IO) errno = 0; - position = lseek(handle,offset,convert_seek_flags(flags)); + position = lseek( handle, offset, convert_seek_flags( flags ) ); last_error = errno; #else + #if defined( _MSC_VER ) + errno = 0; + position = _lseek( handle, offset, convert_seek_flags( flags ) ); + last_error = errno; + #else position = 0; last_error = FS_ERROR; + #endif #endif return position; } @@ -337,17 +380,24 @@ void hb_fsDelete ( BYTEP name ) { #if defined(HAVE_POSIX_IO) errno = 0; - unlink(( char *)name ); + unlink( ( char * ) name ); last_error = errno; return; +#else + #if defined( _MSC_VER ) + errno = 0; + remove( ( char *) name ); + last_error = errno; + return; + #endif #endif } void hb_fsRename ( BYTEP older, BYTEP newer ) { -#if defined(HAVE_POSIX_IO) +#if defined(HAVE_POSIX_IO) || defined( _MSC_VER ) errno = 0; - rename( (char *)older, (char *)newer ); + rename( ( char * ) older, ( char * ) newer ); last_error = errno; return; #endif diff --git a/harbour/tests/working/buildvc.bat b/harbour/tests/working/buildvc.bat index f88837cf86..72636fb6eb 100644 --- a/harbour/tests/working/buildvc.bat +++ b/harbour/tests/working/buildvc.bat @@ -1,2 +1,2 @@ -..\..\bin\harbour %1 /n +..\..\bin\harbour %1 /n /i..\..\include cl -Fd..\..\bin\harbour -w -Zi -TP -GZ -GA -DDEBUG -DHARBOUR_USE_GTAPI -DHARBOUR_USE_WIN_GTAPI -I..\..\include %1.c /link /subsystem:CONSOLE ..\..\obj\symbols.obj ..\..\libs\vc\harbour.lib ..\..\libs\vc\terminal.lib ..\..\libs\vc\hbtools.lib ..\..\libs\vc\dbfntx.lib