diff --git a/src/pymod/bridge_sample/bridge_sample.pro b/src/pymod/bridge_sample/bridge_sample.pro index c164da1aa..5c06e60fc 100644 --- a/src/pymod/bridge_sample/bridge_sample.pro +++ b/src/pymod/bridge_sample/bridge_sample.pro @@ -91,9 +91,11 @@ win32 { # to avoid the major version being appended to the dll name - in this case -lxyz won't link it again # because the library is called xyx0.dll. CONFIG += skip_target_version_ext + # make the proper library name for Python + QMAKE_POST_LINK += $(COPY) $(DESTDIR_TARGET) $$DESTDIR/$${TARGET}$${PYTHONEXTSUFFIX} } else { # Make the target library without the "lib" prefix on Linux - QMAKE_POST_LINK += $(COPY) $(DESTDIR)$(TARGET) $$DESTDIR/$${TARGET}.so + QMAKE_POST_LINK += $(COPY) $(DESTDIR)$(TARGET) $$DESTDIR/$${TARGET}$${PYTHONEXTSUFFIX} } # nothing to install as we're building a test library diff --git a/src/pymod/unit_tests/pymod_tests.cc b/src/pymod/unit_tests/pymod_tests.cc index c80b81a8e..0ada3f98b 100644 --- a/src/pymod/unit_tests/pymod_tests.cc +++ b/src/pymod/unit_tests/pymod_tests.cc @@ -39,6 +39,7 @@ int run_pymodtest (tl::TestBase *_this, const std::string &fn) pypath = "PYTHONPATH="; pypath += STRINGIFY (PYTHONPATH); putenv ((char *) pypath.c_str ()); + tl::info << pypath; std::string fp (tl::testsrc ()); fp += "/testdata/pymod/"; diff --git a/src/tl/tl/tlFileUtils.cc b/src/tl/tl/tlFileUtils.cc index ebeacbd0b..2fd67acc8 100644 --- a/src/tl/tl/tlFileUtils.cc +++ b/src/tl/tl/tlFileUtils.cc @@ -713,8 +713,8 @@ bool is_same_file (const std::string &a, const std::string &b) #if defined(_WIN32) - HANDLE h1 = ::CreateFileW (tl::to_wstring (a).c_str (), 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - HANDLE h2 = ::CreateFileW (tl::to_wstring (b).c_str (), 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE h1 = ::CreateFileW (tl::to_wstring (a).c_str (), 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); + HANDLE h2 = ::CreateFileW (tl::to_wstring (b).c_str (), 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); bool result = false; diff --git a/src/tl/unit_tests/tlFileUtils.cc b/src/tl/unit_tests/tlFileUtils.cc index 117b4b197..c49bc77ab 100644 --- a/src/tl/unit_tests/tlFileUtils.cc +++ b/src/tl/unit_tests/tlFileUtils.cc @@ -24,6 +24,7 @@ #include "tlFileUtils.h" #include "tlUnitTest.h" #include "tlStream.h" +#include "tlString.h" #include @@ -540,7 +541,7 @@ TEST(15) EXPECT_EQ (tl::relative_path (xpath2, xpath2), ""); EXPECT_EQ (tl::relative_path (xpath2, xpath), "doesnotexist"); - EXPECT_EQ (tl::relative_path (xpath2, tl::combine_path (xpath, "a")), "doesnotexist/a"); + EXPECT_EQ (tl::replaced (tl::relative_path (xpath2, tl::combine_path (xpath, "a")), "\\", "/"), "doesnotexist/a"); } // dir_entries @@ -628,3 +629,43 @@ TEST(16) EXPECT_EQ (tl::rm_dir (tt), false); // not empty } +// is_same_file +TEST (17) +{ + std::string currdir = tl::current_dir (); + std::string currdir_abs = tl::absolute_file_path ("."); + EXPECT_EQ (currdir, currdir_abs); + EXPECT_EQ (tl::is_same_file (currdir, "."), true); + EXPECT_EQ (tl::is_same_file (".", currdir), true); + + std::string above = tl::absolute_file_path (".."); + EXPECT_EQ (tl::is_same_file (currdir, above), false); + EXPECT_EQ (tl::is_same_file (above, currdir), false); + + std::string tp = tl::absolute_file_path (tmp_file ()); + std::string dpath = tl::combine_path (tp, "d"); + EXPECT_EQ (tl::mkpath (dpath), true); + std::string xfile = tl::combine_path (dpath, "x"); + std::string yfile = tl::combine_path (dpath, "y"); + { + tl::OutputStream os (xfile); + os << "hello, world!"; + } + { + tl::OutputStream os (yfile); + os << "hello, world II!"; + } + EXPECT_EQ (tl::file_exists (xfile), true); + EXPECT_EQ (tl::is_same_file (xfile, tp), false); + EXPECT_EQ (tl::is_same_file (dpath, xfile), false); + EXPECT_EQ (tl::is_parent_path (dpath, xfile), true); + EXPECT_EQ (tl::is_parent_path (xfile, dpath), false); + + EXPECT_EQ (tl::is_same_file (tl::combine_path (dpath, "../d/x"), xfile), true); + EXPECT_EQ (tl::is_same_file (tl::combine_path (dpath, "../d/y"), xfile), false); + EXPECT_EQ (tl::is_same_file (tl::combine_path (dpath, "../d/y"), yfile), true); + EXPECT_EQ (tl::is_same_file (xfile, tl::combine_path (dpath, "../d/x")), true); + EXPECT_EQ (tl::is_same_file (xfile, tl::combine_path (dpath, "../d/y")), false); + EXPECT_EQ (tl::is_same_file (yfile, tl::combine_path (dpath, "../d/y")), true); +} +