]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - libs/os/path.h
Merge commit '70f0925f0000a132c709b935aa5cb0942b5080d9' into master-merge
[xonotic/netradiant.git] / libs / os / path.h
index e3329a758c76ec79291659a0af7cc2807ccbc0bb..9cbbc2b1361c49a21b48acb82be6b95af3e69831 100644 (file)
@@ -22,6 +22,8 @@
 #if !defined ( INCLUDED_OS_PATH_H )
 #define INCLUDED_OS_PATH_H
 
+#include "globaldefs.h"
+
 /// \file
 /// \brief OS file-system path comparison, decomposition and manipulation.
 ///
@@ -33,7 +35,7 @@
 
 #include "string/string.h"
 
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
 #define OS_CASE_INSENSITIVE
 #endif
 
@@ -70,6 +72,12 @@ inline bool path_equal( const char* path, const char* other ){
 #endif
 }
 
+/// \brief Returns true if \p path and \p other refer to the same file or directory, case insensitively.
+/// O(n)
+inline bool path_equal_i( const char* path, const char* other ){
+       return string_equal_nocase( path, other );
+}
+
 /// \brief Returns true if the first \p n bytes of \p path and \p other form paths that refer to the same file or directory.
 /// If the paths are UTF-8 encoded, [\p path, \p path + \p n) must be a complete path.
 /// O(n)
@@ -85,10 +93,10 @@ inline bool path_equal_n( const char* path, const char* other, std::size_t n ){
 /// \brief Returns true if \p path is a fully qualified file-system path.
 /// O(1)
 inline bool path_is_absolute( const char* path ){
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
        return path[0] == '/'
                   || ( path[0] != '\0' && path[1] == ':' ); // local drive
-#elif defined( POSIX )
+#elif GDEF_OS_POSIX
        return path[0] == '/';
 #endif
 }
@@ -173,6 +181,12 @@ inline bool extension_equal( const char* extension, const char* other ){
        return path_equal( extension, other );
 }
 
+/// \brief Returns true if \p extension is of the same type as \p other, case insensitively.
+/// O(n)
+inline bool extension_equal_i( const char* extension, const char* other ){
+       return path_equal_i( extension, other );
+}
+
 template<typename Functor>
 class MatchFileExtension
 {