From: <man...@us...> - 2013-11-10 10:04:30
|
Revision: 3165 http://sourceforge.net/p/modplug/code/3165 Author: manxorist Date: 2013-11-10 10:04:22 +0000 (Sun, 10 Nov 2013) Log Message: ----------- [Ref] Convert internal itp instrument paths to mpt::PathString. The file format is untouched for now and continues to store locale encoded paths. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/view_com.cpp trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/SampleFormats.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-11-10 02:51:11 UTC (rev 3164) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-11-10 10:04:22 UTC (rev 3165) @@ -1424,7 +1424,7 @@ m_modDoc.UpdateAllViews(NULL, HINT_SAMPLEINFO | HINT_MODTYPE, NULL); // -> CODE#0023 // -> DESC="IT project files (.itp)" - m_sndFile.m_szInstrumentPath[m_nInstrument - 1] = fileName.ToLocale(); + m_sndFile.m_szInstrumentPath[m_nInstrument - 1] = fileName; SetInstrumentModified(false); // -! NEW_FEATURE#0023 bOk = TRUE; @@ -1761,7 +1761,7 @@ // -> CODE#0023 // -> DESC="IT project files (.itp)" - m_sndFile.m_szInstrumentPath[m_nInstrument - 1] = dlg.GetFirstFile().ToLocale(); + m_sndFile.m_szInstrumentPath[m_nInstrument - 1] = dlg.GetFirstFile(); SetInstrumentModified(false); // -! NEW_FEATURE#0023 Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-10 02:51:11 UTC (rev 3164) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-11-10 10:04:22 UTC (rev 3165) @@ -506,19 +506,19 @@ instr--; if(!m_SndFile.m_szInstrumentPath[instr].empty()) { - const size_t len = m_SndFile.m_szInstrumentPath[instr].length(); - const bool iti = !_stricmp(&m_SndFile.m_szInstrumentPath[instr][len - 3], "iti"); - const bool xi = !_stricmp(&m_SndFile.m_szInstrumentPath[instr][len - 2], "xi"); + const mpt::PathString dotExt = m_SndFile.m_szInstrumentPath[instr].GetFileExt(); + const bool iti = !mpt::PathString::CompareNoCase(dotExt, MPT_PATHSTRING(".iti")); + const bool xi = !mpt::PathString::CompareNoCase(dotExt, MPT_PATHSTRING(".xi")); if(iti || (!xi && m_SndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT))) - success = m_SndFile.SaveITIInstrument(instr + 1, mpt::PathString::FromLocale(m_SndFile.m_szInstrumentPath[instr]), false); + success = m_SndFile.SaveITIInstrument(instr + 1, m_SndFile.m_szInstrumentPath[instr], false); else - success = m_SndFile.SaveXIInstrument(instr + 1, mpt::PathString::FromLocale(m_SndFile.m_szInstrumentPath[instr])); + success = m_SndFile.SaveXIInstrument(instr + 1, m_SndFile.m_szInstrumentPath[instr]); if(success) m_bsInstrumentModified.reset(instr); else - Reporting::Error(("Error while saving\n" + m_SndFile.m_szInstrumentPath[instr] + "!").c_str()); + Reporting::Error(("Error while saving\n" + m_SndFile.m_szInstrumentPath[instr].ToLocale() + "!").c_str()); } } return success; Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-10 02:51:11 UTC (rev 3164) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-11-10 10:04:22 UTC (rev 3165) @@ -3089,7 +3089,7 @@ .ExtensionFilter("All files(*.*)|*.*||"); if(!dlg.Show()) return; - pSndFile->m_szInstrumentPath[modItem.val1 - 1] = dlg.GetFirstFile().ToLocale(); + pSndFile->m_szInstrumentPath[modItem.val1 - 1] = dlg.GetFirstFile(); OnRefreshTree(); } } @@ -3117,7 +3117,7 @@ "FastTracker II Instruments (*.xi)|*.xi||"); if(!dlg.Show()) return; - pSndFile->m_szInstrumentPath[modItem.val1 - 1] = dlg.GetFirstFile().ToLocale(); + pSndFile->m_szInstrumentPath[modItem.val1 - 1] = dlg.GetFirstFile(); } pModDoc->SaveInstrument(static_cast<INSTRUMENTINDEX>(modItem.val1)); Modified: trunk/OpenMPT/mptrack/view_com.cpp =================================================================== --- trunk/OpenMPT/mptrack/view_com.cpp 2013-11-10 02:51:11 UTC (rev 3164) +++ trunk/OpenMPT/mptrack/view_com.cpp 2013-11-10 10:04:22 UTC (rev 3165) @@ -428,7 +428,7 @@ case INSLIST_PATH: if (pIns) { - strncpy(s, pSndFile->m_szInstrumentPath[iIns].c_str(), _MAX_PATH); + strncpy(s, pSndFile->m_szInstrumentPath[iIns].ToLocale().c_str(), _MAX_PATH); s[_MAX_PATH] = 0; } break; Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2013-11-10 02:51:11 UTC (rev 3164) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2013-11-10 10:04:22 UTC (rev 3165) @@ -132,9 +132,9 @@ size = file.ReadUint32LE(); // path string length for(INSTRUMENTINDEX ins = 0; ins < GetNumInstruments(); ins++) { - char path[_MAX_PATH]; + std::string path; file.ReadString<mpt::String::maybeNullTerminated>(path, size); - m_szInstrumentPath[ins] = path; + m_szInstrumentPath[ins] = mpt::PathString::FromLocale(path); } // Song Orders @@ -223,7 +223,7 @@ CMappedFile f; for(INSTRUMENTINDEX ins = 0; ins < GetNumInstruments(); ins++) { - if(m_szInstrumentPath[ins].empty() || !f.Open(mpt::PathString::FromLocale(m_szInstrumentPath[ins]))) continue; + if(m_szInstrumentPath[ins].empty() || !f.Open(m_szInstrumentPath[ins])) continue; FileReader file = f.GetFile(); if(file.IsValid()) @@ -399,7 +399,7 @@ { char path[_MAX_PATH]; MemsetZero(path); - strncpy(path, m_szInstrumentPath[i].c_str(), _MAX_PATH); + strncpy(path, m_szInstrumentPath[i].ToLocale().c_str(), _MAX_PATH); fwrite(path, 1, _MAX_PATH, f); } Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp =================================================================== --- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-11-10 02:51:11 UTC (rev 3164) +++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-11-10 10:04:22 UTC (rev 3165) @@ -181,7 +181,7 @@ #ifdef MODPLUG_TRACKER // -> CODE#0023 // -> DESC="IT project files (.itp)" - m_szInstrumentPath[nInstr - 1].clear(); + m_szInstrumentPath[nInstr - 1] = mpt::PathString(); if(GetpModDoc()) { GetpModDoc()->m_bsInstrumentModified.reset(nInstr - 1); Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-11-10 02:51:11 UTC (rev 3164) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-11-10 10:04:22 UTC (rev 3165) @@ -406,7 +406,7 @@ #ifdef MODPLUG_TRACKER // -> CODE#0023 // -> DESC="IT project files (.itp)" - std::string m_szInstrumentPath[MAX_INSTRUMENTS]; + mpt::PathString m_szInstrumentPath[MAX_INSTRUMENTS]; // -! NEW_FEATURE#0023 #endif // MODPLUG_TRACKER This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |