summaryrefslogtreecommitdiff
path: root/x11/qt3-libs/patches/patch-ac
blob: f7925f7a14aeb36e312a5d18d4861bf851fe6be5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
$NetBSD: patch-ac,v 1.6 2009/04/07 10:59:48 hasso Exp $

--- src/tools/qdir_unix.cpp.orig	2007-02-02 16:01:05 +0200
+++ src/tools/qdir_unix.cpp	2009-04-07 13:10:26 +0300
@@ -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
@@ -53,6 +63,9 @@
 #include <limits.h>
 #include <errno.h>
 
+#ifndef MAXNAMLEN
+#define MAXNAMLEN NAME_MAX
+#endif
 
 void QDir::slashify( QString& )
 {
@@ -88,10 +101,19 @@ QString QDir::canonicalPath() const
 
 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
@@ -103,7 +125,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