From cab745d661a1bd57c97a5942156882c31b5a6b1b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Peter=20K=C3=BCmmel?= Date: Sun, 5 Oct 2008 11:51:18 +0000 Subject: [PATCH] Fix bug 2235: jpeg capital letters (.JPG) does not work with pdflatex git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26744 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetGraphics.cpp | 2 +- src/support/FileName.cpp | 18 +++++++++++++++++- src/support/FileName.h | 3 +++ src/support/os.h | 3 +++ src/support/os_cygwin.cpp | 7 +++++++ src/support/os_unix.cpp | 10 ++++++++++ src/support/os_win32.cpp | 6 ++++++ 7 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp index f7c55eab2f..28ea68f7d1 100644 --- a/src/insets/InsetGraphics.cpp +++ b/src/insets/InsetGraphics.cpp @@ -668,7 +668,7 @@ string InsetGraphics::prepareFile(OutputParams const & runparams) const LYXERR(Debug::GRAPHICS, "\tthe orig file is: " << orig_file); if (from == to) { - if (!runparams.nice && getExtension(temp_file.absFilename()) != ext) { + if (!runparams.nice && !FileName(temp_file).hasExtension(ext)) { // The LaTeX compiler will not be able to determine // the file format from the extension, so we must // change it. diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp index f101bba892..8e51a4a92e 100644 --- a/src/support/FileName.cpp +++ b/src/support/FileName.cpp @@ -121,6 +121,14 @@ struct FileName::Private #endif } + + static + bool isFilesystemEqual(QString const & lhs, QString const & rhs) + { + return QString::compare(lhs, rhs, os::isFilesystemCaseSensitive() ? + Qt::CaseSensitive : Qt::CaseInsensitive) == 0; + } + /// QFileInfo fi; }; @@ -323,6 +331,12 @@ string FileName::extension() const } +bool FileName::hasExtension(const string & ext) +{ + return Private::isFilesystemEqual(d->fi.suffix(), toqstr(ext)); +} + + FileName FileName::onlyPath() const { FileName path; @@ -920,8 +934,10 @@ bool operator==(FileName const & lhs, FileName const & rhs) lhs.d->refresh(); rhs.d->refresh(); - if (!lhs.d->fi.isSymLink() && !rhs.d->fi.isSymLink()) + if (!lhs.d->fi.isSymLink() && !rhs.d->fi.isSymLink()) { + // Qt already checks if the filesystem is case sensitive or not. return lhs.d->fi == rhs.d->fi; + } // FIXME: When/if QFileInfo support symlink comparison, remove this code. QFileInfo fi1(lhs.d->fi); diff --git a/src/support/FileName.h b/src/support/FileName.h index 1c020c898f..26d0179d19 100644 --- a/src/support/FileName.h +++ b/src/support/FileName.h @@ -174,6 +174,9 @@ public: std::string onlyFileNameWithoutExt() const; /// only extension after the last dot. std::string extension() const; + /** checks if the file has the given extension + on Windows and Mac it compares case insensitive */ + bool hasExtension(const std::string & ext); /// path without file name FileName onlyPath() const; /// used for display in the Gui diff --git a/src/support/os.h b/src/support/os.h index 2d41dd7626..35fa2aa613 100644 --- a/src/support/os.h +++ b/src/support/os.h @@ -42,6 +42,9 @@ shell_type shell(); /// Name of the python interpreter std::string const python(); +/// +bool isFilesystemCaseSensitive(); + /// Extract the path common to both @c p1 and @c p2. DBCS aware! /// \p p1, \p p2 and the return value are encoded in utf8. std::size_t common_path(docstring const & p1, docstring const & p2); diff --git a/src/support/os_cygwin.cpp b/src/support/os_cygwin.cpp index f13d25c37b..032aae7f13 100644 --- a/src/support/os_cygwin.cpp +++ b/src/support/os_cygwin.cpp @@ -138,6 +138,13 @@ string current_root() } +bool isFilesystemCaseSensitive() +{ + // FIXME: is this correct? + return true; +} + + docstring::size_type common_path(docstring const & p1, docstring const & p2) { docstring::size_type i = 0; diff --git a/src/support/os_unix.cpp b/src/support/os_unix.cpp index 50701eaeb1..4c774fc82b 100644 --- a/src/support/os_unix.cpp +++ b/src/support/os_unix.cpp @@ -36,6 +36,16 @@ string current_root() } +bool isFilesystemCaseSensitive() +{ +#ifdef __APPLE__ + return false: +#else + return true; +#endif +} + + docstring::size_type common_path(docstring const & p1, docstring const & p2) { docstring::size_type i = 0; diff --git a/src/support/os_win32.cpp b/src/support/os_win32.cpp index 1522486704..fe7878a16f 100644 --- a/src/support/os_win32.cpp +++ b/src/support/os_win32.cpp @@ -172,6 +172,12 @@ string current_root() } +bool isFilesystemCaseSensitive() +{ + return false; +} + + docstring::size_type common_path(docstring const & p1, docstring const & p2) { size_t i = 0; -- 2.39.2