]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/tests/testdir.cpp
Exit the deleted directory when it is removed
[dolphin.git] / src / tests / testdir.cpp
index 29bb3ad78fb61f75473663fc223c705d0fc353a0..6fbc4c426aa69df2c1dbf2420820aece02ae1315 100644 (file)
@@ -31,12 +31,12 @@ static void setTimeStamp(const QString& path, const QDateTime& mtime)
 {
 #ifdef Q_OS_UNIX
     struct utimbuf utbuf;
-    utbuf.actime = mtime.toTime_t();
+    utbuf.actime = mtime.toSecsSinceEpoch();
     utbuf.modtime = utbuf.actime;
     utime(QFile::encodeName(path), &utbuf);
 #elif defined(Q_OS_WIN)
     struct _utimbuf utbuf;
-    utbuf.actime = mtime.toTime_t();
+    utbuf.actime = mtime.toSecsSinceEpoch();
     utbuf.modtime = utbuf.actime;
     _wutime(reinterpret_cast<const wchar_t *>(path.utf16()), &utbuf);
 #endif
@@ -61,7 +61,7 @@ void TestDir::createFile(const QString& path, const QByteArray& data, const QDat
 
 void TestDir::createFiles(const QStringList& files)
 {
-    foreach (const QString& path, files) {
+    for (const QString& path : files) {
         createFile(path);
     }
 }
@@ -81,7 +81,7 @@ void TestDir::createDir(const QString& path, const QDateTime& time)
 
 void TestDir::removeFiles(const QStringList& files)
 {
-    foreach (const QString& path, files) {
+    for (const QString& path : files) {
         removeFile(path);
     }
 }
@@ -96,6 +96,17 @@ void TestDir::removeFile(const QString& path)
     QFile::remove(absolutePath);
 }
 
+void TestDir::removeDir(const QString& path)
+{
+    QString absolutePath = path;
+    QFileInfo fileInfo(absolutePath);
+    if (!fileInfo.isAbsolute()) {
+        absolutePath = TestDir::path() + QLatin1Char('/') + path;
+    }
+    QDir dirToRemove = QDir(absolutePath);
+    dirToRemove.removeRecursively();
+}
+
 void TestDir::makePathAbsoluteAndCreateParents(QString& path)
 {
     QFileInfo fileInfo(path);