Suggested change for pstsdk::file::file

Nov 4, 2011 at 10:42 PM

Hi. I work with psts whose names are represented as wide character strings. When I attempt to open these psts fopen_s in pstsdk::file::file would throw an exception. I needed to modify the code slightly to get it working. I needed to use a version of fopen appropriate for wide characters.

Before:
ln 132: errno_t err = fopen_s(&m_pfile, std::string(filename.begin(), filename.end()).c_str(), mode);

After:
std::string smode(mode);
std::wstring wmode(smode.length(),L' ');
std::copy(smode.begin(), smode.end(), wmode.begin());
errno_t err = 0;
m_pfile = _wfsopen(m_filename.c_str(), wmode.c_str(), _SH_DENYNO);
if(m_pfile == NULL)
    err = -1;