home *** CD-ROM | disk | FTP | other *** search
- #ifndef __RWFILE_H__
- #define __RWFILE_H__
- pragma push_align_members(64);
-
- /*
- * Class RWFile encapsulates ANSI-C binary file operations.
- *
- * $Header: E:/vcs/rw/rwfile.h_v 1.5 18 Feb 1992 09:54:38 KEFFER $
- *
- ****************************************************************************
- *
- * Rogue Wave
- * P.O. Box 2328
- * Corvallis, OR 97339
- * Voice: (503) 754-3010 FAX: (503) 757-6650
- *
- * Copyright (C) 1991. This software is subject to copyright
- * protection under the laws of the United States and other countries.
- *
- ***************************************************************************
- *
- * $Log: E:/vcs/rw/rwfile.h_v $
- *
- * Rev 1.5 18 Feb 1992 09:54:38 KEFFER
- *
- * Rev 1.4 17 Oct 1991 09:12:56 keffer
- * Changed include path to <rw/xxx.h>
- *
- * Rev 1.2 29 Jul 1991 11:03:38 keffer
- * Made Exists(const char*) a static function.
- *
- * Rev 1.1 24 Jul 1991 13:06:48 keffer
- * Added pvcs keywords
- */
-
- /*
- * Under Unix, there there is no difference between text and binary
- * files. However, under MS-DOS, and some other operating systems,
- * files opened for *text* output will use a CR/LF convention to end
- * text lines, but do nothing for binary files. Because RWFile is
- * intended to model *binary* files, we must shut off this translation.
- * This requires opening the file in an explicit "binary" mode.
- * This situation is detected by the macro "CRLF_CONVENTION".
- */
-
- #include "rw/defs.h"
- STARTWRAP
- #include <stdio.h>
- ENDWRAP
-
- class RWExport RWFile {
- protected:
- char* filename;
- FILE* filep;
- public:
- RWFile(const char* name);
- ~RWFile();
-
- const char* GetName() {return filename;}
- RWBoolean Exists();
- static RWBoolean Exists(const char* name);
-
- RWBoolean Read(char& c);
- RWBoolean Read(short& i);
- RWBoolean Read(int& i);
- RWBoolean Read(long& i);
- #ifndef CHAR_MATCHES_UCHAR
- RWBoolean Read(unsigned char& c);
- #endif
- RWBoolean Read(unsigned short& i);
- RWBoolean Read(unsigned int& i);
- RWBoolean Read(unsigned long& i);
- RWBoolean Read(float& f);
- RWBoolean Read(double& d);
- RWBoolean Read(char* c, int N);
- RWBoolean Read(short* i, int N);
- RWBoolean Read(int* i, int N);
- RWBoolean Read(long* i, int N);
- #ifndef CHAR_MATCHES_UCHAR
- RWBoolean Read(unsigned char* c, int N){return Read((char*)c, N);}
- #endif
- RWBoolean Read(unsigned int* i, int N) {return Read(( int*)i, N);}
- RWBoolean Read(float* f, int N);
- RWBoolean Read(double* d, int N);
-
- // Read to null terminator or EOF; no CR/LF translation will be done. Beware of overflow.
- RWBoolean Read(char* string);
-
- RWBoolean Write(char c);
- RWBoolean Write(short s);
- RWBoolean Write(int i);
- RWBoolean Write(long l);
- #ifndef CHAR_MATCHES_UCHAR
- RWBoolean Write(unsigned char c);
- #endif
- RWBoolean Write(unsigned short s);
- RWBoolean Write(unsigned int i);
- RWBoolean Write(unsigned long l);
- RWBoolean Write(float f);
- RWBoolean Write(double d);
- RWBoolean Write(const char* string);
- RWBoolean Write(const short* i, int N);
- RWBoolean Write(const int* i, int N);
- RWBoolean Write(const long* i, int N);
- #ifndef CHAR_MATCHES_UCHAR
- RWBoolean Write(const unsigned char* c, int N){return Write((const char*)c, N);}
- #endif
- RWBoolean Write(const unsigned int* i, int N){return Write((const int*)i, N);}
- RWBoolean Write(const float* f, int N);
- RWBoolean Write(const double* d, int N);
- RWBoolean Write(const char* string, int N);
-
- long CurOffset(); // Returns current offset of file
- RWBoolean Eof(); // TRUE if file at EOF
- RWBoolean Erase();
- RWBoolean Error(); // TRUE if the file has had an error.
- RWBoolean Flush(); // Writes all pending output
- RWBoolean IsEmpty(); // TRUE if the file is empty
- RWBoolean SeekTo(long offset); /* offset bytes from beginning of file */
- RWBoolean SeekToBegin() {return SeekTo(0);}
- RWBoolean SeekToEnd();
- };
-
- pragma pop_align_members();
- #endif /* __RWFILE_H__ */
-