|
|
@ -283,9 +283,13 @@ qlonglong Utils::Fs::freeDiskSpaceOnPath(QString path) |
|
|
|
} |
|
|
|
} |
|
|
|
Q_ASSERT(dir_path.exists()); |
|
|
|
Q_ASSERT(dir_path.exists()); |
|
|
|
|
|
|
|
|
|
|
|
#ifndef Q_OS_WIN |
|
|
|
#if defined(Q_OS_WIN) |
|
|
|
|
|
|
|
ULARGE_INTEGER bytesFree; |
|
|
|
|
|
|
|
if (GetDiskFreeSpaceExW((LPCTSTR)(toNativePath(dir_path.path())).utf16(), &bytesFree, NULL, NULL) == 0) |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
return qlonglong(bytesFree.QuadPart); |
|
|
|
|
|
|
|
#elif defined(Q_OS_HAIKU) |
|
|
|
unsigned long long available; |
|
|
|
unsigned long long available; |
|
|
|
#ifdef Q_OS_HAIKU |
|
|
|
|
|
|
|
const QString statfs_path = dir_path.path() + "/."; |
|
|
|
const QString statfs_path = dir_path.path() + "/."; |
|
|
|
dev_t device = dev_for_path (qPrintable(statfs_path)); |
|
|
|
dev_t device = dev_for_path (qPrintable(statfs_path)); |
|
|
|
if (device >= 0) { |
|
|
|
if (device >= 0) { |
|
|
@ -297,6 +301,7 @@ qlonglong Utils::Fs::freeDiskSpaceOnPath(QString path) |
|
|
|
} |
|
|
|
} |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
#else |
|
|
|
#else |
|
|
|
|
|
|
|
unsigned long long available; |
|
|
|
struct statfs stats; |
|
|
|
struct statfs stats; |
|
|
|
const QString statfs_path = dir_path.path() + "/."; |
|
|
|
const QString statfs_path = dir_path.path() + "/."; |
|
|
|
const int ret = statfs(qPrintable(statfs_path), &stats); |
|
|
|
const int ret = statfs(qPrintable(statfs_path), &stats); |
|
|
@ -309,12 +314,6 @@ qlonglong Utils::Fs::freeDiskSpaceOnPath(QString path) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#else |
|
|
|
|
|
|
|
ULARGE_INTEGER bytesFree; |
|
|
|
|
|
|
|
if (GetDiskFreeSpaceExW((LPCTSTR)(toNativePath(dir_path.path())).utf16(), &bytesFree, NULL, NULL) == 0) |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
return qlonglong(bytesFree.QuadPart); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QString Utils::Fs::branchPath(const QString& file_path, QString* removed) |
|
|
|
QString Utils::Fs::branchPath(const QString& file_path, QString* removed) |
|
|
@ -362,14 +361,13 @@ QString Utils::Fs::expandPathAbs(const QString& path) |
|
|
|
QString Utils::Fs::QDesktopServicesDataLocation() |
|
|
|
QString Utils::Fs::QDesktopServicesDataLocation() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString result; |
|
|
|
QString result; |
|
|
|
#ifdef Q_OS_WIN |
|
|
|
#if defined(Q_OS_WIN) |
|
|
|
wchar_t path[MAX_PATH + 1] = {L'\0'}; |
|
|
|
wchar_t path[MAX_PATH + 1] = {L'\0'}; |
|
|
|
if (SHGetSpecialFolderPathW(0, path, CSIDL_LOCAL_APPDATA, FALSE)) |
|
|
|
if (SHGetSpecialFolderPathW(0, path, CSIDL_LOCAL_APPDATA, FALSE)) |
|
|
|
result = fromNativePath(QString::fromWCharArray(path)); |
|
|
|
result = fromNativePath(QString::fromWCharArray(path)); |
|
|
|
if (!QCoreApplication::applicationName().isEmpty()) |
|
|
|
if (!QCoreApplication::applicationName().isEmpty()) |
|
|
|
result += QLatin1String("/") + qApp->applicationName(); |
|
|
|
result += QLatin1String("/") + qApp->applicationName(); |
|
|
|
#else |
|
|
|
#elif defined(Q_OS_MAC) |
|
|
|
#ifdef Q_OS_MAC |
|
|
|
|
|
|
|
FSRef ref; |
|
|
|
FSRef ref; |
|
|
|
OSErr err = FSFindFolder(kUserDomain, kApplicationSupportFolderType, false, &ref); |
|
|
|
OSErr err = FSFindFolder(kUserDomain, kApplicationSupportFolderType, false, &ref); |
|
|
|
if (err) |
|
|
|
if (err) |
|
|
@ -386,7 +384,6 @@ QString Utils::Fs::QDesktopServicesDataLocation() |
|
|
|
xdgDataHome += QLatin1String("/data/") |
|
|
|
xdgDataHome += QLatin1String("/data/") |
|
|
|
+ qApp->applicationName(); |
|
|
|
+ qApp->applicationName(); |
|
|
|
result = xdgDataHome; |
|
|
|
result = xdgDataHome; |
|
|
|
#endif |
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
if (!result.endsWith("/")) |
|
|
|
if (!result.endsWith("/")) |
|
|
|
result += "/"; |
|
|
|
result += "/"; |
|
|
|