Commit d91e910 1 parent a96b224 commit d91e910 Copy full SHA for d91e910
File tree 1 file changed +12
-12
lines changed
1 file changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -1946,25 +1946,25 @@ const char *GetFileName(const char *filePath)
1946
1946
// Get filename string without extension (uses static string)
1947
1947
const char * GetFileNameWithoutExt (const char * filePath )
1948
1948
{
1949
- #define MAX_FILENAMEWITHOUTEXT_LENGTH 256
1950
-
1949
+ #define MAX_FILENAMEWITHOUTEXT_LENGTH 256
1950
+
1951
1951
static char fileName [MAX_FILENAMEWITHOUTEXT_LENGTH ] = { 0 };
1952
1952
memset (fileName , 0 , MAX_FILENAMEWITHOUTEXT_LENGTH );
1953
1953
1954
- if (filePath != NULL ) strcpy (fileName , GetFileName (filePath )); // Get filename with extension
1955
-
1956
- int size = (int )strlen (fileName ); // Get size in bytes
1957
-
1958
- for (int i = 0 ; (i < size ) && (i < MAX_FILENAMEWITHOUTEXT_LENGTH ); i ++ )
1954
+ if (filePath != NULL )
1959
1955
{
1960
- if (fileName [i ] == '.' )
1956
+ strcpy (fileName , GetFileName (filePath )); // Get filename.ext without path
1957
+ int size = (int )strlen (fileName ); // Get size in bytes
1958
+ for (int i = size ; i > 0 ; i -- ) // Reverse search '.'
1961
1959
{
1962
- // NOTE: We break on first '.' found
1963
- fileName [i ] = '\0' ;
1964
- break ;
1960
+ if (fileName [i ] == '.' )
1961
+ {
1962
+ // NOTE: We break on first '.' found
1963
+ fileName [i ] = '\0' ;
1964
+ break ;
1965
+ }
1965
1966
}
1966
1967
}
1967
-
1968
1968
return fileName ;
1969
1969
}
1970
1970
You can’t perform that action at this time.
0 commit comments