Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@


/** Is the filesystem case insensitive? */
static bool caseInsensitiveFilesystem()
static constexpr bool caseInsensitiveFilesystem()
{
#ifdef _WIN32
#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__))
// Windows is case insensitive
// MacOS is case insensitive by default (also supports case sensitivity)
return true;
#else
// TODO: Non-windows filesystems might be case insensitive
Expand Down
3 changes: 2 additions & 1 deletion releasenotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ Deprecations:
Other:
- "USE_QT6=On" will no longer fallback to Qt5 when Qt6 is not found.
- When the execution of an addon fails with an exitcode it will now result in an 'internalError' instead of being silently ignored.
- "Win32" configurations have been removed from the bundled Visual Studio solution and projects. You might still be able to build 32-bit binaries using CMake but that is untested and unmaintained.
- "Win32" configurations have been removed from the bundled Visual Studio solution and projects. You might still be able to build 32-bit binaries using CMake but that is untested and unmaintained.
- The MacOS filesystem is now treated as case insensitive.
53 changes: 51 additions & 2 deletions test/testpath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class TestPath : public TestFixture {
TEST_CASE(join);
TEST_CASE(isDirectory);
TEST_CASE(isFile);
TEST_CASE(sameFileName);
TEST_CASE(getFilenameExtension);
}

void removeQuotationMarks() const {
Expand Down Expand Up @@ -123,7 +125,7 @@ class TestPath : public TestFixture {
ASSERT(Path::isC("C:\\foo\\index.c"));

// In unix .C is considered C++
#ifdef _WIN32
#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__))
ASSERT_EQUALS(true, Path::isC("C:\\foo\\index.C"));
#else
ASSERT_EQUALS(false, Path::isC("C:\\foo\\index.C"));
Expand All @@ -134,7 +136,7 @@ class TestPath : public TestFixture {
ASSERT(Path::isCPP("index.c")==false);

// In unix .C is considered C++
#ifdef _WIN32
#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__))
ASSERT_EQUALS(false, Path::isCPP("index.C"));
#else
ASSERT_EQUALS(true, Path::isCPP("index.C"));
Expand Down Expand Up @@ -176,6 +178,53 @@ class TestPath : public TestFixture {
ASSERT_EQUALS(true, Path::isFile("testpath/testpath.txt"));
ASSERT_EQUALS(true, Path::isFile("testpath2.txt"));
}

void sameFileName() const {
ASSERT(Path::sameFileName("test", "test"));

// case sensitivity cases
#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__))
ASSERT(Path::sameFileName("test", "Test"));
ASSERT(Path::sameFileName("test", "TesT"));
ASSERT(Path::sameFileName("test.h", "test.H"));
ASSERT(Path::sameFileName("test.hh", "test.Hh"));
ASSERT(Path::sameFileName("test.hh", "test.hH"));
#else
ASSERT(!Path::sameFileName("test", "Test"));
ASSERT(!Path::sameFileName("test", "TesT"));
ASSERT(!Path::sameFileName("test.h", "test.H"));
ASSERT(!Path::sameFileName("test.hh", "test.Hh"));
ASSERT(!Path::sameFileName("test.hh", "test.hH"));
#endif
}

void getFilenameExtension() const {
ASSERT_EQUALS("", Path::getFilenameExtension("test"));
ASSERT_EQUALS("", Path::getFilenameExtension("Test"));
ASSERT_EQUALS(".h", Path::getFilenameExtension("test.h"));
ASSERT_EQUALS(".h", Path::getFilenameExtension("Test.h"));
ASSERT_EQUALS("", Path::getFilenameExtension("test", true));
ASSERT_EQUALS("", Path::getFilenameExtension("Test", true));
ASSERT_EQUALS(".h", Path::getFilenameExtension("test.h", true));
ASSERT_EQUALS(".h", Path::getFilenameExtension("Test.h", true));

// case sensitivity cases
#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__))
ASSERT_EQUALS(".h", Path::getFilenameExtension("test.H"));
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.Hh"));
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.hH"));
ASSERT_EQUALS(".h", Path::getFilenameExtension("test.H", true));
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.Hh", true));
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.hH", true));
#else
ASSERT_EQUALS(".H", Path::getFilenameExtension("test.H"));
ASSERT_EQUALS(".Hh", Path::getFilenameExtension("test.Hh"));
ASSERT_EQUALS(".hH", Path::getFilenameExtension("test.hH"));
ASSERT_EQUALS(".h", Path::getFilenameExtension("test.H", true));
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.Hh", true));
ASSERT_EQUALS(".hh", Path::getFilenameExtension("test.hH", true));
#endif
}
};

REGISTER_TEST(TestPath)