Qt 4.8
Classes | Macros | Typedefs | Functions | Variables
qfilesystemengine_win.cpp File Reference
#include "qfilesystemengine_p.h"
#include "qplatformdefs.h"
#include "qabstractfileengine.h"
#include "private/qfsfileengine_p.h"
#include <private/qsystemlibrary_p.h>
#include <qdebug.h>
#include "qfile.h"
#include "qdir.h"
#include "private/qmutexpool_p.h"
#include "qvarlengtharray.h"
#include "qdatetime.h"
#include "qt_windows.h"
#include <types.h>
#include <objbase.h>
#include <shlobj.h>
#include <initguid.h>
#include <accctrl.h>
#include <ctype.h>
#include <limits.h>
#include <security.h>

Go to the source code of this file.

Classes

struct  _SHARE_INFO_1
 

Macros

#define _INTPTR_T_DEFINED
 
#define _POSIX_
 
#define INVALID_FILE_ATTRIBUTES   (DWORD (-1))
 
#define PATH_MAX   FILENAME_MAX
 
#define QT_NO_LIBRARY   1
 
#define SECURITY_WIN32
 
#define SPI_GETPLATFORMTYPE   257
 

Typedefs

typedef INT_PTR intptr_t
 
typedef DWORD(WINAPI * PtrNetApiBufferFree) (LPVOID)
 
typedef DWORD(WINAPI * PtrNetShareEnum) (LPWSTR, DWORD, LPBYTE *, DWORD, LPDWORD, LPDWORD, LPDWORD)
 
typedef struct _SHARE_INFO_1 SHARE_INFO_1
 

Functions

static QDateTime fileTimeToQDateTime (const FILETIME *time)
 
static bool getFindData (QString path, WIN32_FIND_DATA &findData)
 
static bool isDirPath (const QString &dirPath, bool *existed)
 
static bool mkDir (const QString &path)
 
static QString readLink (const QFileSystemEntry &link)
 
static QString readSymLink (const QFileSystemEntry &link)
 
static bool resolveUNCLibs ()
 
static bool rmDir (const QString &path)
 
static bool tryDriveUNCFallback (const QFileSystemEntry &fname, QFileSystemMetaData &data)
 
static bool tryFindFallback (const QFileSystemEntry &fname, QFileSystemMetaData &data)
 
static bool uncShareExists (const QString &server)
 

Variables

static PtrNetApiBufferFree ptrNetApiBufferFree = 0
 
static PtrNetShareEnum ptrNetShareEnum = 0
 
static QString qfsPrivateCurrentDir = QLatin1String("")
 
Q_CORE_EXPORT int qt_ntfs_permission_lookup = 0
 

Macro Definition Documentation

◆ _INTPTR_T_DEFINED

#define _INTPTR_T_DEFINED

Definition at line 92 of file qfilesystemengine_win.cpp.

◆ _POSIX_

#define _POSIX_

Definition at line 44 of file qfilesystemengine_win.cpp.

◆ INVALID_FILE_ATTRIBUTES

#define INVALID_FILE_ATTRIBUTES   (DWORD (-1))

Definition at line 96 of file qfilesystemengine_win.cpp.

Referenced by isDirPath(), and tryFindFallback().

◆ PATH_MAX

#define PATH_MAX   FILENAME_MAX

◆ QT_NO_LIBRARY

#define QT_NO_LIBRARY   1

Definition at line 148 of file qfilesystemengine_win.cpp.

◆ SECURITY_WIN32

#define SECURITY_WIN32

Definition at line 71 of file qfilesystemengine_win.cpp.

◆ SPI_GETPLATFORMTYPE

#define SPI_GETPLATFORMTYPE   257

Definition at line 75 of file qfilesystemengine_win.cpp.

Referenced by mkDir().

Typedef Documentation

◆ intptr_t

typedef INT_PTR intptr_t

Definition at line 89 of file qfilesystemengine_win.cpp.

◆ PtrNetApiBufferFree

typedef DWORD(WINAPI * PtrNetApiBufferFree) (LPVOID)

Definition at line 272 of file qfilesystemengine_win.cpp.

◆ PtrNetShareEnum

typedef DWORD(WINAPI * PtrNetShareEnum) (LPWSTR, DWORD, LPBYTE *, DWORD, LPDWORD, LPDWORD, LPDWORD)

Definition at line 270 of file qfilesystemengine_win.cpp.

◆ SHARE_INFO_1

typedef struct _SHARE_INFO_1 SHARE_INFO_1

Function Documentation

◆ fileTimeToQDateTime()

static QDateTime fileTimeToQDateTime ( const FILETIME *  time)
inlinestatic

Definition at line 1208 of file qfilesystemengine_win.cpp.

Referenced by QFileSystemMetaData::accessTime(), QFileSystemMetaData::creationTime(), and QFileSystemMetaData::modificationTime().

1209 {
1210  QDateTime ret;
1211 
1212 #if defined(Q_OS_WINCE)
1213  SYSTEMTIME systime;
1214  FILETIME ftime;
1215  systime.wYear = 1970;
1216  systime.wMonth = 1;
1217  systime.wDay = 1;
1218  systime.wHour = 0;
1219  systime.wMinute = 0;
1220  systime.wSecond = 0;
1221  systime.wMilliseconds = 0;
1222  systime.wDayOfWeek = 4;
1223  SystemTimeToFileTime(&systime, &ftime);
1224  unsigned __int64 acttime = (unsigned __int64)time->dwHighDateTime << 32 | time->dwLowDateTime;
1225  FileTimeToSystemTime(time, &systime);
1226  unsigned __int64 time1970 = (unsigned __int64)ftime.dwHighDateTime << 32 | ftime.dwLowDateTime;
1227  unsigned __int64 difftime = acttime - time1970;
1228  difftime /= 10000000;
1229  ret.setTime_t((unsigned int)difftime);
1230 #else
1231  SYSTEMTIME sTime, lTime;
1232  FileTimeToSystemTime(time, &sTime);
1233  SystemTimeToTzSpecificLocalTime(0, &sTime, &lTime);
1234  ret.setDate(QDate(lTime.wYear, lTime.wMonth, lTime.wDay));
1235  ret.setTime(QTime(lTime.wHour, lTime.wMinute, lTime.wSecond, lTime.wMilliseconds));
1236 #endif
1237 
1238  return ret;
1239 }
The QDate class provides date functions.
Definition: qdatetime.h:55
The QTime class provides clock time functions.
Definition: qdatetime.h:148
void setTime_t(uint secsSince1Jan1970UTC)
Sets the date and time given the number of seconds that have passed since 1970-01-01T00:00:00, Coordinated Universal Time (Qt::UTC).
Definition: qdatetime.cpp:2566
void setDate(const QDate &date)
Sets the date part of this datetime to date.
Definition: qdatetime.cpp:2399
void setTime(const QTime &time)
Sets the time part of this datetime to time.
Definition: qdatetime.cpp:2416
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216

◆ getFindData()

static bool getFindData ( QString  path,
WIN32_FIND_DATA &  findData 
)
inlinestatic

Definition at line 427 of file qfilesystemengine_win.cpp.

Referenced by QFileSystemEngine::fillMetaData(), isDirPath(), and tryFindFallback().

428 {
429  // path should not end with a trailing slash
430  while (path.endsWith(QLatin1Char('\\')))
431  path.chop(1);
432 
433  // can't handle drives
434  if (!path.endsWith(QLatin1Char(':'))) {
435  HANDLE hFind = ::FindFirstFile((wchar_t*)path.utf16(), &findData);
436  if (hFind != INVALID_HANDLE_VALUE) {
437  ::FindClose(hFind);
438  return true;
439  }
440  }
441 
442  return false;
443 }
void chop(int n)
Removes n characters from the end of the string.
Definition: qstring.cpp:4623
void * HANDLE
Definition: qnamespace.h:1671
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
const ushort * utf16() const
Returns the QString as a &#39;\0\&#39;-terminated array of unsigned shorts.
Definition: qstring.cpp:5290

◆ isDirPath()

static bool isDirPath ( const QString dirPath,
bool *  existed 
)
static

Definition at line 921 of file qfilesystemengine_win.cpp.

Referenced by QFileSystemEngine::fillMetaData().

922 {
923  QString path = dirPath;
924  if (path.length() == 2 && path.at(1) == QLatin1Char(':'))
925  path += QLatin1Char('\\');
926 
927  DWORD fileAttrib = ::GetFileAttributes((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16());
928  if (fileAttrib == INVALID_FILE_ATTRIBUTES) {
929  int errorCode = GetLastError();
930  if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) {
931  WIN32_FIND_DATA findData;
932  if (getFindData(QFSFileEnginePrivate::longFileName(path), findData))
933  fileAttrib = findData.dwFileAttributes;
934  }
935  }
936 
937  if (existed)
938  *existed = fileAttrib != INVALID_FILE_ATTRIBUTES;
939 
940  if (fileAttrib == INVALID_FILE_ATTRIBUTES)
941  return false;
942 
943  return fileAttrib & FILE_ATTRIBUTE_DIRECTORY;
944 }
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString longFileName(const QString &path)
static bool getFindData(QString path, WIN32_FIND_DATA &findData)
#define INVALID_FILE_ATTRIBUTES
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ mkDir()

static bool mkDir ( const QString path)
inlinestatic

Definition at line 892 of file qfilesystemengine_win.cpp.

Referenced by isDirPath().

893 {
894 #if defined(Q_OS_WINCE)
895  // Unfortunately CreateDirectory returns true for paths longer than
896  // 256, but does not create a directory. It starts to fail, when
897  // path length > MAX_PATH, which is 260 usually on CE.
898  // This only happens on a Windows Mobile device. Windows CE seems
899  // not to be affected by this.
900  static int platformId = 0;
901  if (platformId == 0) {
902  wchar_t platformString[64];
903  if (SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(platformString)/sizeof(*platformString),platformString,0)) {
904  if (0 == wcscmp(platformString, L"PocketPC") || 0 == wcscmp(platformString, L"Smartphone"))
905  platformId = 1;
906  else
907  platformId = 2;
908  }
909  }
910  if (platformId == 1 && QFSFileEnginePrivate::longFileName(path).size() > 256)
911  return false;
912 #endif
913  return ::CreateDirectory((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16(), 0);
914 }
static QString longFileName(const QString &path)
#define SPI_GETPLATFORMTYPE

◆ readLink()

static QString readLink ( const QFileSystemEntry link)
static

Definition at line 358 of file qfilesystemengine_win.cpp.

Referenced by QFileSystemEngine::clearWinStatData(), QFile::decodeName(), QFileSystemEngine::fillMetaData(), QFileInfo::isAbsolute(), QFileInfo::symLinkTarget(), and QFile::symLinkTarget().

359 {
360 #if !defined(Q_OS_WINCE)
361 #if !defined(QT_NO_LIBRARY) && !defined(Q_CC_MWERKS)
362  QString ret;
363 
364  bool neededCoInit = false;
365  IShellLink *psl; // pointer to IShellLink i/f
366  WIN32_FIND_DATA wfd;
367  wchar_t szGotPath[MAX_PATH];
368 
369  // Get pointer to the IShellLink interface.
370  HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID *)&psl);
371 
372  if (hres == CO_E_NOTINITIALIZED) { // COM was not initialized
373  neededCoInit = true;
374  CoInitialize(NULL);
375  hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
376  IID_IShellLink, (LPVOID *)&psl);
377  }
378  if (SUCCEEDED(hres)) { // Get pointer to the IPersistFile interface.
379  IPersistFile *ppf;
380  hres = psl->QueryInterface(IID_IPersistFile, (LPVOID *)&ppf);
381  if (SUCCEEDED(hres)) {
382  hres = ppf->Load((LPOLESTR)link.nativeFilePath().utf16(), STGM_READ);
383  //The original path of the link is retrieved. If the file/folder
384  //was moved, the return value still have the old path.
385  if (SUCCEEDED(hres)) {
386  if (psl->GetPath(szGotPath, MAX_PATH, &wfd, SLGP_UNCPRIORITY) == NOERROR)
387  ret = QString::fromWCharArray(szGotPath);
388  }
389  ppf->Release();
390  }
391  psl->Release();
392  }
393  if (neededCoInit)
394  CoUninitialize();
395 
396  return ret;
397 #else
398  Q_UNUSED(link);
399  return QString();
400 #endif // QT_NO_LIBRARY
401 #else
402  wchar_t target[MAX_PATH];
403  QString result;
404  if (SHGetShortcutTarget((wchar_t*)QFileInfo(link.filePath()).absoluteFilePath().replace(QLatin1Char('/'),QLatin1Char('\\')).utf16(), target, MAX_PATH)) {
405  result = QString::fromWCharArray(target);
406  if (result.startsWith(QLatin1Char('"')))
407  result.remove(0,1);
408  if (result.endsWith(QLatin1Char('"')))
409  result.remove(result.size()-1,1);
410  }
411  return result;
412 #endif // Q_OS_WINCE
413 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define CoInitialize(x)
NativePath nativeFilePath() const
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
long HRESULT
QString filePath() const
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition: qstring.cpp:1867
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
const ushort * utf16() const
Returns the QString as a &#39;\0\&#39;-terminated array of unsigned shorts.
Definition: qstring.cpp:5290

◆ readSymLink()

static QString readSymLink ( const QFileSystemEntry link)
static

Definition at line 304 of file qfilesystemengine_win.cpp.

Referenced by QFileSystemEngine::clearWinStatData().

305 {
306  QString result;
307 #if !defined(Q_OS_WINCE)
308  HANDLE handle = CreateFile((wchar_t*)link.nativeFilePath().utf16(),
309  FILE_READ_EA,
310  FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
311  0,
312  OPEN_EXISTING,
313  FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT,
314  0);
315  if (handle != INVALID_HANDLE_VALUE) {
316  DWORD bufsize = MAXIMUM_REPARSE_DATA_BUFFER_SIZE;
317  REPARSE_DATA_BUFFER *rdb = (REPARSE_DATA_BUFFER*)qMalloc(bufsize);
318  DWORD retsize = 0;
319  if (::DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, 0, 0, rdb, bufsize, &retsize, 0)) {
320  if (rdb->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) {
321  int length = rdb->MountPointReparseBuffer.SubstituteNameLength / sizeof(wchar_t);
322  int offset = rdb->MountPointReparseBuffer.SubstituteNameOffset / sizeof(wchar_t);
323  const wchar_t* PathBuffer = &rdb->MountPointReparseBuffer.PathBuffer[offset];
324  result = QString::fromWCharArray(PathBuffer, length);
325  } else if (rdb->ReparseTag == IO_REPARSE_TAG_SYMLINK) {
326  int length = rdb->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(wchar_t);
327  int offset = rdb->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(wchar_t);
328  const wchar_t* PathBuffer = &rdb->SymbolicLinkReparseBuffer.PathBuffer[offset];
329  result = QString::fromWCharArray(PathBuffer, length);
330  }
331  // cut-off "//?/" and "/??/"
332  if (result.size() > 4 && result.at(0) == QLatin1Char('\\') && result.at(2) == QLatin1Char('?') && result.at(3) == QLatin1Char('\\'))
333  result = result.mid(4);
334  }
335  qFree(rdb);
336  CloseHandle(handle);
337 
338 #if !defined(QT_NO_LIBRARY)
339  resolveLibs();
340  if (ptrGetVolumePathNamesForVolumeNameW) {
341  QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive);
342  if(matchVolName.indexIn(result) == 0) {
343  DWORD len;
344  wchar_t buffer[MAX_PATH];
345  QString volumeName = result.mid(0, matchVolName.matchedLength()).prepend(QLatin1String("\\\\?\\"));
346  if(ptrGetVolumePathNamesForVolumeNameW((wchar_t*)volumeName.utf16(), buffer, MAX_PATH, &len) != 0)
347  result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer));
348  }
349  }
350 #endif
351  }
352 #else
353  Q_UNUSED(link);
354 #endif // Q_OS_WINCE
355  return result;
356 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
Q_CORE_EXPORT void qFree(void *ptr)
Definition: qmalloc.cpp:58
QString & replace(int i, int len, QChar after)
Definition: qstring.cpp:2005
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
The QString class provides a Unicode character string.
Definition: qstring.h:83
NativePath nativeFilePath() const
#define IO_REPARSE_TAG_SYMLINK
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
static void resolveLibs()
void * HANDLE
Definition: qnamespace.h:1671
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
const ushort * utf16() const
Returns the QString as a &#39;\0\&#39;-terminated array of unsigned shorts.
Definition: qstring.cpp:5290

◆ resolveUNCLibs()

static bool resolveUNCLibs ( )
static

Definition at line 281 of file qfilesystemengine_win.cpp.

Referenced by QFileSystemEngine::uncListSharesOnServer().

282 {
283  static bool triedResolve = false;
284  if (!triedResolve) {
285 #ifndef QT_NO_THREAD
286  QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve));
287  if (triedResolve) {
289  }
290 #endif
291 
292 #if !defined(Q_OS_WINCE)
293  QSystemLibrary netapi32(QLatin1String("Netapi32"));
294  if (netapi32.load()) {
295  ptrNetShareEnum = (PtrNetShareEnum)netapi32.resolve("NetShareEnum");
296  ptrNetApiBufferFree = (PtrNetApiBufferFree)netapi32.resolve("NetApiBufferFree");
297  }
298 #endif
299  triedResolve = true;
300  }
302 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static PtrNetApiBufferFree ptrNetApiBufferFree
DWORD(WINAPI * PtrNetShareEnum)(LPWSTR, DWORD, LPBYTE *, DWORD, LPDWORD, LPDWORD, LPDWORD)
static PtrNetShareEnum ptrNetShareEnum
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
DWORD(WINAPI * PtrNetApiBufferFree)(LPVOID)
static QMutex * globalInstanceGet(const void *address)
Returns a QMutex from the global mutex pool.
Definition: qmutexpool.cpp:150

◆ rmDir()

static bool rmDir ( const QString path)
inlinestatic

Definition at line 916 of file qfilesystemengine_win.cpp.

Referenced by isDirPath().

917 {
918  return ::RemoveDirectory((wchar_t*)QFSFileEnginePrivate::longFileName(path).utf16());
919 }
static QString longFileName(const QString &path)

◆ tryDriveUNCFallback()

static bool tryDriveUNCFallback ( const QFileSystemEntry fname,
QFileSystemMetaData data 
)
static

Definition at line 736 of file qfilesystemengine_win.cpp.

Referenced by QFileSystemEngine::fillMetaData().

737 {
738  bool entryExists = false;
739  DWORD fileAttrib = 0;
740 #if !defined(Q_OS_WINCE)
741  if (fname.isDriveRoot()) {
742  // a valid drive ??
743  DWORD drivesBitmask = ::GetLogicalDrives();
744  int drivebit = 1 << (fname.filePath().at(0).toUpper().unicode() - QLatin1Char('A').unicode());
745  if (drivesBitmask & drivebit) {
746  fileAttrib = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM;
747  entryExists = true;
748  }
749  } else {
750 #endif
751  const QString &path = fname.nativeFilePath();
752  bool is_dir = false;
753  if (path.startsWith(QLatin1String("\\\\?\\UNC"))) {
754  // UNC - stat doesn't work for all cases (Windows bug)
755  int s = path.indexOf(path.at(0),7);
756  if (s > 0) {
757  // "\\?\UNC\server\..."
758  s = path.indexOf(path.at(0),s+1);
759  if (s > 0) {
760  // "\\?\UNC\server\share\..."
761  if (s == path.size() - 1) {
762  // "\\?\UNC\server\share\"
763  is_dir = true;
764  } else {
765  // "\\?\UNC\server\share\notfound"
766  }
767  } else {
768  // "\\?\UNC\server\share"
769  is_dir = true;
770  }
771  } else {
772  // "\\?\UNC\server"
773  is_dir = true;
774  }
775  }
776  if (is_dir && uncShareExists(path)) {
777  // looks like a UNC dir, is a dir.
778  fileAttrib = FILE_ATTRIBUTE_DIRECTORY;
779  entryExists = true;
780  }
781 #if !defined(Q_OS_WINCE)
782  }
783 #endif
784  if (entryExists)
785  data.fillFromFileAttribute(fileAttrib);
786  return entryExists;
787 }
void fillFromFileAttribute(DWORD fileAttribute, bool isDriveRoot=false)
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
The QString class provides a Unicode character string.
Definition: qstring.h:83
NativePath nativeFilePath() const
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QChar toUpper() const
Returns the uppercase equivalent if the character is lowercase or titlecase; otherwise returns the ch...
Definition: qchar.cpp:1287
ushort unicode() const
Converts a Latin-1 character to an 16-bit-encoded Unicode representation of the character.
Definition: qchar.h:64
static bool uncShareExists(const QString &server)
bool isDriveRoot() const
QString filePath() const
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ tryFindFallback()

static bool tryFindFallback ( const QFileSystemEntry fname,
QFileSystemMetaData data 
)
static

Definition at line 789 of file qfilesystemengine_win.cpp.

Referenced by QFileSystemEngine::fillMetaData().

790 {
791  bool filledData = false;
792  // This assumes the last call to a Windows API failed.
793  int errorCode = GetLastError();
794  if (errorCode == ERROR_ACCESS_DENIED || errorCode == ERROR_SHARING_VIOLATION) {
795  WIN32_FIND_DATA findData;
796  if (getFindData(fname.nativeFilePath(), findData)
797  && findData.dwFileAttributes != INVALID_FILE_ATTRIBUTES) {
798  data.fillFromFindData(findData, true, fname.isDriveRoot());
799  filledData = true;
800  }
801  }
802  return filledData;
803 }
void fillFromFindData(WIN32_FIND_DATA &findData, bool setLinkType=false, bool isDriveRoot=false)
NativePath nativeFilePath() const
static bool getFindData(QString path, WIN32_FIND_DATA &findData)
bool isDriveRoot() const
#define INVALID_FILE_ATTRIBUTES

◆ uncShareExists()

static bool uncShareExists ( const QString server)
static

Definition at line 415 of file qfilesystemengine_win.cpp.

Referenced by tryDriveUNCFallback().

416 {
417  // This code assumes the UNC path is always like \\?\UNC\server...
418  QStringList parts = server.split(QLatin1Char('\\'), QString::SkipEmptyParts);
419  if (parts.count() >= 3) {
420  QStringList shares;
421  if (QFileSystemEngine::uncListSharesOnServer(QLatin1String("\\\\") + parts.at(2), &shares))
422  return parts.count() >= 4 ? shares.contains(parts.at(3), Qt::CaseInsensitive) : true;
423  }
424  return false;
425 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
static bool uncListSharesOnServer(const QString &server, QStringList *list)
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
Definition: qstring.cpp:6526
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

Variable Documentation

◆ ptrNetApiBufferFree

PtrNetApiBufferFree ptrNetApiBufferFree = 0
static

◆ ptrNetShareEnum

PtrNetShareEnum ptrNetShareEnum = 0
static

◆ qfsPrivateCurrentDir

QString qfsPrivateCurrentDir = QLatin1String("")
static

Definition at line 145 of file qfilesystemengine_win.cpp.

Referenced by isDirPath().

◆ qt_ntfs_permission_lookup

Q_CORE_EXPORT int qt_ntfs_permission_lookup = 0