Unicode conversion for volume name in volume copier

We needed to convert the volume name correctly for the volume list
and the progress dialogs when copying to or from a file.  This
shouldn't affect how anything works, but it looks nicer with HFS
volumes that have non-ASCII characters.
This commit is contained in:
Andy McFadden 2015-01-15 10:48:35 -08:00
parent bb24f51ccb
commit 87a7411dda

View File

@ -14,6 +14,7 @@
#include "stdafx.h" #include "stdafx.h"
#include "VolumeCopyDialog.h" #include "VolumeCopyDialog.h"
#include "Main.h" #include "Main.h"
#include "../reformat/Charset.h"
BEGIN_MESSAGE_MAP(VolumeCopyDialog, CDialog) BEGIN_MESSAGE_MAP(VolumeCopyDialog, CDialog)
@ -324,18 +325,18 @@ void VolumeCopyDialog::LoadList(void)
void VolumeCopyDialog::AddToList(CListCtrl* pListView, DiskImg* pDiskImg, void VolumeCopyDialog::AddToList(CListCtrl* pListView, DiskImg* pDiskImg,
DiskFS* pDiskFS, int* pIndex) DiskFS* pDiskFS, int* pIndex)
{ {
CString volName, format, sizeStr, blocksStr; CString sizeStr, blocksStr;
long numBlocks;
assert(pListView != NULL); assert(pListView != NULL);
assert(pDiskImg != NULL); assert(pDiskImg != NULL);
assert(pDiskFS != NULL); assert(pDiskFS != NULL);
assert(pIndex != NULL); assert(pIndex != NULL);
numBlocks = pDiskImg->GetNumBlocks(); long numBlocks = pDiskImg->GetNumBlocks();
volName = pDiskFS->GetVolumeName(); CStringA volNameA = pDiskFS->GetVolumeName();
format = DiskImg::ToString(pDiskImg->GetFSFormat()); CString volName(Charset::ConvertMORToUNI(volNameA));
CString format = DiskImg::ToString(pDiskImg->GetFSFormat());
blocksStr.Format(L"%ld", pDiskImg->GetNumBlocks()); blocksStr.Format(L"%ld", pDiskImg->GetNumBlocks());
if (numBlocks > 1024*1024*2) if (numBlocks > 1024*1024*2)
sizeStr.Format(L"%.2fGB", (double) numBlocks / (1024.0*1024.0*2.0)); sizeStr.Format(L"%.2fGB", (double) numBlocks / (1024.0*1024.0*2.0));
@ -390,7 +391,7 @@ void VolumeCopyDialog::OnCopyToFile(void)
DiskFS* pSrcFS = NULL; DiskFS* pSrcFS = NULL;
DiskImg dstImg; DiskImg dstImg;
DIError dierr; DIError dierr;
CString errMsg, saveName, msg, srcName; CString errMsg, saveName, msg;
int result; int result;
result = GetSelectedDisk(&pSrcImg, &pSrcFS); result = GetSelectedDisk(&pSrcImg, &pSrcFS);
@ -399,7 +400,8 @@ void VolumeCopyDialog::OnCopyToFile(void)
assert(pSrcImg != NULL); assert(pSrcImg != NULL);
assert(pSrcFS != NULL); assert(pSrcFS != NULL);
srcName = pSrcFS->GetVolumeName(); CStringA srcNameA = pSrcFS->GetVolumeName();
CString srcName(Charset::ConvertMORToUNI(srcNameA));
/* force the format to be generic ProDOS-ordered blocks */ /* force the format to be generic ProDOS-ordered blocks */
originalFormat = pSrcImg->GetFSFormat(); originalFormat = pSrcImg->GetFSFormat();
@ -564,7 +566,7 @@ void VolumeCopyDialog::OnCopyFromFile(void)
MainWindow* pMain = (MainWindow*)::AfxGetMainWnd(); MainWindow* pMain = (MainWindow*)::AfxGetMainWnd();
//DiskImg::FSFormat originalFormat = DiskImg::kFormatUnknown; //DiskImg::FSFormat originalFormat = DiskImg::kFormatUnknown;
CString openFilters; CString openFilters;
CString loadName, targetName, errMsg, warning; CString loadName, errMsg, warning;
DiskImg* pDstImg = NULL; DiskImg* pDstImg = NULL;
DiskFS* pDstFS = NULL; DiskFS* pDstFS = NULL;
DiskImg srcImg; DiskImg srcImg;
@ -584,10 +586,8 @@ void VolumeCopyDialog::OnCopyFromFile(void)
if (!result) if (!result)
return; return;
// if (pDstFS == NULL) CStringA targetNameA = pDstFS->GetVolumeName();
// targetName = "the target volume"; CString targetName(Charset::ConvertMORToUNI(targetNameA));
// else
targetName = pDstFS->GetVolumeName();
/* /*