#include <dali/internal/adaptor-framework/common/file-stream-impl.h>
// EXTERNAL INCLUDES
-#include <string>
+#include <cstring>
#include <fstream>
#include <dali/integration-api/debug.h>
return mBufferStream;
}
- std::ios_base::openmode openMode = std::ios::ate;
- if( mMode & Dali::FileStream::BINARY )
+ int openMode = 0;
+
+ if( mMode & Dali::FileStream::APPEND )
{
- openMode |= std::ios::binary;
+ openMode |= ( std::ios::out | std::ios::app );
}
-
- if( mMode & Dali::FileStream::WRITE )
+ else if( mMode & Dali::FileStream::WRITE )
{
- openMode |= std::ios::out;
+ openMode |= ( std::ios::out | std::ios::ate );
}
- else
+
+ if( mMode & Dali::FileStream::READ )
{
openMode |= std::ios::in;
}
+ if( mMode & Dali::FileStream::BINARY )
+ {
+ openMode |= std::ios::binary;
+ }
+
if( !mFileName.empty() )
{
- mFileStream.open( mFileName, openMode );
+ mFileStream.open( mFileName, static_cast<std::ios_base::openmode>( openMode ) );
if( !mFileStream.is_open() )
{
- DALI_LOG_WARNING( "stream open failed for: \"%s\", in mode: \"%d\".\n", mFileName, static_cast<int>( openMode ) );
+ DALI_LOG_WARNING( "stream open failed for: \"%s\", in mode: \"%d\".\n", mFileName.c_str(), openMode );
}
return mFileStream;
}
if( !mBufferStream.rdbuf()->in_avail() )
{
DALI_LOG_WARNING( "File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%d\".\n",
- static_cast<void*>( mBuffer ), static_cast<unsigned>( mDataSize ), static_cast<int>( openMode ) );
+ static_cast<void*>( mBuffer ), static_cast<unsigned>( mDataSize ), openMode );
}
}
char openMode[16] = { 0 };
int i = 0;
- if( mMode & Dali::FileStream::WRITE )
+ if( mMode & Dali::FileStream::APPEND )
+ {
+ openMode[i++] = 'a';
+ }
+ else if( mMode & Dali::FileStream::WRITE )
{
openMode[i++] = 'w';
}
mFile = fopen( mFileName.c_str(), openMode );
if( !mFile )
{
- DALI_LOG_WARNING( "file open failed for: \"%s\", in mode: \"%s\".\n", mFileName, openMode );
+ char buf[512];
+ DALI_LOG_ERROR( "file open failed for: \"%s\", in mode: \"%s\".\n", mFileName.c_str(), openMode );
+ DALI_LOG_ERROR( "file open failed error : %s\n", strerror_r( errno, buf, 512 ) );
}
}
else if( mBuffer )
mFile = fmemopen( mBuffer, mDataSize, openMode );
if( !mFile )
{
- DALI_LOG_WARNING( "File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%s\".\n",
+ char buf[512];
+ DALI_LOG_ERROR( "File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%s\".\n",
static_cast<void*>( mBuffer ), static_cast<unsigned>( mDataSize ), openMode );
+ DALI_LOG_ERROR( "file open failed error : %s\n", strerror_r( errno, buf, 512 ) );
}
}