#include "main.h"
#include "support.h"
LT_USE_NAMESPACE(LizardTech);
{
public:
MyStream() :
m_file(nullptr)
{
}
~MyStream()
{
}
{
m_file = fp;
}
{
return feof(m_file) != 0;
}
{
return (m_file != nullptr);
}
{
}
{
}
{
}
{
}
{
int stdOrigin;
switch (origin)
{
stdOrigin = SEEK_SET;
break;
stdOrigin = SEEK_CUR;
break;
stdOrigin = SEEK_END;
break;
default:
}
if (offset > LT_LONG_MAX || offset < LT_LONG_MIN)
if(::fseek(m_file, (long)offset, stdOrigin) == 0)
else
}
{
return ftell(m_file);
}
{
return nullptr;
}
{
if(ferror(m_file))
else
}
const char*
getID()
const
{
return "my_stdio_stream:";
}
private:
FILE* m_file;
};
{
#if defined(LT_OS_WIN32) || defined(LT_OS_WIN64)
#else
#endif
{
FILE* inFP = fopen(INPUT_PATH("meg.hdr"), "rb");
MyStream inStream;
TEST_SUCCESS(inStream.initialize(inFP));
TEST_SUCCESS(inStream.open());
TEST_BOOL(inStream.read(buf, len) == len);
inStream.close();
fclose(inFP);
}
{
FILE* outFP = fopen(OUTPUT_PATH("foo"), "wb");
MyStream outStream;
TEST_SUCCESS(outStream.initialize(outFP));
TEST_SUCCESS(outStream.open());
TEST_BOOL(outStream.write(buf, len) == len);
outStream.close();
fclose(outFP);
}
delete [] buf;
TEST_BOOL(Compare(OUTPUT_PATH("foo"), INPUT_PATH("meg.hdr")));
Remove(OUTPUT_PATH("foo"));
}
Include file for all LizardTech sources.
LTIOSeekDir
Stream seek directions.
@ LTIO_SEEK_DIR_BEG
Offset from the beginning of the file.
@ LTIO_SEEK_DIR_CUR
Offset from the current read/write position.
@ LTIO_SEEK_DIR_END
Offset from the end of the file (offsets need to be negative to be valid)
lt_uint32 LT_STATUS
An integral status code.
#define LT_STS_Uninit
status code indicating unintialized variable
#define LT_STS_Failure
status code indicating failure
#define LT_STS_Success
status code indicating success
unsigned char lt_uint8
unsigned 8-bit integer
unsigned int lt_uint32
unsigned 32-bit integer
long long int lt_int64
signed 64-bit integer
Abstract definition of a stream.
virtual LT_STATUS getLastError() const =0
Get status code of last error event.
virtual lt_uint32 read(lt_uint8 *pDest, lt_uint32 numBytes)=0
Retrieve the specified number of bytes from the data source and place them in pDest.
virtual LTIOStreamInf * duplicate()=0
Clone the stream.
virtual const char * getID() const =0
Get a URI describing the stream object.
virtual lt_uint32 write(const lt_uint8 *pSrc, lt_uint32 numBytes)=0
Store the specified number of bytes in the data source.
virtual bool isEOF()=0
Test for end-of-stream.
virtual bool isOpen()=0
Test for stream openness.
virtual LT_STATUS seek(lt_int64 offset, LTIOSeekDir origin)=0
Moves the data access position to origin + offset.
virtual lt_int64 tell()=0
Returns the current data access position as an offset from the start of the data.
virtual LT_STATUS open()=0
Opens the stream.
virtual LT_STATUS close()=0
Closes the stream.