From: <man...@us...> - 2013-11-14 21:46:02
|
Revision: 3223 http://sourceforge.net/p/modplug/code/3223 Author: manxorist Date: 2013-11-14 21:45:54 +0000 (Thu, 14 Nov 2013) Log Message: ----------- [Ref] Convert unarchiver to unicode. Modified Paths: -------------- trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/unarchiver/archive.h trunk/OpenMPT/unarchiver/unarchiver.cpp trunk/OpenMPT/unarchiver/unarchiver.h trunk/OpenMPT/unarchiver/unlha.cpp trunk/OpenMPT/unarchiver/unrar.cpp trunk/OpenMPT/unarchiver/unzip.cpp Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-11-14 20:40:27 UTC (rev 3222) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-11-14 21:45:54 UTC (rev 3223) @@ -744,7 +744,7 @@ // Read archive comment if there is no song comment if(songMessage.empty()) { - songMessage.assign(unarchiver.GetComment()); + songMessage.assign(mpt::ToLocale(unarchiver.GetComment())); } #endif Modified: trunk/OpenMPT/unarchiver/archive.h =================================================================== --- trunk/OpenMPT/unarchiver/archive.h 2013-11-14 20:40:27 UTC (rev 3222) +++ trunk/OpenMPT/unarchiver/archive.h 2013-11-14 21:45:54 UTC (rev 3223) @@ -22,14 +22,14 @@ struct ArchiveFileInfo { - std::string name; + mpt::PathString name; ArchiveFileType type; uint64 size; std::string comment; uint64 cookie1; uint64 cookie2; ArchiveFileInfo() - : name(std::string()) + : name(mpt::PathString()) , type(ArchiveFileInvalid) , size(0) , comment(std::string()) @@ -52,7 +52,7 @@ virtual ~IArchive() {}; public: virtual bool IsArchive() const = 0; - virtual std::string GetComment() const = 0; + virtual std::wstring GetComment() const = 0; virtual bool ExtractFile(std::size_t index) = 0; virtual FileReader GetOutputFile() const = 0; virtual std::size_t size() const = 0; @@ -68,7 +68,7 @@ { protected: FileReader inFile; - std::string comment; + std::wstring comment; std::vector<ArchiveFileInfo> contents; std::vector<char> data; public: @@ -87,7 +87,7 @@ { return !contents.empty(); } - virtual std::string GetComment() const + virtual std::wstring GetComment() const { return comment; } Modified: trunk/OpenMPT/unarchiver/unarchiver.cpp =================================================================== --- trunk/OpenMPT/unarchiver/unarchiver.cpp 2013-11-14 20:40:27 UTC (rev 3222) +++ trunk/OpenMPT/unarchiver/unarchiver.cpp 2013-11-14 21:45:54 UTC (rev 3223) @@ -67,16 +67,16 @@ }; -static inline std::string GetExtension(const std::string &filename) -//----------------------------------------------------------------- +static inline std::wstring GetExtension(const std::wstring &filename) +//------------------------------------------------------------------- { - if(filename.find_last_of(".") != std::string::npos) + if(filename.find_last_of(L".") != std::wstring::npos) { - std::string ext = filename.substr(filename.find_last_of(".") + 1); + std::wstring ext = filename.substr(filename.find_last_of(L".") + 1); std::transform(ext.begin(), ext.end(), ext.begin(), tolower); return ext; } - return std::string(); + return std::wstring(); } @@ -95,7 +95,7 @@ { continue; } - const std::string ext = GetExtension(at(i).name); + const std::string ext = mpt::To(mpt::CharsetUTF8, GetExtension(at(i).name.ToWide())); // Compare with list of preferred extensions if(std::find_if(extensions.begin(), extensions.end(), find_str(ext.c_str())) != extensions.end()) @@ -139,8 +139,8 @@ } -std::string CUnarchiver::GetComment() const -//----------------------------------------- +std::wstring CUnarchiver::GetComment() const +//------------------------------------------ { return impl->GetComment(); } Modified: trunk/OpenMPT/unarchiver/unarchiver.h =================================================================== --- trunk/OpenMPT/unarchiver/unarchiver.h 2013-11-14 20:40:27 UTC (rev 3222) +++ trunk/OpenMPT/unarchiver/unarchiver.h 2013-11-14 21:45:54 UTC (rev 3223) @@ -63,7 +63,7 @@ virtual ~CUnarchiver(); virtual bool IsArchive() const; - virtual std::string GetComment() const; + virtual std::wstring GetComment() const; virtual bool ExtractFile(std::size_t index); virtual FileReader GetOutputFile() const; virtual std::size_t size() const; Modified: trunk/OpenMPT/unarchiver/unlha.cpp =================================================================== --- trunk/OpenMPT/unarchiver/unlha.cpp 2013-11-14 20:40:27 UTC (rev 3222) +++ trunk/OpenMPT/unarchiver/unlha.cpp 2013-11-14 21:45:54 UTC (rev 3223) @@ -53,7 +53,7 @@ for(LHAFileHeader *fileheader = firstfile; fileheader; fileheader = lha_reader_next_file(reader)) { ArchiveFileInfo info; - info.name = fileheader->filename; + info.name = mpt::PathString::FromWide(mpt::ToWide(mpt::CharsetISO8859_1, fileheader->filename)); info.size = fileheader->length; info.type = ArchiveFileNormal; contents.push_back(info); Modified: trunk/OpenMPT/unarchiver/unrar.cpp =================================================================== --- trunk/OpenMPT/unarchiver/unrar.cpp 2013-11-14 20:40:27 UTC (rev 3222) +++ trunk/OpenMPT/unarchiver/unrar.cpp 2013-11-14 21:45:54 UTC (rev 3223) @@ -76,7 +76,7 @@ Array<wchar> rarComment; if(rarData->Arc.GetComment(&rarComment)) { - comment = mpt::ToLocale(std::wstring(&rarComment[0], rarComment.Size())); + comment = std::wstring(&rarComment[0], rarComment.Size()); } // Scan all files @@ -84,7 +84,7 @@ while(rarData->Arc.SearchBlock(HEAD_FILE) > 0) { ArchiveFileInfo fileInfo; - fileInfo.name = mpt::ToLocale(std::wstring(rarData->Arc.FileHead.FileName)); + fileInfo.name = mpt::PathString::FromWide(std::wstring(rarData->Arc.FileHead.FileName)); fileInfo.type = ArchiveFileNormal; fileInfo.size = rarData->Arc.FileHead.UnpSize; contents.push_back(fileInfo); Modified: trunk/OpenMPT/unarchiver/unzip.cpp =================================================================== --- trunk/OpenMPT/unarchiver/unzip.cpp 2013-11-14 20:40:27 UTC (rev 3222) +++ trunk/OpenMPT/unarchiver/unzip.cpp 2013-11-14 21:45:54 UTC (rev 3223) @@ -133,7 +133,7 @@ if(unzGetGlobalComment(zipFile, &commentData[0], info.size_comment) >= 0) { commentData[info.size_comment - 1] = '\0'; - comment = &commentData[0]; + comment = mpt::ToWide(mpt::CharsetCP437, &commentData[0]); } } } @@ -154,7 +154,7 @@ char name[256]; unzGetCurrentFileInfo(zipFile, &info, name, sizeof(name), nullptr, 0, nullptr, 0); - fileinfo.name = name; + fileinfo.name = mpt::PathString::FromWide(mpt::ToWide(mpt::CharsetCP437, std::string(name))); fileinfo.size = info.uncompressed_size; unzGetFilePos(zipFile, &bestFile); @@ -246,7 +246,7 @@ if(mz_zip_reader_file_stat(zip, i, &stat)) { info.type = ArchiveFileNormal; - info.name = stat.m_filename; + info.name = mpt::PathString::FromWide(mpt::ToWide(mpt::CharsetCP437, stat.m_filename)); info.size = stat.m_uncomp_size; } if(mz_zip_reader_is_file_a_directory(zip, i)) @@ -308,7 +308,7 @@ { return false; } - comment = std::string(stat.m_comment, stat.m_comment + stat.m_comment_size); + comment = mpt::ToWide(mpt::CharsetCP437, std::string(stat.m_comment, stat.m_comment + stat.m_comment_size)); return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |