Update of /cvsroot/rtk/rtk/src/core/platform/linux
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23534/core/platform/linux
Modified Files:
File.cpp
Log Message:
Some File changes for Linux (w/o testing)
Index: File.cpp
===================================================================
RCS file: /cvsroot/rtk/rtk/src/core/platform/linux/File.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** File.cpp 13 Jun 2004 07:41:16 -0000 1.6
--- File.cpp 13 Jun 2004 10:38:33 -0000 1.7
***************
*** 154,158 ****
}
! void File::SetMode(int mode)
{
ClearFlag(CAN_READ | CAN_WRITE, _flags);
--- 154,158 ----
}
! void File::SetMode(uint mode)
{
ClearFlag(CAN_READ | CAN_WRITE, _flags);
***************
*** 180,185 ****
#endif
! bool File::Open()
{
const RCHAR *file = _filename.c_str();
const char *afile = NULL;
--- 180,188 ----
#endif
! int File::Open()
{
+ if(IsOpen())
+ ERROR_RETURN(ALREADY_OPEN);
+
const RCHAR *file = _filename.c_str();
const char *afile = NULL;
***************
*** 187,198 ****
#ifdef UNICODE
W2A(file, afile);
! if(afile==NULL) return false;
#else
afile = file;
#endif
- if (_handle!=INVALID_HANDLE_VALUE)
- return false;
-
int open_flags = 0;
if(_mode & READ)
--- 190,198 ----
#ifdef UNICODE
W2A(file, afile);
! if(afile==NULL) ERROR_RETURN(OPERATION_FAILED);
#else
afile = file;
#endif
int open_flags = 0;
if(_mode & READ)
***************
*** 211,214 ****
--- 211,217 ----
_handle = (void*) open(afile, open_flags, 0666);
+ if(FD == -1)
+ ERROR_RETURN(OPERATION_FAILED);
+
if(_mode & LOCKED)
{
***************
*** 220,232 ****
}
! return IsOpen();
}
! bool File::Close()
{
int ret; // return value
! // Do not close external handle!
! if (_flags & EXTERN_HANDLE) return false;
! if (_handle==INVALID_HANDLE_VALUE) return false;
//unlock the file
--- 223,235 ----
}
! RETURN_SUCCESS;
}
! int File::Close()
{
int ret; // return value
!
! if (_flags & EXTERN_HANDLE) ERROR_RETURN(CANNOT_CLOSE_EXTERNAL);
! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN);
//unlock the file
***************
*** 243,247 ****
#ifdef UNICODE
W2A(file, afile);
! if(afile==NULL) return false;
#else
afile = file;
--- 246,250 ----
#ifdef UNICODE
W2A(file, afile);
! if(afile==NULL) ERROR_RETURN(OPERATION_FAILED);
#else
afile = file;
***************
*** 257,269 ****
}
! bool File::IsOpen() const
! {
! return (_handle!=INVALID_HANDLE_VALUE);
! }
!
! int File::Read(void *buffer, int buffer_len)
{
! if(!CanRead()) return false;
! if(_handle==INVALID_HANDLE_VALUE) return -1;
int read_bytes = 0;
--- 260,268 ----
}
! long File::Read(void *buffer, long buffer_len)
{
! if(!CanRead()) ERROR_RETURN(DEVICE_READ_PROTECTED);
! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN);
!
int read_bytes = 0;
***************
*** 279,286 ****
}
! int File::Write(void *buffer, int buffer_len)
{
! if(!CanWrite()) return false;
! if(_handle==INVALID_HANDLE_VALUE) return -1;
int written_bytes = 0;
--- 278,286 ----
}
! long File::Write(void *buffer, long buffer_len)
{
! if(!CanWrite()) ERROR_RETURN(DEVICE_WRITE_PROTECTED);
! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN);
!
int written_bytes = 0;
***************
*** 297,302 ****
long File::Seek(long pos, IO::SeekMethod method)
{
! if(_handle==INVALID_HANDLE_VALUE) return -1;
! if(!CanSeek()) return -1;
int seek_method = SEEK_SET;
--- 297,302 ----
long File::Seek(long pos, IO::SeekMethod method)
{
! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN);
! if(!CanSeek()) ERROR_RETURN(OPERATION_FAILED);
int seek_method = SEEK_SET;
***************
*** 311,315 ****
long File::Tell()
{
! if(_handle==INVALID_HANDLE_VALUE) return -1;
if(!CanSeek()) return -1;
--- 311,315 ----
long File::Tell()
{
! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN);
if(!CanSeek()) return -1;
***************
*** 317,323 ****
}
! bool File::Flush()
{
! if(_handle==INVALID_HANDLE_VALUE) return false;
return (fsync(FD)==0);
}
--- 317,323 ----
}
! int File::Flush()
{
! if(!IsOpen()) ERROR_RETURN(DEVICE_NOT_OPEN);
return (fsync(FD)==0);
}
|