summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Zander <t.zander@nokia.com>2010-09-03 07:37:14 (GMT)
committerThomas Zander <t.zander@nokia.com>2010-09-03 07:37:14 (GMT)
commite6747da757b4daba1fc17db9902a9c39b426455f (patch)
treebcb2712a4d57fe7669bcb673f937ce7a5aaed1bd
parentc7784c70b865792a5f09fc83e9a50cc327864a22 (diff)
downloadQt-e6747da757b4daba1fc17db9902a9c39b426455f.zip
Qt-e6747da757b4daba1fc17db9902a9c39b426455f.tar.gz
Qt-e6747da757b4daba1fc17db9902a9c39b426455f.tar.bz2
Move mkdir code to createDirectory for unix'
migrate the QFSFileEngine::mkdir code to QFileSystemEngine::createDirectory and make the former call the latter. Reviewed-by: João Abecasis
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp33
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp32
2 files changed, 33 insertions, 32 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 4b1932d..469abfe 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qfilesystemengine_p.h"
+#include "qplatformdefs.h"
#include "qfsfileengine.h"
#include <stdlib.h> // for realpath()
@@ -165,7 +166,37 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
//static
bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool createParents)
{
- return false; // TODO implement;
+ QString dirName = entry.filePath();
+ if (createParents) {
+ dirName = QDir::cleanPath(dirName);
+#if defined(Q_OS_SYMBIAN)
+ dirName = QDir::toNativeSeparators(dirName);
+#endif
+ for (int oldslash = -1, slash=0; slash != -1; oldslash = slash) {
+ slash = dirName.indexOf(QDir::separator(), oldslash+1);
+ if (slash == -1) {
+ if (oldslash == dirName.length())
+ break;
+ slash = dirName.length();
+ }
+ if (slash) {
+ QByteArray chunk = QFile::encodeName(dirName.left(slash));
+ QT_STATBUF st;
+ if (QT_STAT(chunk, &st) != -1) {
+ if ((st.st_mode & S_IFMT) != S_IFDIR)
+ return false;
+ } else if (QT_MKDIR(chunk, 0777) != 0) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+#if defined(Q_OS_DARWIN) // Mac X doesn't support trailing /'s
+ if (dirName.endsWith(QLatin1Char('/')))
+ dirName.chop(1);
+#endif
+ return (QT_MKDIR(QFile::encodeName(dirName), 0777) == 0);
}
//static
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index 9ca195b..c20d6ae 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -492,37 +492,7 @@ qint64 QFSFileEnginePrivate::nativeSize() const
bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories) const
{
- QString dirName = name;
- if (createParentDirectories) {
- dirName = QDir::cleanPath(dirName);
-#if defined(Q_OS_SYMBIAN)
- dirName = QDir::toNativeSeparators(dirName);
-#endif
- for(int oldslash = -1, slash=0; slash != -1; oldslash = slash) {
- slash = dirName.indexOf(QDir::separator(), oldslash+1);
- if (slash == -1) {
- if (oldslash == dirName.length())
- break;
- slash = dirName.length();
- }
- if (slash) {
- QByteArray chunk = QFile::encodeName(dirName.left(slash));
- QT_STATBUF st;
- if (QT_STAT(chunk, &st) != -1) {
- if ((st.st_mode & S_IFMT) != S_IFDIR)
- return false;
- } else if (QT_MKDIR(chunk, 0777) != 0) {
- return false;
- }
- }
- }
- return true;
- }
-#if defined(Q_OS_DARWIN) // Mac X doesn't support trailing /'s
- if (dirName.endsWith(QLatin1Char('/')))
- dirName.chop(1);
-#endif
- return (QT_MKDIR(QFile::encodeName(dirName), 0777) == 0);
+ return QFileSystemEngine::createDirectory(QFileSystemEntry(name), createParentDirectories);
}
bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) const