From 00bb8c39b97638c872ebccc6aee7f3c5fb57d7d6 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 27 Jan 2009 16:54:55 +0000 Subject: Corrected the Bu::File::canRead() and Bu::File::canWrite() functions, they work now. It helps to read the system docs. Anyway, nids is all fixed up, it seems to work great now, and I guess I got all the corner cases we'll hit for a while, fishtrax really did a number on them :) I also cleaned up all the debugging output, now you can see your program run instead of libbu++ internals. There could still be a good amount of improvement made in nids, it really shouldn't re-write whole blocks every time you write to a stream, but that will be an easy change down the line that won't effect any of the existing code. --- src/file.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/file.cpp') diff --git a/src/file.cpp b/src/file.cpp index 20ff5c9..aa0ea32 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -113,7 +113,10 @@ bool Bu::File::canRead() #ifdef WIN32 return true; #else - return (fcntl( fd, F_GETFL, 0 )&O_RDONLY) == O_RDONLY; + int iMode = fcntl( fd, F_GETFL, 0 )&O_ACCMODE; + if( iMode == O_RDONLY || iMode == O_RDWR ) + return true; + return false; #endif } @@ -122,7 +125,10 @@ bool Bu::File::canWrite() #ifdef WIN32 return true; #else - return (fcntl( fd, F_GETFL, 0 )&O_WRONLY) == O_WRONLY; + int iMode = fcntl( fd, F_GETFL, 0 )&O_ACCMODE; + if( iMode == O_WRONLY || iMode == O_RDWR ) + return true; + return false; #endif } -- cgit v1.2.3