From 2ca5eaaab91db938b06c8eb5d95476e61d305b1a Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 9 Jul 2013 14:07:48 +0200 Subject: [PATCH] utility.cpp: Make compile on OS X --- src/mirall/utility.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/mirall/utility.cpp b/src/mirall/utility.cpp index 6609b3a2b6..a68cb770b7 100644 --- a/src/mirall/utility.cpp +++ b/src/mirall/utility.cpp @@ -26,8 +26,11 @@ #ifdef Q_OS_UNIX #include #include -#elif defined(Q_OS_MAC) +#endif + +#if defined(Q_OS_MAC) #include +#include #elif defined(Q_OS_WIN) #include #include @@ -172,6 +175,7 @@ bool Utility::hasLaunchOnStartup(const QString &appName) return settings.contains(appName); #elif defined(Q_OS_MAC) // implement me + return false; #elif defined(Q_OS_UNIX) QString userAutoStartPath = QDir::homePath()+QLatin1String("/.config/autostart/"); QString desktopFileLocation = userAutoStartPath+appName+QLatin1String(".desktop"); @@ -196,8 +200,7 @@ void Utility::setLaunchOnStartup(const QString &appName, const QString& guiName, #elif defined(Q_OS_MAC) Q_UNUSED(guiName) if (enable) { - // Finder: Place under "Places"/"Favorites" on the left sidebar - QString filePath = QDir(applicationDirPath+QLatin1String("/../..")).absolutePath(); + QString filePath = QDir(QCoreApplication::applicationDirPath()+QLatin1String("/../..")).absolutePath(); CFStringRef folderCFStr = CFStringCreateWithCString(0, filePath.toUtf8().data(), kCFStringEncodingUTF8); CFURLRef urlRef = CFURLCreateWithFileSystemPath (0, folderCFStr, kCFURLPOSIXPathStyle, true); @@ -245,7 +248,11 @@ void Utility::setLaunchOnStartup(const QString &appName, const QString& guiName, qint64 Utility::freeDiskSpace(const QString &path, bool *ok) { -#ifdef Q_OS_UNIX +#ifdef Q_OS_MAC + struct statvfs stat; + statvfs(path.toUtf8().data(), &stat); + return (qint64) stat.f_bavail * stat.f_frsize; +#elif Q_OS_UNIX Q_UNUSED(ok) struct statvfs64 stat; statvfs64(path.toUtf8().data(), &stat);