Abdelrazak Younes wrote:
On 04/10/2008 21:06, Peter Kümmel wrote:
Andre Poenitz wrote:
On Sat, Oct 04, 2008 at 07:30:46PM +0200, Peter Kümmel wrote:
Here a patch for
http://bugzilla.lyx.org/show_bug.cgi?id=2235

Is there a better way to detect case sensitiveness
of the file actual system?

I don't know, but Mac's file system seems to be case-insensitive as well.
Also, instead of toLower(), QString::compare(..., Qt::CaseInsensitive)
seems preferable.

Are the filenames simply utf8 encoded?

Yes, but please use (or extend) already existing FileName::operator==()

I only need to check the extension.

Peter
Index: insets/InsetGraphics.cpp
===================================================================
--- insets/InsetGraphics.cpp    (revision 26732)
+++ insets/InsetGraphics.cpp    (working copy)
@@ -668,7 +668,7 @@
        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.
Index: support/FileName.cpp
===================================================================
--- support/FileName.cpp        (revision 26732)
+++ support/FileName.cpp        (working copy)
@@ -323,6 +323,18 @@
 }
 
 
+bool FileName::hasExtension(const string & ext)
+{
+       return QString::compare(d->fi.suffix(), toqstr(ext),
+#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
+                       Qt::CaseInsensitive
+#else
+                       Qt::CaseSensitive
+#endif
+                       ) == 0;
+}
+
+
 FileName FileName::onlyPath() const
 {
        FileName path;
Index: support/FileName.h
===================================================================
--- support/FileName.h  (revision 26732)
+++ support/FileName.h  (working copy)
@@ -174,6 +174,9 @@
        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

Reply via email to