From 3e7ee32ded33163f4aa6478274426b1a9e475e02 Mon Sep 17 00:00:00 2001 From: Garux Date: Fri, 5 Jun 2020 21:11:26 +0300 Subject: [PATCH] make extension_equal() check case insensitive in Unix allows most of file types with non lowercase extension known issue: textures with non lowercase extension in loose folders are visible now, but they aren't loaded, because it leads to fopen( filename.lowercase_extension ) --- libs/gtkutil/filechooser.cpp | 2 +- libs/os/path.h | 2 +- radiant/environment.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/gtkutil/filechooser.cpp b/libs/gtkutil/filechooser.cpp index 35229eec..0abe3581 100644 --- a/libs/gtkutil/filechooser.cpp +++ b/libs/gtkutil/filechooser.cpp @@ -223,7 +223,7 @@ const char* file_dialog_show( GtkWidget* parent, bool open, const char* title, c else{ /* validate extension */ bool valid = false; for ( std::size_t i = 0; i < masks.m_filters.size(); ++i ) - if( string_length( masks.m_filters[i].c_str() ) >= 2 && string_equal_nocase( extension, masks.m_filters[i].c_str() + 2 ) ) + if( string_length( masks.m_filters[i].c_str() ) >= 2 && extension_equal( extension, masks.m_filters[i].c_str() + 2 ) ) valid = true; if( !valid ){ g_file_dialog_file[0] = '\0'; diff --git a/libs/os/path.h b/libs/os/path.h index ff8a291c..2f4e2f56 100644 --- a/libs/os/path.h +++ b/libs/os/path.h @@ -170,7 +170,7 @@ inline const char* path_get_extension( const char* path ){ /// \brief Returns true if \p extension is of the same type as \p other. /// O(n) inline bool extension_equal( const char* extension, const char* other ){ - return path_equal( extension, other ); + return string_equal_nocase( extension, other ); } template diff --git a/radiant/environment.cpp b/radiant/environment.cpp index de57bdc7..6fbd9018 100644 --- a/radiant/environment.cpp +++ b/radiant/environment.cpp @@ -197,7 +197,7 @@ CopiedString g_openMapByCmd; void cmdMap(){ for ( int i = 1; i < g_argc; ++i ) - if( string_equal_suffix_nocase( g_argv[i], ".map" ) ){ + if( extension_equal( path_get_extension( g_argv[i] ), "map" ) ){ StringOutputStream stream( 256 ); stream << PathCleaned( g_argv[i] ); g_openMapByCmd = stream.c_str();