MrSID Decode SDK for Raster Reference Manual  9.0.0.3864
lt_ioFileStream.h
Go to the documentation of this file.
00001 /* $Id$ */
00002 /* //////////////////////////////////////////////////////////////////////////
00003 //                                                                         //
00004 // This code is Copyright (c) 2004 LizardTech, Inc, 1008 Western Avenue,   //
00005 // Suite 200, Seattle, WA 98104.  Unauthorized use or distribution         //
00006 // prohibited.  Access to and use of this code is permitted only under     //
00007 // license from LizardTech, Inc.  Portions of the code are protected by    //
00008 // US and foreign patents and other filings. All Rights Reserved.          //
00009 //                                                                         //
00011 /* PUBLIC */
00012 
00013 #ifndef LT_IO_FILE_STREAM_H
00014 #define LT_IO_FILE_STREAM_H
00015 
00016 #include "lt_ioStreamInf.h"
00017 #include "lt_fileSpec.h"
00018 #include <stdio.h>
00019 
00020 #ifdef __ANDROID__
00021    #define USE_UNBUFFERED_READER
00022 #endif
00023 
00024 LT_BEGIN_NAMESPACE( LizardTech )
00025 
00026 
00027 
00033 class LTIOFileStream : public LTIOStreamInf
00034 {
00035 public:
00036 
00041 
00045    LTIOFileStream(void);
00046 
00050    virtual ~LTIOFileStream(void);
00051 
00058    virtual LT_STATUS initialize(const LTFileSpec& fs, const char* mode);
00059    LT_STATUS initialize(const char* path, const char* mode);
00061 
00062    // LTIOStreamInf overrides
00063    virtual bool isEOF();
00064    virtual bool isOpen();
00065    virtual LT_STATUS open();
00066    virtual LT_STATUS close();
00067    virtual lt_uint32 read(lt_uint8 *pDest, lt_uint32 numBytes);
00068    virtual lt_uint32 write(const lt_uint8 *pSrc, lt_uint32 numBytes);
00069    virtual LT_STATUS seek(lt_int64 offset, LTIOSeekDir origin);
00070    virtual lt_int64 tell();
00071    virtual LTIOStreamInf *duplicate();
00072    virtual LT_STATUS getLastError() const;
00073    virtual const char* getID() const;
00074 
00082    int stdio_ferror();
00083 
00087    void stdio_clearerr();
00089 
00100    int stdio_setvbuf( lt_uint8* buf, lt_uint32 mode, lt_uint32 size  );
00101 
00102 private:
00103 
00104    void cleanup();
00105 
00106 protected:
00107 
00108 #ifdef USE_UNBUFFERED_READER
00109    int m_fd;
00110 #else
00111    FILE* m_file;
00112 #endif
00113    
00114    enum
00115    {
00116       unknown_state = 1,
00117       reading_state = 2,
00118       writing_state = 3
00119    } m_state;
00120 
00121    LTFileSpec m_path;
00122    char *m_mode;
00123    char *m_uri;
00124 };
00125 
00126 LT_END_NAMESPACE( LizardTech )
00127 
00128 #endif   // LT_STREAMINF_H