69 lines
1.9 KiB
Text
69 lines
1.9 KiB
Text
$NetBSD: patch-ac,v 1.4 2003/03/18 08:36:25 skrll Exp $
|
|
|
|
--- src/tools/qdir_unix.cpp.orig Mon Dec 9 22:40:32 2002
|
|
+++ src/tools/qdir_unix.cpp
|
|
@@ -36,6 +36,16 @@
|
|
**********************************************************************/
|
|
|
|
#include "qplatformdefs.h"
|
|
+
|
|
+#ifdef Q_TRAILING_DIR_SEP // Some OSes doesn't support trailing /'s
|
|
+
|
|
+// POSIX Large File Support redefines truncate -> truncate64
|
|
+#if defined(truncate)
|
|
+# undef truncate
|
|
+#endif
|
|
+
|
|
+#endif
|
|
+
|
|
#include "qdir.h"
|
|
|
|
#ifndef QT_NO_DIR
|
|
@@ -86,10 +96,19 @@
|
|
|
|
bool QDir::mkdir( const QString &dirName, bool acceptAbsPath ) const
|
|
{
|
|
-#if defined(Q_OS_MACX) // Mac X doesn't support trailing /'s
|
|
+#ifdef Q_TRAILING_DIR_SEP // Some OSes doesn't support trailing /'s
|
|
QString name = dirName;
|
|
- if (dirName[dirName.length() - 1] == "/")
|
|
- name = dirName.left( dirName.length() - 1 );
|
|
+ int pos = name.length();
|
|
+ if (pos > 0) {
|
|
+ while ( (pos - 1) >= 0 && name[pos - 1] == '/' ) {
|
|
+ --pos;
|
|
+ };
|
|
+ if ( pos == 0 ) {
|
|
+ name = QDir::rootDirPath();
|
|
+ } else {
|
|
+ name.truncate( pos );
|
|
+ }
|
|
+ }
|
|
int status =
|
|
::mkdir( QFile::encodeName(filePath(name,acceptAbsPath)), 0777 );
|
|
#else
|
|
@@ -101,7 +120,24 @@ bool QDir::mkdir( const QString &dirName
|
|
|
|
bool QDir::rmdir( const QString &dirName, bool acceptAbsPath ) const
|
|
{
|
|
+#ifdef Q_TRAILING_DIR_SEP // Some OSes doesn't support trailing /'s
|
|
+ QString name = dirName;
|
|
+ int pos = name.length();
|
|
+ if (pos > 0) {
|
|
+ while ( (pos - 1) >= 0 && name[pos - 1] == '/' ) {
|
|
+ --pos;
|
|
+ };
|
|
+ if ( pos == 0 ) {
|
|
+ name = QDir::rootDirPath();
|
|
+ } else {
|
|
+ name.truncate( pos );
|
|
+ }
|
|
+ }
|
|
+ return ::rmdir( QFile::encodeName(filePath(name,acceptAbsPath)) )
|
|
+ == 0;
|
|
+#else
|
|
return ::rmdir( QFile::encodeName(filePath(dirName,acceptAbsPath)) ) == 0;
|
|
+#endif
|
|
}
|
|
|
|
bool QDir::isReadable() const
|