sort list of files by file name

This commit is contained in:
Chris Danford
2005-10-23 18:02:32 +00:00
parent eb2efd6d52
commit 59602f6f6e
+22 -11
View File
@@ -10,6 +10,7 @@
#include "ShowComment.h" #include "ShowComment.h"
#include "IniFile.h" #include "IniFile.h"
#include "UninstallOld.h" #include "UninstallOld.h"
#include <algorithm>
#ifdef _DEBUG #ifdef _DEBUG
#define new DEBUG_NEW #define new DEBUG_NEW
@@ -55,6 +56,11 @@ END_MESSAGE_MAP()
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// CSMPackageInstallDlg message handlers // CSMPackageInstallDlg message handlers
static bool CompareStringNoCase( const CString &s1, const CString &s2 )
{
return s1.CompareNoCase( s2 ) < 0;
}
BOOL CSMPackageInstallDlg::OnInitDialog() BOOL CSMPackageInstallDlg::OnInitDialog()
{ {
CDialog::OnInitDialog(); CDialog::OnInitDialog();
@@ -86,7 +92,6 @@ BOOL CSMPackageInstallDlg::OnInitDialog()
// //
// Set the text of the second Edit box // Set the text of the second Edit box
// //
CString sMessage2;
try try
{ {
m_zip.Open( m_sPackagePath, CZipArchive::zipOpenReadOnly ); m_zip.Open( m_sPackagePath, CZipArchive::zipOpenReadOnly );
@@ -98,20 +103,26 @@ BOOL CSMPackageInstallDlg::OnInitDialog()
exit( 1 ); exit( 1 );
} }
for( i=0; i<m_zip.GetCount(); i++ )
{ {
CZipFileHeader fh; vector<CString> vs;
m_zip.GetFileInfo(fh, (WORD)i); for( i=0; i<m_zip.GetCount(); i++ )
{
CZipFileHeader fh;
m_zip.GetFileInfo(fh, (WORD)i);
if( fh.IsDirectory() ) if( fh.IsDirectory() )
continue; continue;
if( !fh.GetFileName().CompareNoCase( "smzip.ctl" ) ) if( !fh.GetFileName().CompareNoCase( "smzip.ctl" ) )
continue; continue;
vs.push_back( fh.GetFileName() );
}
sMessage2 += ssprintf( "\t%s\r\n", fh.GetFileName() ); sort( vs.begin(), vs.end(), CompareStringNoCase );
CEdit* pEdit2 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE2);
CString sText = "\t" + join( "\r\n\t", vs );
pEdit2->SetWindowText( sText );
} }
CEdit* pEdit2 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE2);
pEdit2->SetWindowText( sMessage2 );
// //