Made changes to prevent compiler/linker errors of clutils.

* Added shlwapi.lib for MSVC target.
* Added pure Win32 alternative implementation for DirObj::Reset function.
This commit is contained in:
davyw
2011-12-07 18:45:42 -05:00
committed by Mark Pictor
parent 784285605e
commit 6226717d18
2 changed files with 31 additions and 3 deletions
+4
View File
@@ -35,6 +35,10 @@ IF(MINGW)
TARGET_LINK_LIBRARIES(steputils shlwapi.lib)
ENDIF(MINGW)
IF(MSVC)
TARGET_LINK_LIBRARIES(steputils shlwapi.lib)
ENDIF(MSVC)
if(APPLE)
set_target_properties(steputils PROPERTIES LINK_FLAGS "-flat_namespace -undefined suppress")
endif(APPLE)
+27 -3
View File
@@ -142,6 +142,21 @@ int DirObj::Index( const char * name ) {
bool DirObj::Reset( const std::string & path ) {
bool successful = IsADirectory( path.c_str() );
if( successful ) {
#ifdef __WIN32__
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
ClearFileList();
hFind = FindFirstFile( path.c_str(), &FindFileData );
if (hFind != INVALID_HANDLE_VALUE)
{
int i = 0;
do {
InsertFile( FindFileData.cFileName, i++ );
} while ( FindNextFile( hFind, &FindFileData ) );
FindClose( hFind );
}
#else
DIR * dir = opendir( path.c_str() );
ClearFileList();
@@ -149,6 +164,7 @@ bool DirObj::Reset( const std::string & path ) {
InsertFile( d->d_name, Position( d->d_name ) );
}
closedir( dir );
#endif
} else std::cout << "not a directory: " << path << "!" << std::endl;
return successful;
}
@@ -227,7 +243,11 @@ const std::string DirObj::Normalize( const std::string & path ) {
///////////////////////////////////////////////////////////////////////////////
const char * DirObj::ValidDirectories( const char * path ) {
static char buf[MAXPATHLEN + 1];
#ifdef __WIN32__
static char buf[MAX_PATH + 1];
#else
static char buf[MAXPATHLEN + 1];
#endif
strcpy( buf, path );
int i = strlen( path );
@@ -277,8 +297,12 @@ void DirObj::InsertFile( const char * f, int index ) {
CheckIndex( index );
spot = &fileList[index];
}
char * string = strdup( f );
*spot = string;
#ifdef __WIN32__
char * string = _strdup( f );
#else
char * string = strdup( f );
#endif
*spot = string;
++fileCount;
}