107 lines
1.9 KiB
C
107 lines
1.9 KiB
C
|
|
#pragma once
|
|
|
|
static const char* getExtFromFileName ( const char* filename )
|
|
{
|
|
const char *lastfound = NULL;
|
|
int i=0;
|
|
while ( filename[i] != '\0' )
|
|
{
|
|
if ( filename[i++] == '.' )
|
|
lastfound = filename+i;
|
|
}
|
|
return lastfound;
|
|
}
|
|
static void makePathNameFromFileName(char* filename)
|
|
{
|
|
char *lastfound = NULL;
|
|
int i=0;
|
|
while ( filename[i] != '\0' )
|
|
{
|
|
if ( filename[i++] == '\\' )
|
|
lastfound = filename+i;
|
|
}
|
|
if ( lastfound ) *lastfound = '\0';
|
|
}
|
|
static const char* getFileNameFromPath(const char* filename)
|
|
{
|
|
const char *lastfound = (filename);
|
|
int i=0;
|
|
while ( filename[i] != '\0' )
|
|
{
|
|
if ( filename[i++] == '\\' )
|
|
lastfound = (filename+i);
|
|
}
|
|
return lastfound;
|
|
}
|
|
|
|
extern const char * pResLevel[];
|
|
|
|
static void changeExtFromFileName ( char* filename, int nLevel, char *ext )
|
|
{
|
|
char *lastfound = NULL;
|
|
int i=0;
|
|
while ( filename[i] != '\0' )
|
|
{
|
|
if ( filename[i++] == '.' )
|
|
lastfound = filename+i;
|
|
}
|
|
|
|
if ( lastfound )
|
|
{
|
|
//리소스 레벨에 따른 추가 확장자 붙임
|
|
//if( nLevel == 1 )
|
|
//{
|
|
// --lastfound; //'.' 부터 수정.
|
|
|
|
// for ( i=0 ; i<4 ; i++ )
|
|
// {
|
|
// (*lastfound) = pResLevel[nLevel][i];
|
|
// lastfound++;
|
|
// }
|
|
//}
|
|
|
|
int l = static_cast<int>(strlen(ext));
|
|
for ( i=0 ; i<l ; i++ )
|
|
{
|
|
(*lastfound) = ext[i];
|
|
lastfound++;
|
|
}
|
|
|
|
//if( nLevel == 1 )
|
|
// (*lastfound) = '\0';
|
|
}
|
|
}
|
|
|
|
static bool checkExtFromFileName ( const char* filename, const char *ext )
|
|
{
|
|
int filename_len = strlen(filename);
|
|
int ext_len = strlen(ext);
|
|
|
|
if( filename_len < ext_len )
|
|
return false;
|
|
|
|
char *lastfound = NULL;
|
|
int i=0;
|
|
while ( filename[i] != '\0' )
|
|
{
|
|
if ( filename[i++] == '.' )
|
|
lastfound = (char *)(filename+i);
|
|
}
|
|
|
|
if( ::strcmpi( lastfound, ext) == 0)
|
|
return true;
|
|
|
|
|
|
return false;
|
|
}
|
|
|
|
static void makeCorrectPath( char *path )
|
|
{
|
|
int len = strlen( path );
|
|
if ( path[len-1] != '\\' )
|
|
{
|
|
strcat( path, "\\" );
|
|
}
|
|
}
|