diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 2df7ff82..a06bc53d 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -7,7 +7,7 @@ add_executable( exiv2 $ ) -target_include_directories(exiv2 PRIVATE ${CMAKE_SOURCE_DIR}/src) # To find utils.hpp +target_include_directories(exiv2 PRIVATE ${CMAKE_SOURCE_DIR}/src) # To find i18n.hpp set_target_properties( exiv2 PROPERTIES COMPILE_FLAGS ${EXTRA_COMPILE_FLAGS} diff --git a/app/actions.cpp b/app/actions.cpp index 11153ed9..f8cefa07 100644 --- a/app/actions.cpp +++ b/app/actions.cpp @@ -31,7 +31,6 @@ #include "image.hpp" #include "jpgimage.hpp" #include "xmpsidecar.hpp" -#include "utils.hpp" #include "types.hpp" #include "exif.hpp" #include "easyaccess.hpp" @@ -1974,10 +1973,11 @@ namespace { { auto p = fs::path(newPath); std::string path = newPath; + auto oldFsPath = fs::path(path); std::string format = Params::instance().format_; - replace(format, ":basename:", Util::basename(path, true)); - replace(format, ":dirname:", Util::basename(Util::dirname(path))); - replace(format, ":parentname:", Util::basename(Util::dirname(Util::dirname(path)))); + replace(format, ":basename:", p.stem().string()); + replace(format, ":dirname:", p.parent_path().filename().string()); + replace(format, ":parentname:", p.parent_path().parent_path().filename().string()); const size_t max = 1024; char basename[max]; @@ -1989,9 +1989,9 @@ namespace { } newPath = p.parent_path() / (basename + p.extension().string()); + p = fs::path(newPath); - if ( Util::dirname(newPath) == Util::dirname(path) - && Util::basename(newPath) == Util::basename(path)) { + if (p.parent_path() == oldFsPath.parent_path() && p.filename() == oldFsPath.filename()) { if (Params::instance().verbose_) { std::cout << _("This file already has the correct name") << std::endl; } @@ -2066,13 +2066,13 @@ namespace { std::string newFilePath(const std::string& path, const std::string& ext) { - std::string directory = Params::instance().directory_; + auto p = fs::path(path); + auto directory = fs::path(Params::instance().directory_); if (directory.empty()) - directory = Util::dirname(path); - directory = Exiv2::fileProtocol(path) == Exiv2::pFile ? directory + EXV_SEPARATOR_STR - : "" // use current directory for remote files - ; - return directory + Util::basename(path, true) + ext; + directory = p.parent_path(); + if (Exiv2::fileProtocol(path) != Exiv2::pFile) + directory.clear(); // use current directory for remote files + return directory / (p.stem().string() + ext); } int dontOverwrite(const std::string& path) diff --git a/app/app_utils.cpp b/app/app_utils.cpp index dec2955c..09aaf144 100644 --- a/app/app_utils.cpp +++ b/app/app_utils.cpp @@ -1,5 +1,3 @@ -#include "utils.hpp" - #include #include diff --git a/app/exiv2.cpp b/app/exiv2.cpp index 87fb2f99..182ab7ae 100644 --- a/app/exiv2.cpp +++ b/app/exiv2.cpp @@ -29,7 +29,6 @@ #include "futils.hpp" #include "getopt.hpp" #include "i18n.h" // NLS support. -#include "utils.hpp" #include "xmp_exiv2.hpp" #include diff --git a/app/exiv2app.hpp b/app/exiv2app.hpp index 35b22c1c..97230021 100644 --- a/app/exiv2app.hpp +++ b/app/exiv2app.hpp @@ -31,7 +31,6 @@ // included header files #include -#include "utils.hpp" #include "types.hpp" #include "getopt.hpp" diff --git a/app/getopt.cpp b/app/getopt.cpp index b176971e..4fd54d2e 100644 --- a/app/getopt.cpp +++ b/app/getopt.cpp @@ -25,15 +25,17 @@ // included header files #include #include +#include +#include #include #include #include #include -#include -#include "utils.hpp" #include "getopt.hpp" +namespace fs = std::filesystem; + namespace Util { // https://raw.githubusercontent.com/skeeto/getopt/master/getopt.h @@ -113,7 +115,7 @@ namespace Util { int Getopt::getopt(int argc, char* const argv[], const std::string& optstring) { - progname_ = Util::basename(argv[0]); + progname_ = fs::path(argv[0]).filename().string(); Util::optind = 0; // reset the Util::Getopt scanner for (;!errcnt_;) { diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index c8442d52..566f0ab2 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -52,27 +52,24 @@ if (MSVC) link_directories(${CMAKE_INSTALL_PREFIX}/lib) endif() -add_executable( getopt-test getopt-test.cpp ../app/getopt.cpp ../src/utils.cpp) +add_executable( getopt-test getopt-test.cpp ../app/getopt.cpp) list(APPEND APPLICATIONS getopt-test) target_include_directories(getopt-test PRIVATE ${CMAKE_SOURCE_DIR}/app - ${CMAKE_SOURCE_DIR}/src -) # To find utils.hpp & getopt.hpp +) # To find getopt.hpp -add_executable( metacopy metacopy.cpp ../app/getopt.cpp ../src/utils.cpp) +add_executable( metacopy metacopy.cpp ../app/getopt.cpp) list(APPEND APPLICATIONS metacopy) target_include_directories(metacopy PRIVATE ${CMAKE_SOURCE_DIR}/app - ${CMAKE_SOURCE_DIR}/src -) # To find utils.hpp & getopt.hpp +) # To find getopt.hpp -add_executable( path-test path-test.cpp ../app/getopt.cpp ../src/utils.cpp) +add_executable( path-test path-test.cpp ../app/getopt.cpp) list(APPEND APPLICATIONS path-test) set_target_properties( path-test PROPERTIES OUTPUT_NAME path-test ) target_include_directories(path-test PRIVATE ${CMAKE_SOURCE_DIR}/app - ${CMAKE_SOURCE_DIR}/src -) # To find utils.hpp & getopt.hpp +) # To find getopt.hpp add_executable( exiv2json exiv2json.cpp Jzon.cpp Jzon.h) list(APPEND APPLICATIONS exiv2json) diff --git a/samples/path-test.cpp b/samples/path-test.cpp index 7dd5abd5..4f7a8d4a 100644 --- a/samples/path-test.cpp +++ b/samples/path-test.cpp @@ -20,12 +20,13 @@ */ #include +#include #include #include #include #include -#include "utils.hpp" +namespace fs = std::filesystem; int main(int argc, char* const argv[]) { @@ -49,8 +50,9 @@ int main(int argc, char* const argv[]) std::string path, dir, base; std::istringstream is(line); is >> path >> dir >> base; - std::string d = Util::dirname(path); - std::string b = Util::basename(path); + auto p = fs::path(path); + std::string d = p.parent_path().string(); + std::string b = p.filename().string(); if (d != dir || b != base) { std::cout << path << "\t'" << d << "'\t '" << b diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b6f75c84..a4990b4e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -36,7 +36,6 @@ add_library( exiv2lib_int OBJECT tifffwd_int.hpp timegm.h unused.h - utils.cpp utils.hpp ) set(PUBLIC_HEADERS diff --git a/src/epsimage.cpp b/src/epsimage.cpp index 9fcaeea6..e0434fec 100644 --- a/src/epsimage.cpp +++ b/src/epsimage.cpp @@ -33,7 +33,6 @@ #include "error.hpp" #include "futils.hpp" #include "version.hpp" -#include "utils.hpp" // + standard includes #include @@ -49,7 +48,6 @@ namespace { using namespace Exiv2; - using namespace Util; using Exiv2::byte; // signature of DOS EPS diff --git a/src/makernote_int.cpp b/src/makernote_int.cpp index cf8a0444..5863eb01 100644 --- a/src/makernote_int.cpp +++ b/src/makernote_int.cpp @@ -32,7 +32,6 @@ #include "tiffvisitor_int.hpp" #include "tiffimage.hpp" #include "tiffimage_int.hpp" -#include "utils.hpp" // + standard includes #include diff --git a/src/sonymn_int.cpp b/src/sonymn_int.cpp index b168170d..e59b5e99 100644 --- a/src/sonymn_int.cpp +++ b/src/sonymn_int.cpp @@ -27,7 +27,6 @@ #include "value.hpp" #include "exif.hpp" #include "i18n.h" // NLS support. -#include "utils.hpp" // + standard includes #include diff --git a/src/utils.cpp b/src/utils.cpp deleted file mode 100644 index dbe3325f..00000000 --- a/src/utils.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2004-2021 Exiv2 authors - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. - */ -// ***************************************************************************** - -#include "utils.hpp" - -#include - -namespace fs = std::filesystem; - -namespace Util { - -// ***************************************************************************** -// free functions - - std::string dirname(const std::string& path) - { - auto p = fs::path(path).parent_path(); - if (p.empty()) - return "."; - return p.string(); - } - - std::string basename(const std::string& path, bool delsuffix) - { - auto p = fs::path(path); - if (delsuffix) - return p.stem().string(); - return p.filename().string(); - } -} // namespace Util diff --git a/src/utils.hpp b/src/utils.hpp deleted file mode 100644 index 8c081601..00000000 --- a/src/utils.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// ***************************************************************** -*- C++ -*- -/* - * Copyright (C) 2004-2021 Exiv2 authors - * This program is part of the Exiv2 distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA. - */ -#ifndef UTILS_HPP_ -#define UTILS_HPP_ - -// ********************************************************************* -// included header files - -// + standard includes -#include - -// ********************************************************************* -// namespace extensions -/*! - @brief Contains utility classes and functions. Most of these are - wrappers for common C functions that do not require pointers - and memory considerations. -*/ -namespace Util { - -// ********************************************************************* -// free functions - - /*! - @brief Get the directory component from the \em path string. - See %dirname(3). - - This function can handle Windows paths to some extent: c:\\bar should - be fine, \\\\bigsrv\\foo also, but \\\\bigsrv alone doesn't work. - */ - std::string dirname(const std::string& path); - - /*! - @brief Get the filename component from the \em path string. - See %basename(3). If the \em delsuffix parameter is true, - the suffix will be removed. - - This function can handle Windows paths to some extent: c:\\bar should - be fine, \\\\bigsrv\\foo also, but \\\\bigsrv alone doesn't work. - */ - std::string basename(const std::string& path, bool delsuffix =false); - -} // namespace Util - -#endif // #ifndef UTILS_HPP_ diff --git a/test/data/test_reference_files/exiv2-test.out b/test/data/test_reference_files/exiv2-test.out index ec42d606..6023f884 100644 --- a/test/data/test_reference_files/exiv2-test.out +++ b/test/data/test_reference_files/exiv2-test.out @@ -2223,72 +2223,72 @@ Warning: Directory Canon has an unexpected next pointer; ignored. Extract Exif data -------------------------------------------------------- File 1/16: exiv2-empty.jpg File 2/16: 20031214_000043.jpg -Writing Exif data from 20031214_000043.jpg to ./20031214_000043.exv +Writing Exif data from 20031214_000043.jpg to 20031214_000043.exv File 3/16: 20000506_020544.jpg -Writing Exif data from 20000506_020544.jpg to ./20000506_020544.exv +Writing Exif data from 20000506_020544.jpg to 20000506_020544.exv File 4/16: 20040329_224245.jpg -Writing Exif data from 20040329_224245.jpg to ./20040329_224245.exv +Writing Exif data from 20040329_224245.jpg to 20040329_224245.exv File 5/16: 20010405_235039.jpg -Writing Exif data from 20010405_235039.jpg to ./20010405_235039.exv +Writing Exif data from 20010405_235039.jpg to 20010405_235039.exv File 6/16: 20030925_201850.jpg -Writing Exif data from 20030925_201850.jpg to ./20030925_201850.exv +Writing Exif data from 20030925_201850.jpg to 20030925_201850.exv File 7/16: 20001026_044550.jpg -Writing Exif data from 20001026_044550.jpg to ./20001026_044550.exv -Writing JPEG comment from 20001026_044550.jpg to ./20001026_044550.exv +Writing Exif data from 20001026_044550.jpg to 20001026_044550.exv +Writing JPEG comment from 20001026_044550.jpg to 20001026_044550.exv File 8/16: 20030926_111535.jpg -Writing Exif data from 20030926_111535.jpg to ./20030926_111535.exv +Writing Exif data from 20030926_111535.jpg to 20030926_111535.exv File 9/16: 20040316_075137.jpg -Writing Exif data from 20040316_075137.jpg to ./20040316_075137.exv +Writing Exif data from 20040316_075137.jpg to 20040316_075137.exv File 10/16: 20040208_093744.jpg -Writing Exif data from 20040208_093744.jpg to ./20040208_093744.exv +Writing Exif data from 20040208_093744.jpg to 20040208_093744.exv File 11/16: 20050218_212016.jpg -Writing Exif data from 20050218_212016.jpg to ./20050218_212016.exv +Writing Exif data from 20050218_212016.jpg to 20050218_212016.exv File 12/16: 20050527_051833.jpg -Writing Exif data from 20050527_051833.jpg to ./20050527_051833.exv +Writing Exif data from 20050527_051833.jpg to 20050527_051833.exv File 13/16: 20060802_095200.jpg Warning: Directory Canon has an unexpected next pointer; ignored. -Writing Exif data from 20060802_095200.jpg to ./20060802_095200.exv +Writing Exif data from 20060802_095200.jpg to 20060802_095200.exv File 14/16: 20001004_015404.jpg -Writing Exif data from 20001004_015404.jpg to ./20001004_015404.exv +Writing Exif data from 20001004_015404.jpg to 20001004_015404.exv File 15/16: 20060127_225027.jpg -Writing Exif data from 20060127_225027.jpg to ./20060127_225027.exv +Writing Exif data from 20060127_225027.jpg to 20060127_225027.exv File 16/16: 20110626_213900.psd -Writing Exif data from 20110626_213900.psd to ./20110626_213900.exv -Writing IPTC data from 20110626_213900.psd to ./20110626_213900.exv -Writing XMP data from 20110626_213900.psd to ./20110626_213900.exv +Writing Exif data from 20110626_213900.psd to 20110626_213900.exv +Writing IPTC data from 20110626_213900.psd to 20110626_213900.exv +Writing XMP data from 20110626_213900.psd to 20110626_213900.exv Extract Thumbnail -------------------------------------------------------- File 1/16: exiv2-empty.jpg exiv2-empty.jpg: No Exif data found in the file File 2/16: 20031214_000043.jpg -Writing thumbnail (image/jpeg, 5448 Bytes) to file ./20031214_000043-thumb.jpg +Writing thumbnail (image/jpeg, 5448 Bytes) to file 20031214_000043-thumb.jpg File 3/16: 20000506_020544.jpg -Writing thumbnail (image/jpeg, 7829 Bytes) to file ./20000506_020544-thumb.jpg +Writing thumbnail (image/jpeg, 7829 Bytes) to file 20000506_020544-thumb.jpg File 4/16: 20040329_224245.jpg -Writing thumbnail (image/jpeg, 8930 Bytes) to file ./20040329_224245-thumb.jpg +Writing thumbnail (image/jpeg, 8930 Bytes) to file 20040329_224245-thumb.jpg File 5/16: 20010405_235039.jpg -Writing thumbnail (image/jpeg, 4662 Bytes) to file ./20010405_235039-thumb.jpg +Writing thumbnail (image/jpeg, 4662 Bytes) to file 20010405_235039-thumb.jpg File 6/16: 20030925_201850.jpg -Writing thumbnail (image/jpeg, 9728 Bytes) to file ./20030925_201850-thumb.jpg +Writing thumbnail (image/jpeg, 9728 Bytes) to file 20030925_201850-thumb.jpg File 7/16: 20001026_044550.jpg -Writing thumbnail (image/tiff, 20916 Bytes) to file ./20001026_044550-thumb.tif +Writing thumbnail (image/tiff, 20916 Bytes) to file 20001026_044550-thumb.tif File 8/16: 20030926_111535.jpg -Writing thumbnail (image/jpeg, 9573 Bytes) to file ./20030926_111535-thumb.jpg +Writing thumbnail (image/jpeg, 9573 Bytes) to file 20030926_111535-thumb.jpg File 9/16: 20040316_075137.jpg -Writing thumbnail (image/jpeg, 11998 Bytes) to file ./20040316_075137-thumb.jpg +Writing thumbnail (image/jpeg, 11998 Bytes) to file 20040316_075137-thumb.jpg File 10/16: 20040208_093744.jpg -Writing thumbnail (image/jpeg, 7306 Bytes) to file ./20040208_093744-thumb.jpg +Writing thumbnail (image/jpeg, 7306 Bytes) to file 20040208_093744-thumb.jpg File 11/16: 20050218_212016.jpg -Writing thumbnail (image/jpeg, 10308 Bytes) to file ./20050218_212016-thumb.jpg +Writing thumbnail (image/jpeg, 10308 Bytes) to file 20050218_212016-thumb.jpg File 12/16: 20050527_051833.jpg -Writing thumbnail (image/jpeg, 15605 Bytes) to file ./20050527_051833-thumb.jpg +Writing thumbnail (image/jpeg, 15605 Bytes) to file 20050527_051833-thumb.jpg File 13/16: 20060802_095200.jpg Warning: Directory Canon has an unexpected next pointer; ignored. -Writing thumbnail (image/jpeg, 6260 Bytes) to file ./20060802_095200-thumb.jpg +Writing thumbnail (image/jpeg, 6260 Bytes) to file 20060802_095200-thumb.jpg File 14/16: 20001004_015404.jpg -Writing thumbnail (image/jpeg, 13824 Bytes) to file ./20001004_015404-thumb.jpg +Writing thumbnail (image/jpeg, 13824 Bytes) to file 20001004_015404-thumb.jpg File 15/16: 20060127_225027.jpg -Writing thumbnail (image/jpeg, 6137 Bytes) to file ./20060127_225027-thumb.jpg +Writing thumbnail (image/jpeg, 6137 Bytes) to file 20060127_225027-thumb.jpg File 16/16: 20110626_213900.psd 20110626_213900.psd: Exif data doesn't contain a thumbnail exiv2-empty.exv: No Exif data found in the file @@ -5623,38 +5623,38 @@ File 16/16: 20110626_213900.psd Insert Exif data --------------------------------------------------------- File 1/16: exiv2-empty.jpg File 2/16: 20031214_000043.jpg -Writing Exif data from ./20031214_000043.exv to 20031214_000043.jpg +Writing Exif data from 20031214_000043.exv to 20031214_000043.jpg File 3/16: 20000506_020544.jpg -Writing Exif data from ./20000506_020544.exv to 20000506_020544.jpg +Writing Exif data from 20000506_020544.exv to 20000506_020544.jpg File 4/16: 20040329_224245.jpg -Writing Exif data from ./20040329_224245.exv to 20040329_224245.jpg +Writing Exif data from 20040329_224245.exv to 20040329_224245.jpg File 5/16: 20010405_235039.jpg -Writing Exif data from ./20010405_235039.exv to 20010405_235039.jpg +Writing Exif data from 20010405_235039.exv to 20010405_235039.jpg File 6/16: 20030925_201850.jpg -Writing Exif data from ./20030925_201850.exv to 20030925_201850.jpg +Writing Exif data from 20030925_201850.exv to 20030925_201850.jpg File 7/16: 20001026_044550.jpg -Writing Exif data from ./20001026_044550.exv to 20001026_044550.jpg -Writing JPEG comment from ./20001026_044550.exv to 20001026_044550.jpg +Writing Exif data from 20001026_044550.exv to 20001026_044550.jpg +Writing JPEG comment from 20001026_044550.exv to 20001026_044550.jpg File 8/16: 20030926_111535.jpg -Writing Exif data from ./20030926_111535.exv to 20030926_111535.jpg +Writing Exif data from 20030926_111535.exv to 20030926_111535.jpg File 9/16: 20040316_075137.jpg -Writing Exif data from ./20040316_075137.exv to 20040316_075137.jpg +Writing Exif data from 20040316_075137.exv to 20040316_075137.jpg File 10/16: 20040208_093744.jpg -Writing Exif data from ./20040208_093744.exv to 20040208_093744.jpg +Writing Exif data from 20040208_093744.exv to 20040208_093744.jpg File 11/16: 20050218_212016.jpg -Writing Exif data from ./20050218_212016.exv to 20050218_212016.jpg +Writing Exif data from 20050218_212016.exv to 20050218_212016.jpg File 12/16: 20050527_051833.jpg -Writing Exif data from ./20050527_051833.exv to 20050527_051833.jpg +Writing Exif data from 20050527_051833.exv to 20050527_051833.jpg File 13/16: 20060802_095200.jpg -Writing Exif data from ./20060802_095200.exv to 20060802_095200.jpg +Writing Exif data from 20060802_095200.exv to 20060802_095200.jpg File 14/16: 20001004_015404.jpg -Writing Exif data from ./20001004_015404.exv to 20001004_015404.jpg +Writing Exif data from 20001004_015404.exv to 20001004_015404.jpg File 15/16: 20060127_225027.jpg -Writing Exif data from ./20060127_225027.exv to 20060127_225027.jpg +Writing Exif data from 20060127_225027.exv to 20060127_225027.jpg File 16/16: 20110626_213900.psd -Writing Exif data from ./20110626_213900.exv to 20110626_213900.psd -Writing IPTC data from ./20110626_213900.exv to 20110626_213900.psd -Writing XMP data from ./20110626_213900.exv to 20110626_213900.psd +Writing Exif data from 20110626_213900.exv to 20110626_213900.psd +Writing IPTC data from 20110626_213900.exv to 20110626_213900.psd +Writing XMP data from 20110626_213900.exv to 20110626_213900.psd exiv2-empty.exv: No Exif data found in the file Compare original and inserted image data --------------------------------- diff --git a/unitTests/CMakeLists.txt b/unitTests/CMakeLists.txt index 704d84a0..ca0372fa 100644 --- a/unitTests/CMakeLists.txt +++ b/unitTests/CMakeLists.txt @@ -21,7 +21,6 @@ add_executable(unit_tests test_tiffheader.cpp test_types.cpp test_TimeValue.cpp - test_utils.cpp test_XmpKey.cpp $ ) diff --git a/unitTests/test_utils.cpp b/unitTests/test_utils.cpp deleted file mode 100644 index c04f655b..00000000 --- a/unitTests/test_utils.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include - -// Auxiliary headers - -#include - -namespace { - const std::string pathLinux("/home/luis/file.txt"); - const std::string pathWindows("c:/luis/file.txt"); -} - -#ifdef _WIN32 - -TEST(dirname, returnsDirNameWithValidPathOnWindows) -{ - ASSERT_EQ("c:\\luis", Util::dirname(pathWindows)); -} -TEST(basename, returnsStemWithExtensionWithValidPathOnWindows) -{ - const bool delSuffix = false; - ASSERT_EQ("file.txt", Util::basename(pathWindows, delSuffix)); -} - -TEST(basename, returnsStemWithoutExtensionWithValidPathOnWindows) -{ - const bool delSuffix = true; - ASSERT_EQ("file", Util::basename(pathWindows, delSuffix)); -} - -#else - -TEST(dirname, returnsDirNameWithValidPathOnLinux) -{ - ASSERT_EQ("/home/luis", Util::dirname(pathLinux)); - ASSERT_EQ("/tmp", Util::dirname("/tmp/file.jpg")); -} - - -TEST(dirname, returnsDotWithRelativePath) -{ - ASSERT_EQ(".", Util::dirname("file.txt")); -} - -TEST(dirname, returnsDotEmptyString) -{ - ASSERT_EQ(".", Util::dirname("")); -} - -/// \bug the logic for delsuffix is actually reverted -TEST(basename, returnsStemWithExtensionWithValidPathOnLinux) -{ - const bool delSuffix = false; - ASSERT_EQ("file.txt", Util::basename(pathLinux, delSuffix)); -} - -TEST(basename, returnsStemWithoutExtensionWithValidPathOnLinux) -{ - const bool delSuffix = true; - ASSERT_EQ("file", Util::basename(pathLinux, delSuffix)); -} - -#endif