@@ -75,8 +75,10 @@ CPPDEVTK_UTIL_API bool IsValidPath(const QString& path, bool ignorePathSeparator
75
75
return false ;
76
76
}
77
77
if (path.contains (' \? ' )) {
78
- CPPDEVTK_LOG_ERROR (" path '" << path << " ' contains invalid character ?" );
79
- return false ;
78
+ if (!path.startsWith (" //?/" ) || (path.count (' ?' ) > 1 )) {
79
+ CPPDEVTK_LOG_ERROR (" path '" << path << " ' contains invalid character ?" );
80
+ return false ;
81
+ }
80
82
}
81
83
if (path.contains (' *' )) {
82
84
CPPDEVTK_LOG_ERROR (" path '" << path << " ' contains invalid character *" );
@@ -94,6 +96,7 @@ CPPDEVTK_UTIL_API bool IsValidPath(const QString& path, bool ignorePathSeparator
94
96
}
95
97
*/
96
98
99
+ /*
97
100
int cnt = path.count(':');
98
101
if (cnt > 1) {
99
102
CPPDEVTK_LOG_ERROR("path '" << path << "' contains invalid character :");
@@ -110,6 +113,7 @@ CPPDEVTK_UTIL_API bool IsValidPath(const QString& path, bool ignorePathSeparator
110
113
return false;
111
114
}
112
115
}
116
+ */
113
117
114
118
return ignorePathSeparator ? true : !path.contains (' /' );
115
119
}
@@ -120,7 +124,9 @@ CPPDEVTK_UTIL_API void DeleteFile(const QString& fileName, bool failIfNotExists)
120
124
QString nativeFileName = QDir::toNativeSeparators (fileName);
121
125
# if (!CPPDEVTK_DISABLE_UNICODE)
122
126
if (QDir::isAbsolutePath (fileName)) {
123
- nativeFileName.prepend (" \\\\ ?\\ " );
127
+ if (!nativeFileName.startsWith (" \\\\ ?\\ " )) {
128
+ nativeFileName.prepend (" \\\\ ?\\ " );
129
+ }
124
130
}
125
131
# endif
126
132
@@ -179,14 +185,18 @@ CPPDEVTK_UTIL_API void CopyFile(const QString& srcFileName, const QString& dstFi
179
185
QString nativeSrcFileName = QDir::toNativeSeparators (srcFileName);
180
186
# if (!CPPDEVTK_DISABLE_UNICODE)
181
187
if (QDir::isAbsolutePath (srcFileName)) {
182
- nativeSrcFileName.prepend (" \\\\ ?\\ " );
188
+ if (!nativeSrcFileName.startsWith (" \\\\ ?\\ " )) {
189
+ nativeSrcFileName.prepend (" \\\\ ?\\ " );
190
+ }
183
191
}
184
192
# endif
185
193
186
194
QString nativeDstFileName = QDir::toNativeSeparators (dstFileName);
187
195
# if (!CPPDEVTK_DISABLE_UNICODE)
188
196
if (QDir::isAbsolutePath (dstFileName)) {
189
- nativeDstFileName.prepend (" \\\\ ?\\ " );
197
+ if (!nativeDstFileName.startsWith (" \\\\ ?\\ " )) {
198
+ nativeDstFileName.prepend (" \\\\ ?\\ " );
199
+ }
190
200
}
191
201
# endif
192
202
@@ -237,7 +247,9 @@ CPPDEVTK_UTIL_API void MakeDirectory(const QString& dirName, bool failIfExists)
237
247
QString nativeDirName = QDir::toNativeSeparators (dirName);
238
248
# if (!CPPDEVTK_DISABLE_UNICODE)
239
249
if (QDir::isAbsolutePath (dirName)) {
240
- nativeDirName.prepend (" \\\\ ?\\ " );
250
+ if (!nativeDirName.startsWith (" \\\\ ?\\ " )) {
251
+ nativeDirName.prepend (" \\\\ ?\\ " );
252
+ }
241
253
}
242
254
# endif
243
255
@@ -292,7 +304,9 @@ CPPDEVTK_UTIL_API void RemoveDirectory(const QString& path, bool failIfNotExists
292
304
QString nativePath = QDir::toNativeSeparators (path);
293
305
# if (!CPPDEVTK_DISABLE_UNICODE)
294
306
if (QDir::isAbsolutePath (path)) {
295
- nativePath.prepend (" \\\\ ?\\ " );
307
+ if (!nativePath.startsWith (" \\\\ ?\\ " )) {
308
+ nativePath.prepend (" \\\\ ?\\ " );
309
+ }
296
310
}
297
311
# endif
298
312
@@ -351,7 +365,9 @@ CPPDEVTK_UTIL_API void GetFileSystemSpaceInfo(const QString& path, FileSystemSpa
351
365
352
366
QString nativeDirAbsPath = QDir::toNativeSeparators (QFileInfo (path).absolutePath ());
353
367
# if (!CPPDEVTK_DISABLE_UNICODE)
354
- nativeDirAbsPath.prepend (" \\\\ ?\\ " );
368
+ if (!nativeDirAbsPath.startsWith (" \\\\ ?\\ " )) {
369
+ nativeDirAbsPath.prepend (" \\\\ ?\\ " );
370
+ }
355
371
# endif
356
372
357
373
if (!GetDiskFreeSpaceEx (CPPDEVTK_Q2T (nativeDirAbsPath).c_str (), &freeBytesAvailable, &totalNumberOfBytes,
0 commit comments