Beispiel #1
0
std::ostream& operator << (std::ostream &stream, const std::wstring &str)
{
#ifdef WIN32
    if ((stream == std::cout) || (stream == std::cerr) || 
            (stream == std::clog))
        stream << toOem(str);
    else
#endif
    stream << toMbcs(str);
    return stream;
}
Beispiel #2
0
void ResourceCompressor::readData(const std::wstring &fileName)
{
    std::ifstream ifs(toMbcs(fileName).c_str(), 
            std::ios::in | std::ios::binary);
    if (ifs.fail())
        throw Exception(L"Error opening file '" + fileName + L"'");

    ifs.seekg(0, std::ios::end);
    int realSize = ifs.tellg();
    unpackedBuffer.setSize(realSize);
    ifs.seekg(0, std::ios::beg);
    if (realSize <= 0)
        throw Exception(L"File '" + fileName + L"' has invalid size");
    
    ifs.read((char*)unpackedBuffer.getData(), realSize);
    if (ifs.fail() || (ifs.gcount() != realSize))
        throw Exception(L"Error reading from file '" + fileName + L"'");
    ifs.close();

}