MrSID Decode SDK for Raster Reference Manual  9.5.5.5244
lt_ioFileStream.h
Go to the documentation of this file.
1 //
2 // This code is property of Celartem, Inc dba Extensis.
3 // Copyright (c) 1995-2023. All rights reserved.
4 // Use permitted only under license from Extensis.
5 //
6 /* PUBLIC */
7 
8 #ifndef LT_IO_FILE_STREAM_H
9 #define LT_IO_FILE_STREAM_H
10 
11 #include "lt_ioStreamInf.h"
12 #include "lt_fileSpec.h"
13 #include <stdio.h>
14 
15 #ifdef __ANDROID__
16  #define USE_UNBUFFERED_READER
17 #endif
18 
19 #if defined(LT_USE_DIGMAP)
20 LT_BEGIN_LIZARDTECH_NAMESPACE
21 class LTDigmapFile;
22 LT_END_LIZARDTECH_NAMESPACE
23 #endif
24 
25 LT_BEGIN_LIZARDTECH_NAMESPACE
26 
27 
35 {
36 public:
37 
42 
47 
51  virtual ~LTIOFileStream(void);
52 
59  virtual LT_STATUS initialize(const LTFileSpec& fs, const char* mode);
60  LT_STATUS initialize(const char* path, const char* mode);
62 
63  // LTIOStreamInf overrides
64  virtual bool isEOF();
65  virtual bool isOpen();
66  virtual LT_STATUS open();
67  virtual LT_STATUS close();
68  virtual lt_uint32 read(lt_uint8 *pDest, lt_uint32 numBytes);
69  virtual lt_uint32 write(const lt_uint8 *pSrc, lt_uint32 numBytes);
70  virtual LT_STATUS seek(lt_int64 offset, LTIOSeekDir origin);
71  virtual lt_int64 tell();
73  virtual LT_STATUS getLastError() const;
74  virtual const char* getID() const;
75 
83  int stdio_ferror();
84 
90 
101  int stdio_setvbuf( lt_uint8* buf, lt_uint32 mode, lt_uint32 size );
102 
103 private:
104 
105  void cleanup();
106  bool shouldRetry();
107 
108 protected:
109 
110 #if defined(LT_USE_DIGMAP)
111  LTDigmapFile *m_dmfile;
112 #elif defined(USE_UNBUFFERED_READER)
113  int m_fd;
114 #else
115  FILE* m_file;
117 #endif
118 
119  enum
120  {
123  writing_state = 3
125 
127  char *m_mode;
128  char *m_uri;
129 };
130 
131 LT_END_LIZARDTECH_NAMESPACE
132 
133 #endif // LT_STREAMINF_H
LTIOSeekDir
Stream seek directions.
Definition: lt_lib_io.h:26
lt_uint32 LT_STATUS
An integral status code.
Definition: lt_status.h:30
unsigned char lt_uint8
unsigned 8-bit integer
Definition: lt_types.h:36
unsigned int lt_uint32
unsigned 32-bit integer
Definition: lt_types.h:44
long long int lt_int64
signed 64-bit integer
Definition: lt_types.h:57
Represents a file or directory path.
Definition: lt_fileSpec.h:35
File stream.
virtual const char * getID() const
Default Constructor.
virtual lt_uint32 write(const lt_uint8 *pSrc, lt_uint32 numBytes)
Default Constructor.
int stdio_ferror()
Returns underlying stdio error code.
void stdio_clearerr()
Clears underlying stdio error code.
virtual lt_uint32 read(lt_uint8 *pDest, lt_uint32 numBytes)
Default Constructor.
LT_STATUS initialize(const char *path, const char *mode)
Default Constructor.
virtual LT_STATUS seek(lt_int64 offset, LTIOSeekDir origin)
Default Constructor.
virtual lt_int64 tell()
Default Constructor.
bool m_onceOpened
Returns underlying stdio error code.
LTFileSpec m_path
Returns underlying stdio error code.
virtual bool isEOF()
Default Constructor.
virtual LT_STATUS close()
Default Constructor.
virtual LTIOStreamInf * duplicate()
Default Constructor.
int stdio_setvbuf(lt_uint8 *buf, lt_uint32 mode, lt_uint32 size)
Set buffering - may be called only after open() but before the first read/write operation.
virtual bool isOpen()
Default Constructor.
virtual ~LTIOFileStream(void)
Destructor.
enum LTIOFileStream::@1 m_state
Returns underlying stdio error code.
char * m_uri
Returns underlying stdio error code.
FILE * m_file
Returns underlying stdio error code.
LTIOFileStream(void)
Default Constructor.
virtual LT_STATUS getLastError() const
Default Constructor.
char * m_mode
Returns underlying stdio error code.
virtual LT_STATUS initialize(const LTFileSpec &fs, const char *mode)
Initializes the stream from a file spec.
virtual LT_STATUS open()
Default Constructor.
Abstract definition of a stream.

Extensis