-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support UNC path capacity on Windows #22202
base: master
Are you sure you want to change the base?
Conversation
QT seems doesn't have full support of UNC paths in general, a workaround is to mount it as a drive, mentioned at PCSX2/pcsx2#6258 and https://forum.qt.io/topic/96418/how-to-create-a-folder-and-write-a-file-in-it-using-the-unc-path/2 |
@@ -99,6 +104,27 @@ namespace | |||
Path current = path; | |||
qint64 freeSpace = Utils::Fs::freeDiskSpaceOnPath(current); | |||
|
|||
// UNC path support on windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be done inside Utils::Fs::freeDiskSpaceOnPath()
.
@@ -99,6 +104,27 @@ namespace | |||
Path current = path; | |||
qint64 freeSpace = Utils::Fs::freeDiskSpaceOnPath(current); | |||
|
|||
// UNC path support on windows | |||
#ifdef Q_OS_WIN | |||
if (freeSpace < 0 && PathIsUNC(current.data().toStdWString().c_str())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (freeSpace < 0 && PathIsUNC(current.data().toStdWString().c_str())) | |
if ((freeSpace < 0) && PathIsUNCW(current.data().toStdWString().c_str())) |
ULARGE_INTEGER FreeBytesAvailable = { 0 }; | ||
ULARGE_INTEGER TotalNumberOfBytes = { 0 }; | ||
ULARGE_INTEGER TotalNumberOfFreeBytes = { 0 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ULARGE_INTEGER FreeBytesAvailable = { 0 }; | |
ULARGE_INTEGER TotalNumberOfBytes = { 0 }; | |
ULARGE_INTEGER TotalNumberOfFreeBytes = { 0 }; | |
ULARGE_INTEGER freeBytesAvailable = {0}; | |
ULARGE_INTEGER totalNumberOfBytes = {0}; | |
ULARGE_INTEGER totalNumberOfFreeBytes = {0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, both totalNumberOfBytes
and totalNumberOfFreeBytes
are redundant (unused) and can be omitted.
BOOL ok = GetDiskFreeSpaceEx( | ||
current.data().toStdWString().c_str(), | ||
&FreeBytesAvailable, | ||
&TotalNumberOfBytes, | ||
&TotalNumberOfFreeBytes | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such indentation is too overkill.
BOOL ok = GetDiskFreeSpaceEx( | |
current.data().toStdWString().c_str(), | |
&FreeBytesAvailable, | |
&TotalNumberOfBytes, | |
&TotalNumberOfFreeBytes | |
); | |
const BOOL ok = GetDiskFreeSpaceExW(current.data().toStdWString().c_str() | |
, &freeBytesAvailable, &totalNumberOfBytes, &totalNumberOfFreeBytes); |
if (ok) | ||
{ | ||
freeSpace = FreeBytesAvailable.QuadPart; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (ok) | |
{ | |
freeSpace = FreeBytesAvailable.QuadPart; | |
} | |
if (ok) | |
freeSpace = freeBytesAvailable.QuadPart; |
freeSpace = FreeBytesAvailable.QuadPart; | ||
} | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#endif | |
#endif |
@@ -99,6 +104,27 @@ namespace | |||
Path current = path; | |||
qint64 freeSpace = Utils::Fs::freeDiskSpaceOnPath(current); | |||
|
|||
// UNC path support on windows | |||
#ifdef Q_OS_WIN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#ifdef Q_OS_WIN | |
#ifdef Q_OS_WIN |
Add UNC path capacity calculation capability by invoking Windows API directly.
For #21954,
Can we get a confirmation on linux as well?