From 7fd398337014d71e5f6c9acc79e43d122e72c05e Mon Sep 17 00:00:00 2001 From: Eddie Runia Date: Sun, 23 May 1999 10:32:51 +0000 Subject: [PATCH] Probably forgot to commit --- harbour/ChangeLog | 8 +++++- harbour/source/rtl/files.c | 44 +++++++++++++++++++------------ harbour/tests/working/iotest.prg | 30 +++++++++++++++++++++ harbour/tests/working/passref.prg | 17 ++++++++++++ 4 files changed, 81 insertions(+), 18 deletions(-) create mode 100644 harbour/tests/working/iotest.prg create mode 100644 harbour/tests/working/passref.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index cc8a9270e3..14b14ee8f3 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,4 +1,10 @@ -19990520-18:30 CET Eddie Runia +19990523-08:00 CET Les Griffith (upload by Eddie Runia) + * source/rtl/files.c + Yes, revision 1.2 ! + * tests/working/passref.prg, tests/working/iotest.prg + test files added. (Not functioning correctly yet) + +19990522-18:30 CET Eddie Runia * tests/working/runner.c command-line arguments passed to both init function and running program * tests/working/spawn.prg diff --git a/harbour/source/rtl/files.c b/harbour/source/rtl/files.c index 457117a67e..54db5bb7d4 100644 --- a/harbour/source/rtl/files.c +++ b/harbour/source/rtl/files.c @@ -32,6 +32,7 @@ #endif #if defined(__BORLANDC__) + #include #include #endif @@ -162,7 +163,7 @@ int _fsOpen( char * name, int flags ) #if defined(HAVE_POSIX_IO) return open(name,convert_open_flags(flags)); #else - return 0; + return open(name, flags); #endif } @@ -171,15 +172,18 @@ int _fsCreate( char * name, int flags ) #if defined(HAVE_POSIX_IO) return creat(name,convert_create_flags(flags)); #else - return 0; + /* TO DO create a file with attributes in flags + for now create it normal */ + return creat(name,S_IWRITE); #endif } -void _fsClose( int handle ) +int _fsClose( int handle ) { #if defined(HAVE_POSIX_IO) - close(handle); - return; + return close(handle); +#else + return close(handle); #endif } @@ -188,7 +192,7 @@ long _fsRead( int handle, char * buff, long count ) #if defined(HAVE_POSIX_IO) return read(handle,buff,count); #else - return 0; + return read(handle,buff,count); #endif } @@ -197,7 +201,7 @@ long _fsWrite( int handle, char * buff, long count ) #if defined(HAVE_POSIX_IO) return write(handle,buff,count); #else - return 0; + return write(handle,buff,count); #endif } @@ -206,7 +210,7 @@ long _fsSeek( int handle, long offset, int flags ) #if defined(HAVE_POSIX_IO) return lseek(handle,offset,convert_seek_flags(flags)); #else - return 0; + return lseek(handle,offset,flags); #endif } @@ -215,18 +219,21 @@ int _fsError() return last_error; } -void _fsDelete( char * name ) +int _fsDelete( char * name ) { #if defined(HAVE_POSIX_IO) unlink(name); +#else + return unlink(name); #endif } -void _fsRename( char * older, char * newer ) +int _fsRename( char * older, char * newer ) { #if defined(HAVE_POSIX_IO) - rename(older,newer); - return; + return rename(older,newer); +#else + return rename(older,newer); #endif } @@ -236,9 +243,11 @@ int _fsLock( int handle, long start, long length, long mode ) #if defined(HAVE_POSIX_IO) /* TODO: I'm thinking about this :) */ + return; +#else + /* TODO not in io,h is in stdio.h as fflush(handle)*/ + return; #endif - - return result; } void _fsCommit( int handle ) @@ -324,6 +333,7 @@ long _fsIsDrv( int driver ) int _fsExtOpen(PBYTE filename, PBYTE defExt, ULONG flags, PBYTE paths, ERRORP error ); + #endif /* @@ -459,7 +469,7 @@ HARBOUR FCLOSE() if( arg1_it ) { - result=close(_parni(1)); + result= _fsClose(_parni(1)); /* last_error = errno; */ } @@ -475,7 +485,7 @@ HARBOUR FERASE() if( arg1_it ) { - result=unlink(_parc(1)); + result= _fsDelete(_parc(1)); last_error = errno; } @@ -492,7 +502,7 @@ HARBOUR FRENAME() if( arg1_it && arg2_it ) { - result = rename(_parc(1),_parc(1)); + result = _fsRename(_parc(1),_parc(1)); last_error = errno; } diff --git a/harbour/tests/working/iotest.prg b/harbour/tests/working/iotest.prg new file mode 100644 index 0000000000..5ec55cae65 --- /dev/null +++ b/harbour/tests/working/iotest.prg @@ -0,0 +1,30 @@ +// Testing Harbour file io features + +function Main() + + local h := 0 + local cstr := " " + local ntmp := 0 + + h := FCreate( "test.txt") + qout('create handle',h) + + FWrite( h, "This test worked if you can see this" ) + + FClose( h ) + + h := FOpen("test.txt") + qout('open handle',h) + qout() + /* try to read what is there */ + do while .t. + ntmp := FRead( h, @cstr, 1) + if ntmp == 0 + exit + endif + qqout(cstr) + enddo + + FClose( h ) + +return nil diff --git a/harbour/tests/working/passref.prg b/harbour/tests/working/passref.prg new file mode 100644 index 0000000000..8bee5842bf --- /dev/null +++ b/harbour/tests/working/passref.prg @@ -0,0 +1,17 @@ +/* test of pass by reference @ */ + +function main +local a := 10 + +qout('a := 10',a) +testfun(@a) +qout('return of reference should = 20',a,iif(a == 20,"worked","failed")) + +return nil + +function testfun(b) +b := b + 10 +qout('pointer+10 =',b) + +return nil +