source: box/trunk/lib/common/FileStream.h @ 2512

Revision 2512, 1.6 KB checked in by chris, 3 years ago (diff)

Move definition of INVALID_HANDLE_VALUE and tOSFileHandle to
BoxPlatform?.h, to make them available in other files.

  • Property svn:eol-style set to native
Line 
1// --------------------------------------------------------------------------
2//
3// File
4//              Name:    FileStream.h
5//              Purpose: FileStream interface to files
6//              Created: 2003/07/31
7//
8// --------------------------------------------------------------------------
9
10#ifndef FILESTREAM__H
11#define FILESTREAM__H
12
13#include "IOStream.h"
14
15#include <fcntl.h>
16#include <stdlib.h>
17#include <sys/stat.h>
18
19#ifdef HAVE_UNISTD_H
20        #include <unistd.h>
21#endif
22
23class FileStream : public IOStream
24{
25public:
26        FileStream(const std::string& rFilename, 
27                int flags = (O_RDONLY | O_BINARY),
28                int mode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH));
29
30        // Ensure that const char * name doesn't end up as a handle
31        // on Windows!
32
33        FileStream(const char *pFilename, 
34                int flags = (O_RDONLY | O_BINARY),
35                int mode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH));
36
37        FileStream(tOSFileHandle FileDescriptor);
38       
39        virtual ~FileStream();
40       
41        virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite);
42        virtual pos_type BytesLeftToRead();
43        virtual void Write(const void *pBuffer, int NBytes);
44        virtual pos_type GetPosition() const;
45        virtual void Seek(IOStream::pos_type Offset, int SeekType);
46        virtual void Close();
47       
48        virtual bool StreamDataLeft();
49        virtual bool StreamClosed();
50
51        bool CompareWith(IOStream& rOther, int Timeout = IOStream::TimeOutInfinite);
52
53private:
54        tOSFileHandle mOSFileHandle;
55        bool mIsEOF;
56        FileStream(const FileStream &rToCopy) { /* do not call */ }
57        void AfterOpen();
58
59        // for debugging..
60        std::string mFileName;
61};
62
63
64#endif // FILESTREAM__H
65
66
Note: See TracBrowser for help on using the repository browser.