summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfile.h
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-05-14 15:43:57 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-15 04:57:29 +0200
commit57c755fef00c8269b083817228f046e4d950a580 (patch)
tree1d1ecdc34e6461754c41549ff5dd5e56ebc93ed7 /src/corelib/io/qfile.h
parente5f77fe31be0ea2c891eacd3e866bb9db4e0a238 (diff)
Deprecate the ability to change the FS encoding separate from the locale
Changing the encoding used by filenames separately from the locale encoding is a broken concept and cannot work properly. This creates ambiguity depending on the data source and how it's being treated. Instead, enforce that the locale encoding is the only possibility to deal with file names. The QFile::encodeName and decodeName functions are retained due to the Mac-specific issues and due to the sheer number of current uses. There's no point in deprecating them and moving away from them. Change-Id: Iedb2d8715d166a59a824f05bc11d107fd44f9c17 Discussed-on: http://lists.qt-project.org/pipermail/development/2012-May/003782.html Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/io/qfile.h')
-rw-r--r--src/corelib/io/qfile.h33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/corelib/io/qfile.h b/src/corelib/io/qfile.h
index 0ee8f39d95..565701befb 100644
--- a/src/corelib/io/qfile.h
+++ b/src/corelib/io/qfile.h
@@ -76,14 +76,35 @@ public:
QString fileName() const;
void setFileName(const QString &name);
- typedef QByteArray (*EncoderFn)(const QString &fileName);
- typedef QString (*DecoderFn)(const QByteArray &localfileName);
- static QByteArray encodeName(const QString &fileName);
- static QString decodeName(const QByteArray &localFileName);
+#if defined(Q_OS_DARWIN)
+ // Mac always expects filenames in UTF-8... and decomposed...
+ static inline QByteArray encodeName(const QString &fileName)
+ {
+ return fileName.normalized(QString::NormalizationForm_D).toUtf8();
+ }
+ static QString decodeName(const QByteArray &localFileName)
+ {
+ return QString::fromUtf8(localFileName).normalized(QString::NormalizationForm_C);
+ }
+#else
+ static inline QByteArray encodeName(const QString &fileName)
+ {
+ return fileName.toLocal8Bit();
+ }
+ static QString decodeName(const QByteArray &localFileName)
+ {
+ return QString::fromLocal8Bit(localFileName);
+ }
+#endif
inline static QString decodeName(const char *localFileName)
{ return decodeName(QByteArray(localFileName)); }
- static void setEncodingFunction(EncoderFn);
- static void setDecodingFunction(DecoderFn);
+
+#if QT_DEPRECATED_SINCE(5,0)
+ typedef QByteArray (*EncoderFn)(const QString &fileName);
+ typedef QString (*DecoderFn)(const QByteArray &localfileName);
+ QT_DEPRECATED static void setEncodingFunction(EncoderFn) {}
+ QT_DEPRECATED static void setDecodingFunction(DecoderFn) {}
+#endif
bool exists() const;
static bool exists(const QString &fileName);