Tired of fighting with MFC; switch arrays to vector.

Update IniFile and some of RageUitl.  Can't do everything, since it's
still using MFC CString.
This commit is contained in:
Glenn Maynard
2003-07-23 00:47:23 +00:00
parent 212af912f1
commit 33a835ff31
12 changed files with 372 additions and 396 deletions
+3 -5
View File
@@ -55,7 +55,7 @@ BOOL EditInsallations::OnInitDialog()
CStringArray asInstallDirs;
GetStepManiaInstallDirs( asInstallDirs );
for( int i=0; i<asInstallDirs.GetSize(); i++ )
for( unsigned i=0; i<asInstallDirs.size(); i++ )
m_list.AddString( asInstallDirs[i] );
@@ -114,15 +114,13 @@ void EditInsallations::OnButtonAdd()
void EditInsallations::OnOK()
{
// TODO: Add extra validation here
m_asReturnedInstallDirs.RemoveAll();
m_asReturnedInstallDirs.clear();
for( int i=0; i<m_list.GetCount(); i++ )
{
CString sDir;
m_list.GetText( i, sDir );
m_asReturnedInstallDirs.Add( sDir );
m_asReturnedInstallDirs.push_back( sDir );
}
CDialog::OnOK();
+23 -13
View File
@@ -93,33 +93,35 @@ void EditMetricsDlg::RefreshTree()
iniCombined.ReadFile();
CStringArray asKeys;
asKeys.Copy( iniCombined.names );
IniFile::const_iterator it;
for( it = iniCombined.begin(); it != iniCombined.end(); ++it )
asKeys.push_back( it->first );
SortCStringArray( asKeys );
for( int i=0; i<asKeys.GetSize(); i++ )
for( unsigned i=0; i<asKeys.size(); i++ )
{
CString sKey = asKeys[i];
bool bInBase = iniBase.FindKey(sKey) != -1;
bool bInTheme = iniTheme.FindKey(sKey) != -1;
bool bInBase = iniBase.GetKey(sKey) != NULL;
bool bInTheme = iniTheme.GetKey(sKey) != NULL;
HTREEITEM item1 = m_tree.InsertItem( sKey );
SET_ITEM_STYLE( item1, bInBase, bInTheme );
IniFile::key* pKey = iniCombined.GetKeyPointer( sKey );
const IniFile::key* pKey = iniCombined.GetKey( sKey );
CStringArray asNames;
for( POSITION pos=pKey->GetStartPosition(); pos != NULL; )
for( IniFile::key::const_iterator val = pKey->begin(); val != pKey->end(); ++val )
{
CString sName, sValue;
pKey->GetNextAssoc( pos, sName, sValue );
asNames.Add( sName );
CString sName = val->first, sValue = val->second;
asNames.push_back( sName );
}
SortCStringArray( asNames );
for( int j=0; j<asNames.GetSize(); j++ )
for( unsigned j=0; j<asNames.size(); j++ )
{
CString sName = asNames[j];
CString sValue = iniCombined.GetValue( sKey, sName );
CString sValue;
iniCombined.GetValue( sKey, sName, sValue );
CString sThrowAway;
bool bInBase = !!iniBase.GetValue( sKey, sName, sThrowAway );
@@ -176,8 +178,16 @@ void EditMetricsDlg::OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult)
m_buttonOverride.EnableWindow( bInBase && !bInTheme );
m_buttonRemove.EnableWindow( bInTheme );
m_editValue.EnableWindow( bInTheme );
m_editValue.SetWindowText( bInTheme ? iniTheme.GetValue(sKey,sName) : "" );
m_editDefault.SetWindowText( bInBase ? iniBase.GetValue(sKey,sName) : "" );
if( bInTheme )
{
CString n;
iniTheme.GetValue(sKey,sName, n);
m_editValue.SetWindowText( n );
m_editDefault.SetWindowText( n );
} else {
m_editValue.SetWindowText( "" );
m_editDefault.SetWindowText( "" );
}
*pResult = 0;
}
+184 -199
View File
@@ -13,15 +13,6 @@
#include "RageUtil.h"
/////////////////////////////////////////////////////////////////////
// Construction/Destruction
/////////////////////////////////////////////////////////////////////
//default constructor
IniFile::IniFile()
{
}
//constructor, can specify pathname here instead of using SetPath later
IniFile::IniFile(CString inipath)
{
@@ -34,269 +25,263 @@ IniFile::~IniFile()
}
/////////////////////////////////////////////////////////////////////
// Public Functions
/////////////////////////////////////////////////////////////////////
//sets path of ini file to read and write from
// sets path of ini file to read and write from
void IniFile::SetPath(CString newpath)
{
path = newpath;
}
//reads ini file specified using IniFile::SetPath()
//returns true if successful, false otherwise
BOOL IniFile::ReadFile()
// reads ini file specified using IniFile::SetPath()
// returns true if successful, false otherwise
bool IniFile::ReadFile()
{
CStdioFile file;
if( !file.Open(path, CFile::modeRead) )
FILE *f = fopen(path, "r");
if (f == NULL)
{
error = "Unable to open ini file.";
return FALSE;
error = ssprintf("Unable to open ini file: %s", strerror(errno));
return 0;
}
CString line;
int curkey = -1, curval = -1;
CString keyname, valuename, value;
while( file.ReadString(line) )
CString keyname;
char buf[10240];
while (fgets(buf, sizeof(buf), f))
{
if( line != "" )
buf[sizeof(buf)-1]=0;
CString line(buf);
if(line.GetLength() >= 3 &&
line[0] == '\xef' &&
line[1] == '\xbb' &&
line[2] == '\xbf'
)
{
if( line[0] == '[' && line[line.GetLength()-1] == ']' ) //if a section heading
/* Obnoxious NT marker for UTF-8. Remove it. */
line.Delete(0, 3);
}
if (line == "")
continue;
StripCrnl(line);
if ((line.GetLength() >= 2 && line[0] == '/' && line[1] == '/') || line[0] == '#')
continue; /* comment */
if (line[0] == '[' && line[line.GetLength()-1] == ']') //if a section heading
{
keyname = line;
keyname.Delete(0);
keyname.Delete(keyname.GetLength()-1);
}
else //if a value
{
int iEqualIndex = line.Find("=");
if( iEqualIndex != -1 )
{
keyname = line;
keyname.TrimLeft('[');
keyname.TrimRight(']');
}
else //if a value
{
int iIndexOfEqual = line.Find("=");
if( iIndexOfEqual == -1 ) // this is a malformed line
continue;
valuename = line.Left( iIndexOfEqual );
value = line.Right(line.GetLength()-valuename.GetLength()-1);
CString valuename = line.Left(iEqualIndex);
CString value = line.Right(line.GetLength()-valuename.GetLength()-1);
SetValue(keyname,valuename,value);
}
}
}
file.Close();
fclose(f);
return 1;
}
//writes data stored in class to ini file
// writes data stored in class to ini file
void IniFile::WriteFile()
{
CStdioFile file;
if( !file.Open(path, CFile::modeCreate | CFile::modeWrite ) )
{
error = "Unable to open ini for writing.";
FILE* fp = fopen( path, "w" );
if( fp == NULL )
return;
}
// foreach key
for( int keynum = 0; keynum <= names.GetUpperBound(); keynum++ )
for (keymap::const_iterator k = keys.begin(); k != keys.end(); ++k)
{
CString sTemp;
sTemp.Format( "[%s]\n", names[keynum] );
file.WriteString( sTemp );
if (k->second.empty())
continue;
CMapStringToString &map = keys[keynum];
fprintf( fp, "[%s]\n", (const char *) k->first );
CStringArray as;
for (key::const_iterator i = k->second.begin(); i != k->second.end(); ++i)
fprintf( fp, "%s=%s\n", (const char *)i->first, (const char *)i->second );
// for each value_name/value pair
for( POSITION pos = map.GetStartPosition(); pos != NULL; )
{
CString value_name;
CString value;
map.GetNextAssoc( pos, value_name, value );
sTemp.Format( "%s=%s\n", value_name, value );
as.Add( sTemp );
}
SortCStringArray( as );
for( int i=0; i<as.GetSize(); i++ )
file.WriteString( as[i] );
file.WriteString( "\n" );
fprintf( fp, "\n" );
}
file.Close();
fclose( fp );
}
//deletes all stored ini data
// deletes all stored ini data
void IniFile::Reset()
{
keys.SetSize(0);
names.SetSize(0);
keys.clear();
}
//returns number of keys currently in the ini
int IniFile::GetNumKeys()
// returns number of keys currently in the ini
int IniFile::GetNumKeys() const
{
return keys.GetSize();
return keys.size();
}
//returns a pointer to the key for direct modification
CMapStringToString* IniFile::GetKeyPointer( CString keyname )
// returns number of values stored for specified key, or -1 if key not found
int IniFile::GetNumValues(const CString &keyname) const
{
int keynum = FindKey(keyname);
if (keynum == -1)
return NULL;
else
return &keys[keynum];
}
//returns number of values stored for specified key, or -1 if key not found
int IniFile::GetNumValues(CString keyname)
{
int keynum = FindKey(keyname);
if (keynum == -1)
keymap::const_iterator k = keys.find(keyname);
if (k == keys.end())
return -1;
else
return keys[keynum].GetCount();
return k->second.size();
}
//gets value of [keyname] valuename =
//overloaded to return CString, int, and double
BOOL IniFile::GetValue(CString keyname, CString valuename, CString value_out)
// gets value of [keyname] valuename =
bool IniFile::GetValue(const CString &keyname, const CString &valuename, CString& value) const
{
int keynum = FindKey(keyname);//, valuenum = FindValue(keynum,valuename);
if( keynum == -1 )
keymap::const_iterator k = keys.find(keyname);
if (k == keys.end())
{
error = "Unable to locate specified key.";
return FALSE;
return false;
}
CMapStringToString &map = keys[keynum];
if( !map.Lookup(valuename, value_out) )
key::const_iterator i = k->second.find(valuename);
if (i == k->second.end())
{
error = "Unable to locate specified value.";
return FALSE;
}
return TRUE;
}
//gets value of [keyname] valuename =
//overloaded to return CString, int, and double
CString IniFile::GetValue(CString keyname, CString valuename)
{
int keynum = FindKey(keyname);//, valuenum = FindValue(keynum,valuename);
if( keynum == -1 )
{
error = "Unable to locate specified key.";
return "";
return false;
}
CMapStringToString &map = keys[keynum];
CString value;
if( !map.Lookup(valuename, value) )
{
error = "Unable to locate specified value.";
return "";
}
return value;
value = i->second;
return true;
}
//gets value of [keyname] valuename =
//overloaded to return CString, int, and double
int IniFile::GetValueI(CString keyname, CString valuename)
// gets value of [keyname] valuename =
bool IniFile::GetValueI(const CString &keyname, const CString &valuename, int& value) const
{
return atoi( GetValue(keyname,valuename) );
CString sValue;
if( !GetValue(keyname,valuename,sValue) )
return false;
sscanf( sValue, "%d", &value );
return true;
}
//gets value of [keyname] valuename =
//overloaded to return CString, int, and double
double IniFile::GetValueF(CString keyname, CString valuename)
bool IniFile::GetValueU(const CString &keyname, const CString &valuename, unsigned &value) const
{
return atof( GetValue(keyname, valuename) );
CString sValue;
if( !GetValue(keyname,valuename,sValue) )
return false;
sscanf( sValue, "%u", &value );
return true;
}
//sets value of [keyname] valuename =.
//specify the optional paramter as false (0) if you do not want it to create
//the key if it doesn't exist. Returns true if data entered, false otherwise
//overloaded to accept CString, int, and double
BOOL IniFile::SetValue(CString keyname, CString valuename, CString value, BOOL create)
// gets value of [keyname] valuename =
bool IniFile::GetValueF(const CString &keyname, const CString &valuename, float& value) const
{
int keynum = FindKey(keyname);
if( keynum == -1 ) //if key doesn't exist
{
if( !create ) //and user does not want to create it,
return FALSE; //stop entering this key
names.SetSize(names.GetSize()+1);
keys.SetSize(keys.GetSize()+1);
keynum = names.GetSize()-1;
names[keynum] = keyname;
}
// insert value
CMapStringToString &map = keys[keynum];
CString oldvalue;
if( !map.Lookup(valuename, oldvalue) && !create )
return FALSE;
map[valuename] = value;
return TRUE;
CString sValue;
if( !GetValue(keyname,valuename,sValue) )
return false;
sscanf( sValue, "%f", &value );
return true;
}
//sets value of [keyname] valuename =.
//specify the optional paramter as false (0) if you do not want it to create
//the key if it doesn't exist. Returns true if data entered, false otherwise
//overloaded to accept CString, int, and double
BOOL IniFile::SetValueI(CString keyname, CString valuename, int value, BOOL create)
// gets value of [keyname] valuename =
bool IniFile::GetValueB(const CString &keyname, const CString &valuename, bool& value) const
{
CString temp;
temp.Format("%d",value);
return SetValue(keyname, valuename, temp, create);
CString sValue;
if( !GetValue(keyname,valuename,sValue) )
return false;
value = atoi(sValue) != 0;
return true;
}
//sets value of [keyname] valuename =.
//specify the optional paramter as false (0) if you do not want it to create
//the key if it doesn't exist. Returns true if data entered, false otherwise
//overloaded to accept CString, int, and double
BOOL IniFile::SetValueF(CString keyname, CString valuename, double value, BOOL create)
// sets value of [keyname] valuename =.
// specify the optional paramter as false (0) if you do not want it to create
// the key if it doesn't exist. Returns true if data entered, false otherwise
bool IniFile::SetValue(const CString &keyname, const CString &valuename, const CString &value, bool create)
{
CString temp;
temp.Format("%e",value);
return SetValue(keyname, valuename, temp, create);
if (!create && keys.find(keyname) == keys.end()) //if key doesn't exist
return false; // stop entering this key
// find value
if (!create && keys[keyname].find(valuename) == keys[keyname].end())
return false;
keys[keyname][valuename] = value;
return true;
}
//deletes specified value
//returns true if value existed and deleted, false otherwise
BOOL IniFile::DeleteValue(CString keyname, CString valuename)
// sets value of [keyname] valuename =.
// specify the optional paramter as false (0) if you do not want it to create
// the key if it doesn't exist. Returns true if data entered, false otherwise
bool IniFile::SetValueI(const CString &keyname, const CString &valuename, int value, bool create)
{
int keynum = FindKey(keyname);
if( keynum == -1 )
return FALSE;
CMapStringToString &map = keys[keynum];
return map.RemoveKey( valuename );
return SetValue(keyname, valuename, ssprintf("%d",value), create);
}
//deletes specified key and all values contained within
//returns true if key existed and deleted, false otherwise
BOOL IniFile::DeleteKey(CString keyname)
bool IniFile::SetValueU(const CString &keyname, const CString &valuename, unsigned value, bool create)
{
int keynum = FindKey(keyname);
if (keynum == -1)
return 0;
keys.RemoveAt(keynum);
names.RemoveAt(keynum);
return 1;
return SetValue(keyname, valuename, ssprintf("%u",value), create);
}
/////////////////////////////////////////////////////////////////////
// Private Functions
/////////////////////////////////////////////////////////////////////
//returns index of specified key, or -1 if not found
int IniFile::FindKey(CString keyname)
bool IniFile::SetValueF(const CString &keyname, const CString &valuename, float value, bool create)
{
int keynum = 0;
while ( keynum < keys.GetSize() && names[keynum] != keyname)
keynum++;
if (keynum == keys.GetSize())
return -1;
return keynum;
return SetValue(keyname, valuename, ssprintf("%f",value), create);
}
bool IniFile::SetValueB(const CString &keyname, const CString &valuename, bool value, bool create)
{
return SetValue(keyname, valuename, ssprintf("%d",value), create);
}
// deletes specified value
// returns true if value existed and deleted, false otherwise
bool IniFile::DeleteValue(const CString &keyname, const CString &valuename)
{
keymap::iterator k = keys.find(keyname);
if (k == keys.end())
return false;
key::iterator i = k->second.find(valuename);
if(i == k->second.end())
return false;
k->second.erase(i);
return true;
}
// deletes specified key and all values contained within
// returns true if key existed and deleted, false otherwise
bool IniFile::DeleteKey(const CString &keyname)
{
keymap::iterator k = keys.find(keyname);
if (k == keys.end())
return false;
keys.erase(k);
return true;
}
const IniFile::key *IniFile::GetKey(const CString &keyname) const
{
keymap::const_iterator i = keys.find(keyname);
if(i == keys.end()) return NULL;
return &i->second;
}
void IniFile::SetValue(const CString &keyname, const key &key)
{
keys[keyname]=key;
}
void IniFile::RenameKey(const CString &from, const CString &to)
{
if(keys.find(from) == keys.end())
return;
if(keys.find(to) != keys.end())
return;
keys[to] = keys[from];
keys.erase(from);
}
+49 -53
View File
@@ -1,72 +1,59 @@
#ifndef INIFILE_H
#define INIFILE_H
/*
-----------------------------------------------------------------------------
File: IniFile.h
Class: IniFile
Desc: Wrapper for reading and writing an .ini file.
Copyright (c) 2001-2002 by the persons listed below. All rights reserved.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Adam Clauss
Chris Danford
-----------------------------------------------------------------------------
*/
#ifndef _INIFILE_H_
#define _INIFILE_H_
#include <afxtempl.h>
//#include <iostream.h>
#include <map>
using namespace std;
class IniFile
{
//all private variables
public:
// all keys are of this type
typedef map<CString, CString> key;
typedef map<CString, key> keymap;
typedef keymap::const_iterator const_iterator;
const_iterator begin() const { return keys.begin(); }
const_iterator end() const { return keys.end(); }
private:
//stores pathname of ini file to read/write
CString path;
//all keys are of this time
typedef CMapStringToString key;
//list of keys in ini
CArray<key, key> keys;
//corresponding list of keynames
CStringArray names;
// keys in ini
keymap keys;
//all private functions
//private:
//returns index of specified key, or -1 if not found
int FindKey(CString keyname);
//public variables
public:
//will contain error info if one occurs
//ended up not using much, just in ReadFile and GetValue
CString error;
//public functions
public:
//default constructor
IniFile();
mutable CString error;
//constructor, can specify pathname here instead of using SetPath later
IniFile(CString inipath);
IniFile(CString inipath = "");
//default destructor
virtual ~IniFile();
//sets path of ini file to read and write from
void SetPath(CString newpath);
CString GetPath() const { return path; }
//reads ini file specified using IniFile::SetPath()
//returns true if successful, false otherwise
BOOL ReadFile();
bool ReadFile();
//writes data stored in class to ini file
void WriteFile();
@@ -75,38 +62,47 @@ public:
void Reset();
//returns number of keys currently in the ini
int GetNumKeys();
//returns a pointer to the key for direct modification
CMapStringToString* GetKeyPointer( CString keyname );
int GetNumKeys() const;
//returns number of values stored for specified key
int GetNumValues( CString keyname );
int GetNumValues(const CString &keyname) const;
//gets value of [keyname] valuename =
//overloaded to return CString, int, and double,
//returns "", or 0 if key/value not found. Sets error member to show problem
BOOL GetValue(CString keyname, CString valuename, CString value_out);
CString GetValue(CString keyname, CString valuename);
int GetValueI(CString keyname, CString valuename);
double GetValueF(CString keyname, CString valuename);
bool GetValue(const CString &key, const CString &valuename, CString& value) const;
bool GetValueI(const CString &key, const CString &valuename, int& value) const;
bool GetValueU(const CString &key, const CString &valuename, unsigned& value) const;
bool GetValueF(const CString &key, const CString &valuename, float& value) const;
bool GetValueB(const CString &key, const CString &valuename, bool& value) const;
bool GetValue(const CString &key, const CString &valuename, int& value) const { return GetValueI(key, valuename, value); }
bool GetValue(const CString &key, const CString &valuename, float& value) const { return GetValueF(key, valuename, value); }
bool GetValue(const CString &key, const CString &valuename, bool& value) const { return GetValueB(key, valuename, value); }
//sets value of [keyname] valuename =.
//specify the optional paramter as false (0) if you do not want it to create
//the key if it doesn't exist. Returns true if data entered, false otherwise
//overloaded to accept CString, int, and double
BOOL SetValue(CString key, CString valuename, CString value, BOOL create = 1);
BOOL SetValueI(CString key, CString valuename, int value, BOOL create = 1);
BOOL SetValueF(CString key, CString valuename, double value, BOOL create = 1);
bool SetValue(const CString &key, const CString &valuename, const CString &value, bool create = 1);
bool SetValueI(const CString &key, const CString &valuename, int value, bool create = 1);
bool SetValueU(const CString &key, const CString &valuename, unsigned value, bool create = 1);
bool SetValueF(const CString &key, const CString &valuename, float value, bool create = 1);
bool SetValueB(const CString &key, const CString &valuename, bool value, bool create = 1);
bool SetValue(const CString &key, const CString &valuename, int value, bool create = 1) { return SetValueI(key, valuename, value, create); }
//deletes specified value
//returns true if value existed and deleted, false otherwise
BOOL DeleteValue(CString keyname, CString valuename);
bool DeleteValue(const CString &keyname, const CString &valuename);
//deletes specified key and all values contained within
//returns true if key existed and deleted, false otherwise
BOOL DeleteKey(CString keyname);
bool DeleteKey(const CString &keyname);
const key *GetKey(const CString &keyname) const;
void SetValue(const CString &keyname, const key &key);
/* Rename a key. For example, call RenameKey("foo", "main") after
* reading an INI where [foo] is an alias to [main]. If to already
* exists, nothing happens. */
void RenameKey(const CString &from, const CString &to);
};
#endif
+39 -51
View File
@@ -12,6 +12,7 @@
*/
#include "RageUtil.h"
#include <algorithm>
ULONG randseed = time(NULL);
@@ -34,8 +35,8 @@ float TimeToSeconds( CString sHMS )
CStringArray arrayBits;
split( sHMS, ":", arrayBits, false );
while( arrayBits.GetSize() < 3 )
arrayBits.InsertAt( 0, "0" ); // pad missing bits
while( arrayBits.size() < 3 )
arrayBits.insert(arrayBits.begin(), "0" ); // pad missing bits
float fSeconds = 0;
fSeconds += atoi( arrayBits[0] ) * 60 * 60;
@@ -84,22 +85,20 @@ CString vssprintf( LPCTSTR fmt, va_list argList)
//-----------------------------------------------------------------------------
CString join( const CString &Deliminator, const CStringArray& Source)
{
if( Source.GetSize() == 0 )
if( Source.empty() )
return "";
CString csReturn;
CString csTmp;
// Loop through the Array and Append the Deliminator
for( int iNum = 0; iNum < Source.GetSize()-1; iNum++ ) {
csTmp += Source.GetAt(iNum);
for( unsigned iNum = 0; iNum < Source.size()-1; iNum++ ) {
csTmp += Source[iNum];
csTmp += Deliminator;
}
csTmp += Source.GetAt( Source.GetSize()-1 );
csTmp += Source.back();
return csTmp;
}
//-----------------------------------------------------------------------------
// Name: split()
// Desc:
@@ -122,7 +121,7 @@ void split( const CString &Source, const CString &Deliminator, CStringArray& Add
if( newCString.IsEmpty() && bIgnoreEmpty )
; // do nothing
else
AddIt.Add(AddCString);
AddIt.push_back(AddCString);
tmpCString = newCString.Mid(pos + Deliminator.GetLength());
newCString = tmpCString;
@@ -132,10 +131,12 @@ void split( const CString &Source, const CString &Deliminator, CStringArray& Add
if( newCString.IsEmpty() && bIgnoreEmpty )
; // do nothing
else
AddIt.Add(newCString);
AddIt.push_back(newCString);
}
//-----------------------------------------------------------------------------
// Name: splitpath()
// Desc:
@@ -212,49 +213,36 @@ void splitpath( const bool UsingDirsOnly, const CString &Path, CString& Drive, C
//-----------------------------------------------------------------------------
void splitrelpath( const CString &Path, CString& Dir, CString& FName, CString& Ext )
{
// need to split on both forward slashes and back slashes
CStringArray sPathBits;
/* Find the last slash or backslash. */
int Last = max(Path.ReverseFind('/'), Path.ReverseFind('\\'));
CStringArray sBackShashPathBits;
split( Path, "\\", sBackShashPathBits, true );
for( int i=0; i<sBackShashPathBits.GetSize(); i++ ) // foreach backslash bit
{
CStringArray sForwardShashPathBits;
split( sBackShashPathBits[i], "/", sForwardShashPathBits, true );
sPathBits.Append( sForwardShashPathBits );
}
if( sPathBits.GetSize() == 0 )
{
Dir = FName = Ext = "";
return;
}
CString sFNameAndExt = sPathBits[ sPathBits.GetSize()-1 ];
/* Set 'Last' to the first character of the filename. If we have
* no directory separators, this is the entire string, so set it
* to 0. */
if(Last == -1) Last = 0;
else Last++;
CString sFNameAndExt = Path.Right(Path.GetLength()-Last);
// subtract the FNameAndExt from Path
Dir = Path.Left( Path.GetLength()-sFNameAndExt.GetLength() ); // don't subtract out the trailing slash
CStringArray sFNameAndExtBits;
split( sFNameAndExt, ".", sFNameAndExtBits, false );
if( sFNameAndExtBits.GetSize() == 0 ) // no file at the end of this path
if( sFNameAndExt.GetLength() == 0 ) // no file at the end of this path
{
FName = "";
Ext = "";
}
else if( sFNameAndExtBits.GetSize() == 1 ) // file doesn't have extension
else if( sFNameAndExtBits.size() == 1 ) // file doesn't have extension
{
FName = sFNameAndExtBits[0];
Ext = "";
}
else if( sFNameAndExtBits.GetSize() > 1 ) // file has extension and possibly multiple periods
else if( sFNameAndExtBits.size() > 1 ) // file has extension and possibly multiple periods
{
Ext = sFNameAndExtBits[ sFNameAndExtBits.GetSize()-1 ];
Ext = sFNameAndExtBits[ sFNameAndExtBits.size()-1 ];
// subtract the Ext and last period from FNameAndExt
FName = sFNameAndExt.Left( sFNameAndExt.GetLength()-Ext.GetLength()-1 );
@@ -284,9 +272,9 @@ void GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs, bool bRe
continue;
if( bReturnPathToo )
AddTo.Add( sDir + sDirName );
AddTo.push_back( sDir + sDirName );
else
AddTo.Add( sDirName );
AddTo.push_back( sDirName );
} while( ::FindNextFile( hFind, &fd ) );
@@ -460,7 +448,7 @@ int GetHashForDirectory( CString sDir )
CStringArray arrayFiles;
GetDirListing( sDir+"\\*.*", arrayFiles, false );
for( int i=0; i<arrayFiles.GetSize(); i++ )
for( unsigned i=0; i<arrayFiles.size(); i++ )
{
const CString sFilePath = sDir + arrayFiles[i];
hash += GetHashForFile( sFilePath );
@@ -507,27 +495,27 @@ bool IsADirectory( const CString &sPath )
}
int CompareCStringsAsc(const void *arg1, const void *arg2)
bool CompareCStringsAsc(const CString &str1, const CString &str2)
{
CString str1 = *(CString *)arg1;
CString str2 = *(CString *)arg2;
return str1.CompareNoCase( str2 );
return str1.CompareNoCase( str2 ) < 0;
}
int CompareCStringsDesc(const void *arg1, const void *arg2)
bool CompareCStringsDesc(const CString &str1, const CString &str2)
{
CString str1 = *(CString *)arg1;
CString str2 = *(CString *)arg2;
return str2.CompareNoCase( str1 );
return str1.CompareNoCase( str2 ) > 0;
}
void SortCStringArray( CStringArray &arrayCStrings, const bool bSortAcsending )
void SortCStringArray( CStringArray &arrayCStrings, const bool bSortAscending )
{
qsort( arrayCStrings.GetData(), arrayCStrings.GetSize(), sizeof(CString), bSortAcsending ? CompareCStringsAsc : CompareCStringsDesc );
sort( arrayCStrings.begin(), arrayCStrings.end(),
CompareCStringsDesc);
}
void StripCrnl(CString &s)
{
while( s.GetLength() && (s[s.GetLength()-1] == '\r' || s[s.GetLength()-1] == '\n') )
s.Delete(s.GetLength()-1);
}
LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata)
{
+1 -2
View File
@@ -157,9 +157,8 @@ bool IsAFile( const CString &sPath );
bool IsADirectory( const CString &sPath );
DWORD GetFileSizeInBytes( const CString &sFilePath );
int CompareCStringsAsc(const void *arg1, const void *arg2);
int CompareCStringsDesc(const void *arg1, const void *arg2);
void SortCStringArray( CStringArray &AddTo, const bool bSortAcsending = true );
void StripCrnl(CString &s);
LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata);
@@ -260,10 +260,8 @@ void CSMPackageInstallDlg::RefreshInstallationList()
CStringArray asInstallDirs;
GetStepManiaInstallDirs( asInstallDirs );
for( int i=0; i<asInstallDirs.GetSize(); i++ )
{
for( unsigned i=0; i<asInstallDirs.size(); i++ )
m_comboDir.AddString( asInstallDirs[i] );
}
m_comboDir.SetCurSel( 0 ); // guaranteed to be at least one item
}
+6 -6
View File
@@ -8,7 +8,7 @@ void WriteStepManiaInstallDirs( const CStringArray& asInstallDirsToWrite )
Reg.SetRootKey(HKEY_LOCAL_MACHINE);
Reg.SetKey("Software\\StepMania\\smpackage\\Installations", TRUE); // create if not already present
int i;
unsigned i;
for( i=0; i<100; i++ )
{
@@ -17,7 +17,7 @@ void WriteStepManiaInstallDirs( const CStringArray& asInstallDirsToWrite )
Reg.WriteString( sName, "" );
}
for( i=0; i<asInstallDirsToWrite.GetSize(); i++ )
for( i=0; i<asInstallDirsToWrite.size(); i++ )
{
CString sName = ssprintf("%d",i);
Reg.WriteString( sName, asInstallDirsToWrite[i] );
@@ -27,7 +27,7 @@ void WriteStepManiaInstallDirs( const CStringArray& asInstallDirsToWrite )
void GetStepManiaInstallDirs( CStringArray& asInstallDirsOut )
{
asInstallDirsOut.RemoveAll();
asInstallDirsOut.clear();
CRegistry Reg;
Reg.SetRootKey(HKEY_LOCAL_MACHINE);
@@ -42,7 +42,7 @@ void GetStepManiaInstallDirs( CStringArray& asInstallDirsOut )
if( sPath == "" ) // read failed
continue; // skip
asInstallDirsOut.Add( sPath );
asInstallDirsOut.push_back( sPath );
}
// while we're at it, write to clean up stale entries
@@ -55,7 +55,7 @@ void AddStepManiaInstallDir( CString sNewInstallDir )
GetStepManiaInstallDirs( asInstallDirs );
bool bAlreadyInList = false;
for( int i=0; i<asInstallDirs.GetSize(); i++ )
for( unsigned i=0; i<asInstallDirs.size(); i++ )
{
if( asInstallDirs[i].CompareNoCase(sNewInstallDir) == 0 )
{
@@ -65,7 +65,7 @@ void AddStepManiaInstallDir( CString sNewInstallDir )
}
if( !bAlreadyInList )
asInstallDirs.Add( sNewInstallDir );
asInstallDirs.push_back( sNewInstallDir );
WriteStepManiaInstallDirs( asInstallDirs );
}
+36 -32
View File
@@ -11,6 +11,10 @@
#include "smpackageUtil.h"
#include "EditInsallations.h"
#include <vector>
#include <algorithm>
using namespace std;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
@@ -83,9 +87,9 @@ CString ReplaceInvalidFileNameChars( CString sOldFileName )
return sNewFileName;
}
void GetFilePaths( CString sDirOrFile, CStringArray& asPathToFilesOut )
void GetFilePaths( CString sDirOrFile, vector<CString> &asPathToFilesOut )
{
CStringArray asDirectoriesToExplore;
vector<CString> asDirectoriesToExplore;
// HACK:
// Must use backslashes in the path, or else WinZip and WinRAR don't see the files.
@@ -99,18 +103,18 @@ void GetFilePaths( CString sDirOrFile, CStringArray& asPathToFilesOut )
if( IsAFile(sDirOrFile) )
{
asPathToFilesOut.Add( sDirOrFile );
asPathToFilesOut.push_back( sDirOrFile );
return;
}
GetDirListing( sDirOrFile, asPathToFilesOut, false, true );
GetDirListing( sDirOrFile, asDirectoriesToExplore, true, true );
while( asDirectoriesToExplore.GetSize() > 0 )
while( asDirectoriesToExplore.size() > 0 )
{
GetDirListing( asDirectoriesToExplore[0] + "\\*.*", asPathToFilesOut, false, true );
GetDirListing( asDirectoriesToExplore[0] + "\\*.*", asDirectoriesToExplore, true, true );
asDirectoriesToExplore.RemoveAt( 0 );
asDirectoriesToExplore.erase( 0 );
}
}
@@ -163,15 +167,15 @@ bool ExportPackage( CString sPackageName, const CStringArray& asDirectoriesToExp
zip.SetGlobalComment( sComment );
/* Find files to add to zip. */
int i;
CStringArray asFilePaths;
for( i=0; i<asDirectoriesToExport.GetSize(); i++ )
unsigned i;
vector<CString> asFilePaths;
for( i=0; i<asDirectoriesToExport.size(); i++ )
GetFilePaths( asDirectoriesToExport[i], asFilePaths );
//
// Add files to zip
//
for( int j=0; j<asFilePaths.GetSize(); j++ )
for( unsigned j=0; j<asFilePaths.size(); j++ )
{
CString sFilePath = asFilePaths[j];
@@ -236,12 +240,12 @@ void CSmpackageExportDlg::OnButtonExportAsOne()
CStringArray asPaths;
GetCheckedPaths( asPaths );
if( asPaths.GetSize() == 0 )
if( asPaths.size() == 0 )
{
AfxMessageBox( "No items are checked" );
return;
}
else if( asPaths.GetSize() == 1 )
else if( asPaths.size() == 1 )
{
OnButtonExportAsIndividual();
return;
@@ -270,7 +274,7 @@ void CSmpackageExportDlg::OnButtonExportAsIndividual()
CStringArray asPaths;
GetCheckedPaths( asPaths );
if( asPaths.GetSize() == 0 )
if( asPaths.size() == 0 )
{
AfxMessageBox( "No items are checked" );
return;
@@ -284,7 +288,7 @@ void CSmpackageExportDlg::OnButtonExportAsIndividual()
bool bAllSucceeded = true;
CStringArray asExportedPackages;
CStringArray asFailedPackages;
for( int i=0; i<asPaths.GetSize(); i++ )
for( unsigned i=0; i<asPaths.size(); i++ )
{
// Generate a package name for every path
CString sPath = asPaths[i];
@@ -292,21 +296,21 @@ void CSmpackageExportDlg::OnButtonExportAsIndividual()
CString sPackageName;
CStringArray asPathBits;
split( sPath, "\\", asPathBits, true );
sPackageName = asPathBits[ asPathBits.GetSize()-1 ] + ".smzip";
sPackageName = asPathBits[ asPathBits.size()-1 ] + ".smzip";
sPackageName = ReplaceInvalidFileNameChars( sPackageName );
CStringArray asPathsToExport;
asPathsToExport.Add( sPath );
asPathsToExport.push_back( sPath );
if( ExportPackage( sPackageName, asPathsToExport, sComment ) )
asExportedPackages.Add( sPackageName );
asExportedPackages.push_back( sPackageName );
else
asFailedPackages.Add( sPackageName );
asFailedPackages.push_back( sPackageName );
}
CString sMessage;
if( asFailedPackages.GetSize() == 0 )
sMessage = ssprintf("Successfully exported the package%s '%s' to your Desktop.", asFailedPackages.GetSize()>1?"s":"", join("', '",asExportedPackages) );
if( asFailedPackages.size() == 0 )
sMessage = ssprintf("Successfully exported the package%s '%s' to your Desktop.", asFailedPackages.size()>1?"s":"", join("', '",asExportedPackages) );
else
sMessage = ssprintf(" The packages %s failed to export.", join(", ",asFailedPackages) );
AfxMessageBox( sMessage );
@@ -392,7 +396,7 @@ void CSmpackageExportDlg::GetCheckedPaths( CStringArray& aPathsOut )
sPath.TrimRight('\\'); // strip off last slash
aPathsOut.Add( sPath );
aPathsOut.push_back( sPath );
}
}
@@ -416,7 +420,7 @@ void CSmpackageExportDlg::RefreshInstallationList()
CStringArray asInstallDirs;
GetStepManiaInstallDirs( asInstallDirs );
for( int i=0; i<asInstallDirs.GetSize(); i++ )
for( unsigned i=0; i<asInstallDirs.size(); i++ )
{
m_comboDir.AddString( asInstallDirs[i] );
}
@@ -443,7 +447,7 @@ void CSmpackageExportDlg::RefreshTree()
CStringArray as1;
HTREEITEM item1 = m_tree.InsertItem( "Announcers" );
GetDirListing( "Announcers\\*.*", as1, true, false );
for( int i=0; i<as1.GetSize(); i++ )
for( unsigned i=0; i<as1.size(); i++ )
m_tree.InsertItem( as1[i], item1 );
}
@@ -452,7 +456,7 @@ void CSmpackageExportDlg::RefreshTree()
CStringArray as1;
HTREEITEM item1 = m_tree.InsertItem( "Characters" );
GetDirListing( "Characters\\*.*", as1, true, false );
for( int i=0; i<as1.GetSize(); i++ )
for( unsigned i=0; i<as1.size(); i++ )
m_tree.InsertItem( as1[i], item1 );
}
@@ -461,7 +465,7 @@ void CSmpackageExportDlg::RefreshTree()
CStringArray as1;
HTREEITEM item1 = m_tree.InsertItem( "Themes" );
GetDirListing( "Themes\\*.*", as1, true, false );
for( int i=0; i<as1.GetSize(); i++ )
for( unsigned i=0; i<as1.size(); i++ )
m_tree.InsertItem( as1[i], item1 );
}
@@ -470,7 +474,7 @@ void CSmpackageExportDlg::RefreshTree()
CStringArray as1;
HTREEITEM item1 = m_tree.InsertItem( "BGAnimations" );
GetDirListing( "BGAnimations\\*.*", as1, true, false );
for( int i=0; i<as1.GetSize(); i++ )
for( unsigned i=0; i<as1.size(); i++ )
m_tree.InsertItem( as1[i], item1 );
}
@@ -481,7 +485,7 @@ void CSmpackageExportDlg::RefreshTree()
GetDirListing( "RandomMovies\\*.avi", as1, false, false );
GetDirListing( "RandomMovies\\*.mpg", as1, false, false );
GetDirListing( "RandomMovies\\*.mpeg", as1, false, false );
for( int i=0; i<as1.GetSize(); i++ )
for( unsigned i=0; i<as1.size(); i++ )
m_tree.InsertItem( as1[i], item1 );
}
@@ -492,7 +496,7 @@ void CSmpackageExportDlg::RefreshTree()
GetDirListing( "Visualizations\\*.avi", as1, false, false );
GetDirListing( "Visualizations\\*.mpg", as1, false, false );
GetDirListing( "Visualizations\\*.mpeg", as1, false, false );
for( int i=0; i<as1.GetSize(); i++ )
for( unsigned i=0; i<as1.size(); i++ )
m_tree.InsertItem( as1[i], item1 );
}
@@ -501,7 +505,7 @@ void CSmpackageExportDlg::RefreshTree()
CStringArray as1;
HTREEITEM item1 = m_tree.InsertItem( "Courses" );
GetDirListing( "Courses\\*.crs", as1, false, false );
for( int i=0; i<as1.GetSize(); i++ )
for( unsigned i=0; i<as1.size(); i++ )
{
as1[i] = as1[i].Left(as1[i].GetLength()-4); // strip off ".crs"
m_tree.InsertItem( as1[i], item1 );
@@ -516,12 +520,12 @@ void CSmpackageExportDlg::RefreshTree()
CStringArray as1;
HTREEITEM item1 = m_tree.InsertItem( "NoteSkins" );
GetDirListing( "NoteSkins\\*.*", as1, true, false );
for( int i=0; i<as1.GetSize(); i++ )
for( unsigned i=0; i<as1.size(); i++ )
{
CStringArray as2;
HTREEITEM item2 = m_tree.InsertItem( as1[i], item1 );
GetDirListing( "NoteSkins\\" + as1[i] + "\\*.*", as2, true, false );
for( int j=0; j<as2.GetSize(); j++ )
for( unsigned j=0; j<as2.size(); j++ )
m_tree.InsertItem( as2[j], item2 );
}
}
@@ -533,12 +537,12 @@ void CSmpackageExportDlg::RefreshTree()
CStringArray as1;
HTREEITEM item1 = m_tree.InsertItem( "Songs" );
GetDirListing( "Songs\\*.*", as1, true, false );
for( int i=0; i<as1.GetSize(); i++ )
for( unsigned i=0; i<as1.size(); i++ )
{
CStringArray as2;
HTREEITEM item2 = m_tree.InsertItem( as1[i], item1 );
GetDirListing( "Songs\\" + as1[i] + "\\*.*", as2, true, false );
for( int j=0; j<as2.GetSize(); j++ )
for( unsigned j=0; j<as2.size(); j++ )
m_tree.InsertItem( as2[j], item2 );
}
}
+3
View File
@@ -19,6 +19,9 @@
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <vector>
using namespace std;
#define CStringArray vector<CString>
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+26 -31
View File
@@ -62,7 +62,7 @@ BOOL ConvertThemeDlg::OnInitDialog()
CStringArray asThemes;
GetDirListing( "Themes\\*.*", asThemes, true, false );
for( int i=0; i<asThemes.GetSize(); i++ )
for( unsigned i=0; i<asThemes.size(); i++ )
// if( asThemes[i] != "default" ) // allow editing of default
m_listThemes.AddString( asThemes[i] );
@@ -78,7 +78,7 @@ void RecursiveRename( CString sDirStart, CString sOld, CString sNew )
CStringArray asFilesAndDirs;
GetDirListing( sDirStart+"*.*", asFilesAndDirs, false, false );
for( int i=0; i<asFilesAndDirs.GetSize(); i++ )
for( unsigned i=0; i<asFilesAndDirs.size(); i++ )
{
CString sOldFilePath = sDirStart+asFilesAndDirs[i];
CString sNewFilePath = sOldFilePath;
@@ -91,7 +91,7 @@ void RecursiveRename( CString sDirStart, CString sOld, CString sNew )
CStringArray asDirs;
GetDirListing( sDirStart+"*.*", asDirs, true, false );
for( i=0; i<asDirs.GetSize(); i++ )
for( i=0; i<asDirs.size(); i++ )
RecursiveRename( sDirStart+asDirs[i], sOld, sNew );
}
@@ -331,9 +331,6 @@ void LaunchNotepad( CString sPathToOpen )
void ConvertThemeDlg::OnButtonAnalyze()
{
// TODO: Add your control notification handler code here
int i;
CString sBaseDir = "Themes\\default\\";
int iSel = m_listThemes.GetCurSel();
CString sThemeName;
@@ -356,14 +353,15 @@ void ConvertThemeDlg::OnButtonAnalyze()
CStringArray asRedundant;
CStringArray asWarning;
for( i=0; i<asThemeFilePaths.GetSize(); i++ )
unsigned i;
for( i=0; i<asThemeFilePaths.size(); i++ )
{
CString sThemeElement = asThemeFilePaths[i];
sThemeElement.Replace( sThemeDir, "" );
sThemeElement = StripExtension( sThemeElement );
bool bFoundMatch = false;
for( int j=0; j<asBaseFilePaths.GetSize(); j++ )
for( unsigned j=0; j<asBaseFilePaths.size(); j++ )
{
CString sBaseElement = asBaseFilePaths[j];
sBaseElement.Replace( sBaseDir, "" );
@@ -373,12 +371,12 @@ void ConvertThemeDlg::OnButtonAnalyze()
{
bFoundMatch = true;
if( FilesAreIdentical( asThemeFilePaths[i], asBaseFilePaths[j] ) )
asRedundant.Add( asThemeFilePaths[i] );
asRedundant.push_back( asThemeFilePaths[i] );
break; // skip to next file in asThemeFilePaths
}
}
if( !bFoundMatch )
asWarning.Add( asThemeFilePaths[i] );
asWarning.push_back( asThemeFilePaths[i] );
}
SortCStringArray( asRedundant );
@@ -390,13 +388,13 @@ void ConvertThemeDlg::OnButtonAnalyze()
fprintf( fp, "The following elements are REDUNDANT.\n"
" (These elements are identical to the elements in the base theme.\n"
" They are unnecessary and should be deleted.)\n" );
for( i=0; i<asRedundant.GetSize(); i++ )
for( i=0; i<asRedundant.size(); i++ )
fprintf( fp, asRedundant[i] + "\n" );
fprintf( fp, "\n" );
fprintf( fp, "The following elements are possibly MISNAMED.\n"
" (These files do not have a corresponding element in the base theme.\n"
" This likely means that there is an error in the file name.)\n" );
for( i=0; i<asWarning.GetSize(); i++ )
for( i=0; i<asWarning.size(); i++ )
fprintf( fp, asWarning[i] + "\n" );
fclose( fp );
@@ -417,9 +415,6 @@ void ConvertThemeDlg::OnButtonEditMetrics()
void ConvertThemeDlg::OnButtonAnalyzeMetrics()
{
// TODO: Add your control notification handler code here
int i;
int iSel = m_listThemes.GetCurSel();
CString sThemeName;
m_listThemes.GetText( iSel, sThemeName );
@@ -433,27 +428,27 @@ void ConvertThemeDlg::OnButtonAnalyzeMetrics()
iniTheme.ReadFile();
CMapStringToString mapBaseClassPlusNameToValue;
for( i=0; i<iniBase.names.GetSize(); i++ )
unsigned i;
IniFile::const_iterator it;
for( it = iniBase.begin(); it != iniBase.end(); ++it )
{
CString sKey = iniBase.names[i];
IniFile::key& Key = iniBase.keys[i];
for( POSITION pos=Key.GetStartPosition(); pos!=NULL; )
CString sKey = it->first;
const IniFile::key &Key = it->second;
for( IniFile::key::const_iterator val = Key.begin(); val != Key.end(); ++val )
{
CString sName, sValue;
Key.GetNextAssoc( pos, sName, sValue );
CString sName = val->first, sValue = val->second;
mapBaseClassPlusNameToValue[sKey+"-"+sName] = sValue;
}
}
CMapStringToString mapThemeClassPlusNameToValue;
for( i=0; i<iniTheme.names.GetSize(); i++ )
for( it = iniTheme.begin(); it != iniTheme.end(); ++it )
{
CString sKey = iniTheme.names[i];
IniFile::key& Key = iniTheme.keys[i];
for( POSITION pos=Key.GetStartPosition(); pos!=NULL; )
CString sKey = it->first;
const IniFile::key &Key = it->second;
for( IniFile::key::const_iterator val = Key.begin(); val != Key.end(); ++val )
{
CString sName, sValue;
Key.GetNextAssoc( pos, sName, sValue );
CString sName = val->first, sValue = val->second;
mapThemeClassPlusNameToValue[sKey+"-"+sName] = sValue;
}
}
@@ -476,12 +471,12 @@ void ConvertThemeDlg::OnButtonAnalyzeMetrics()
{
bFoundMatch = true;
if( sThemeValue == sBaseValue )
asRedundant.Add( sThemeKey );
asRedundant.push_back( sThemeKey );
break; // skip to next file in asThemeFilePaths
}
}
if( !bFoundMatch )
asWarning.Add( sThemeKey );
asWarning.push_back( sThemeKey );
}
SortCStringArray( asRedundant );
@@ -493,13 +488,13 @@ void ConvertThemeDlg::OnButtonAnalyzeMetrics()
fprintf( fp, "The following metrics are REDUNDANT.\n"
" (These metrics are identical to the metrics in the base theme.\n"
" They are unnecessary and should be deleted.)\n" );
for( i=0; i<asRedundant.GetSize(); i++ )
for( i=0; i<asRedundant.size(); i++ )
fprintf( fp, asRedundant[i] + "\n" );
fprintf( fp, "\n" );
fprintf( fp, "The following elements are possibly MISNAMED.\n"
" (These metrics do not have a corresponding metric in\n"
" the base theme. This likely means that there is an error in the metric name.)\n" );
for( i=0; i<asWarning.GetSize(); i++ )
for( i=0; i<asWarning.size(); i++ )
fprintf( fp, asWarning[i] + "\n" );
fclose( fp );
+1 -1
View File
@@ -68,7 +68,7 @@ BOOL CSmpackageApp::InitInstance()
// check if there's a .smzip command line argument
CStringArray arrayCommandLineBits;
split( ::GetCommandLine(), "\"", arrayCommandLineBits );
for( int i=0; i<arrayCommandLineBits.GetSize(); i++ )
for( unsigned i=0; i<arrayCommandLineBits.size(); i++ )
{
CString sPath = arrayCommandLineBits[i];
sPath.TrimLeft();