|
|
|
@ -37,14 +37,13 @@ namespace nv
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/// Ctor.
|
|
|
|
|
StdStream( FILE * fp, bool autoclose=true ) :
|
|
|
|
|
m_fp(fp), m_autoclose(autoclose) { }
|
|
|
|
|
StdStream( FILE * fp, bool autoclose=true ) : m_fp(fp), m_autoclose(autoclose) { }
|
|
|
|
|
|
|
|
|
|
/// Dtor.
|
|
|
|
|
virtual ~StdStream()
|
|
|
|
|
{
|
|
|
|
|
if( m_fp != NULL && m_autoclose ) {
|
|
|
|
|
fclose( m_fp );
|
|
|
|
|
_fclose_nolock( m_fp );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -55,22 +54,22 @@ namespace nv
|
|
|
|
|
{
|
|
|
|
|
nvDebugCheck(m_fp != NULL);
|
|
|
|
|
nvDebugCheck(pos < size());
|
|
|
|
|
fseek(m_fp, pos, SEEK_SET);
|
|
|
|
|
_fseek_nolock(m_fp, pos, SEEK_SET);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual uint tell() const
|
|
|
|
|
{
|
|
|
|
|
nvDebugCheck(m_fp != NULL);
|
|
|
|
|
return ftell(m_fp);
|
|
|
|
|
return _ftell_nolock(m_fp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual uint size() const
|
|
|
|
|
{
|
|
|
|
|
nvDebugCheck(m_fp != NULL);
|
|
|
|
|
uint pos = ftell(m_fp);
|
|
|
|
|
fseek(m_fp, 0, SEEK_END);
|
|
|
|
|
_fseek_nolock(m_fp, 0, SEEK_END);
|
|
|
|
|
uint end = ftell(m_fp);
|
|
|
|
|
fseek(m_fp, pos, SEEK_SET);
|
|
|
|
|
_fseek_nolock(m_fp, pos, SEEK_SET);
|
|
|
|
|
return end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -110,8 +109,7 @@ namespace nv
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/// Construct stream by file name.
|
|
|
|
|
StdOutputStream( const char * name ) :
|
|
|
|
|
StdStream(fileOpen(name, "wb")) { }
|
|
|
|
|
StdOutputStream( const char * name ) : StdStream(fileOpen(name, "wb")) { }
|
|
|
|
|
|
|
|
|
|
/// Construct stream by file handle.
|
|
|
|
|
StdOutputStream( FILE * fp, bool autoclose=true ) : StdStream(fp, autoclose)
|
|
|
|
@ -125,7 +123,7 @@ namespace nv
|
|
|
|
|
{
|
|
|
|
|
nvDebugCheck(data != NULL);
|
|
|
|
|
nvDebugCheck(m_fp != NULL);
|
|
|
|
|
return (uint)fwrite(data, 1, len, m_fp);
|
|
|
|
|
return (uint)_fwrite_nolock(data, 1, len, m_fp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual bool isLoading() const
|
|
|
|
@ -149,8 +147,7 @@ namespace nv
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/// Construct stream by file name.
|
|
|
|
|
StdInputStream( const char * name ) :
|
|
|
|
|
StdStream(fileOpen(name, "rb")) { }
|
|
|
|
|
StdInputStream( const char * name ) : StdStream(fileOpen(name, "rb")) { }
|
|
|
|
|
|
|
|
|
|
/// Construct stream by file handle.
|
|
|
|
|
StdInputStream( FILE * fp, bool autoclose=true ) : StdStream(fp, autoclose)
|
|
|
|
@ -164,7 +161,7 @@ namespace nv
|
|
|
|
|
{
|
|
|
|
|
nvDebugCheck(data != NULL);
|
|
|
|
|
nvDebugCheck(m_fp != NULL);
|
|
|
|
|
return (uint)fread(data, 1, len, m_fp);
|
|
|
|
|
return (uint)_fread_nolock(data, 1, len, m_fp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual bool isLoading() const
|
|
|
|
@ -188,8 +185,7 @@ namespace nv
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
/// Ctor.
|
|
|
|
|
MemoryInputStream( const uint8 * mem, uint size ) :
|
|
|
|
|
m_mem(mem), m_ptr(mem), m_size(size) { }
|
|
|
|
|
MemoryInputStream( const uint8 * mem, uint size ) : m_mem(mem), m_ptr(mem), m_size(size) { }
|
|
|
|
|
|
|
|
|
|
/** @name Stream implementation. */
|
|
|
|
|
//@{
|
|
|
|
|