From 8a0c0d5ea46c238b5b784f098e5cf12aa92c1af5 Mon Sep 17 00:00:00 2001 From: Anton Fedchin Date: Tue, 3 Apr 2018 17:38:26 +0300 Subject: [darwin] storage: move implementation to platform folder --- cmake/treedata/ios/subdirs.txt | 10 +- cmake/treedata/osx/subdirs.txt | 8 +- xbmc/platform/darwin/osx/SDLMain.mm | 2 +- xbmc/platform/darwin/osx/storage/CMakeLists.txt | 5 + .../darwin/osx/storage/DarwinStorageProvider.cpp | 216 +++++++++++++++++++++ .../darwin/osx/storage/DarwinStorageProvider.h | 49 +++++ xbmc/storage/osx/CMakeLists.txt | 5 - xbmc/storage/osx/DarwinStorageProvider.cpp | 216 --------------------- xbmc/storage/osx/DarwinStorageProvider.h | 49 ----- 9 files changed, 280 insertions(+), 280 deletions(-) create mode 100644 xbmc/platform/darwin/osx/storage/CMakeLists.txt create mode 100644 xbmc/platform/darwin/osx/storage/DarwinStorageProvider.cpp create mode 100644 xbmc/platform/darwin/osx/storage/DarwinStorageProvider.h delete mode 100644 xbmc/storage/osx/CMakeLists.txt delete mode 100644 xbmc/storage/osx/DarwinStorageProvider.cpp delete mode 100644 xbmc/storage/osx/DarwinStorageProvider.h diff --git a/cmake/treedata/ios/subdirs.txt b/cmake/treedata/ios/subdirs.txt index 00f5cf115c..feafe5480a 100644 --- a/cmake/treedata/ios/subdirs.txt +++ b/cmake/treedata/ios/subdirs.txt @@ -5,13 +5,13 @@ xbmc/network/linux network/linux xbmc/network/osx network/osx xbmc/peripherals/bus/osx peripherals/bus/osx xbmc/powermanagement/osx powermanagement/osx -xbmc/storage/osx storage/osx xbmc/platform/posix posix -xbmc/platform/darwin platform_darwin -xbmc/platform/darwin/ios platform_ios -xbmc/platform/darwin/ios-common platform_ios-common +xbmc/platform/darwin platform/darwin +xbmc/platform/darwin/ios platform/ios +xbmc/platform/darwin/ios-common platform/ios-common +xbmc/platform/darwin/osx/storage platform/osx/storage xbmc/filesystem/posix filesystem/posix -xbmc/utils/posix utils_posix +xbmc/utils/posix utils/posix xbmc/windowing/osx windowing/osx xbmc/cores/RetroPlayer/process/ios cores/RetroPlayer/process/ios xbmc/cores/VideoPlayer/Process/ios cores/VideoPlayer/Process/ios diff --git a/cmake/treedata/osx/subdirs.txt b/cmake/treedata/osx/subdirs.txt index 5b1b3021d6..de61ea4940 100644 --- a/cmake/treedata/osx/subdirs.txt +++ b/cmake/treedata/osx/subdirs.txt @@ -3,12 +3,12 @@ xbmc/network/linux network/linux xbmc/network/osx network/osx xbmc/peripherals/bus/osx peripherals/bus/osx xbmc/powermanagement/osx powermanagement/osx -xbmc/storage/osx storage/osx xbmc/platform/posix posix -xbmc/platform/darwin platform_darwin -xbmc/platform/darwin/osx platform_osx +xbmc/platform/darwin platform/darwin +xbmc/platform/darwin/osx platform/osx +xbmc/platform/darwin/osx/storage platform/osx/storage xbmc/filesystem/posix filesystem/posix -xbmc/utils/posix utils_posix +xbmc/utils/posix utils/posix xbmc/windowing/osx windowing/osx xbmc/cores/RetroPlayer/process/osx cores/RetroPlayer/process/osx xbmc/cores/VideoPlayer/Process/osx cores/VideoPlayer/Process/osx diff --git a/xbmc/platform/darwin/osx/SDLMain.mm b/xbmc/platform/darwin/osx/SDLMain.mm index f7aa09a81b..a301d845eb 100644 --- a/xbmc/platform/darwin/osx/SDLMain.mm +++ b/xbmc/platform/darwin/osx/SDLMain.mm @@ -18,7 +18,7 @@ #import "platform/darwin/osx/CocoaInterface.h" #import "PlatformDefs.h" #import "messaging/ApplicationMessenger.h" -#import "storage/osx/DarwinStorageProvider.h" +#import "platform/darwin/osx/storage/DarwinStorageProvider.h" #import "platform/darwin/osx/HotKeyController.h" #import "platform/darwin/DarwinUtils.h" diff --git a/xbmc/platform/darwin/osx/storage/CMakeLists.txt b/xbmc/platform/darwin/osx/storage/CMakeLists.txt new file mode 100644 index 0000000000..9407297191 --- /dev/null +++ b/xbmc/platform/darwin/osx/storage/CMakeLists.txt @@ -0,0 +1,5 @@ +set(SOURCES DarwinStorageProvider.cpp) + +set(HEADERS DarwinStorageProvider.h) + +core_add_library(platform_osx_storage) diff --git a/xbmc/platform/darwin/osx/storage/DarwinStorageProvider.cpp b/xbmc/platform/darwin/osx/storage/DarwinStorageProvider.cpp new file mode 100644 index 0000000000..566c87ba05 --- /dev/null +++ b/xbmc/platform/darwin/osx/storage/DarwinStorageProvider.cpp @@ -0,0 +1,216 @@ +/* + * Copyright (C) 2005-2013 Team XBMC + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * . + * + */ + +#include +#include "DarwinStorageProvider.h" +#include "utils/RegExp.h" +#include "Util.h" +#include "guilib/LocalizeStrings.h" + +#include +#if defined(TARGET_DARWIN_OSX) +#include +#include +#include +#include "platform/darwin/DarwinUtils.h" +#endif +#include "platform/darwin/osx/CocoaInterface.h" + +bool CDarwinStorageProvider::m_event = false; + +IStorageProvider* IStorageProvider::CreateInstance() +{ + return new CDarwinStorageProvider(); +} + +CDarwinStorageProvider::CDarwinStorageProvider() +{ + PumpDriveChangeEvents(NULL); +} + +void CDarwinStorageProvider::GetLocalDrives(VECSOURCES &localDrives) +{ + CMediaSource share; + + // User home folder + #ifdef TARGET_DARWIN_IOS + share.strPath = "special://envhome/"; + #else + share.strPath = getenv("HOME"); + #endif + share.strName = g_localizeStrings.Get(21440); + share.m_ignore = true; + localDrives.push_back(share); + +#if defined(TARGET_DARWIN_IOS) + // iOS Inbox folder + share.strPath = "special://envhome/Documents/Inbox"; + share.strName = "Inbox"; + share.m_ignore = true; + localDrives.push_back(share); +#endif + +#if defined(TARGET_DARWIN_OSX) + // User desktop folder + share.strPath = getenv("HOME"); + share.strPath += "/Desktop"; + share.strName = "Desktop"; + share.m_ignore = true; + localDrives.push_back(share); + + // Volumes (all mounts are present here) + share.strPath = "/Volumes"; + share.strName = "Volumes"; + share.m_ignore = true; + localDrives.push_back(share); + + // This will pick up all local non-removable disks including the Root Disk. + DASessionRef session = DASessionCreate(kCFAllocatorDefault); + if (session) + { + unsigned i, count = 0; + struct statfs *buf = NULL; + std::string mountpoint, devicepath; + + count = getmntinfo(&buf, 0); + for (i=0; i CDarwinStorageProvider::GetDiskUsage() +{ + std::vector result; + char line[1024]; + +#ifdef TARGET_DARWIN_IOS + FILE* pipe = popen("df -ht hfs,apfs", "r"); +#else + FILE* pipe = popen("df -HT ufs,cd9660,hfs,apfs,udf", "r"); +#endif + + if (pipe) + { + while (fgets(line, sizeof(line) - 1, pipe)) + { + result.push_back(line); + } + pclose(pipe); + } + + return result; +} + +bool CDarwinStorageProvider::Eject(const std::string& mountpath) +{ + return false; +} + +bool CDarwinStorageProvider::PumpDriveChangeEvents(IStorageEventsCallback *callback) +{ + bool event = m_event; + m_event = false; + return event; +} + +void CDarwinStorageProvider::SetEvent(void) +{ + CDarwinStorageProvider::m_event = true; +} diff --git a/xbmc/platform/darwin/osx/storage/DarwinStorageProvider.h b/xbmc/platform/darwin/osx/storage/DarwinStorageProvider.h new file mode 100644 index 0000000000..1c01f38493 --- /dev/null +++ b/xbmc/platform/darwin/osx/storage/DarwinStorageProvider.h @@ -0,0 +1,49 @@ +#pragma once +/* + * Copyright (C) 2005-2013 Team XBMC + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * . + * + */ + +#include +#include + +#include "storage/IStorageProvider.h" + +class CDarwinStorageProvider : public IStorageProvider +{ +public: + CDarwinStorageProvider(); + virtual ~CDarwinStorageProvider() { } + + virtual void Initialize() { } + virtual void Stop() { } + + virtual void GetLocalDrives(VECSOURCES &localDrives); + virtual void GetRemovableDrives(VECSOURCES &removableDrives); + + virtual std::vector GetDiskUsage(void); + + virtual bool Eject(const std::string& mountpath); + + virtual bool PumpDriveChangeEvents(IStorageEventsCallback *callback); + + static void SetEvent(void); + +private: + static bool m_event; +}; diff --git a/xbmc/storage/osx/CMakeLists.txt b/xbmc/storage/osx/CMakeLists.txt deleted file mode 100644 index 8d1e86c4c8..0000000000 --- a/xbmc/storage/osx/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set(SOURCES DarwinStorageProvider.cpp) - -set(HEADERS DarwinStorageProvider.h) - -core_add_library(storage_osx) diff --git a/xbmc/storage/osx/DarwinStorageProvider.cpp b/xbmc/storage/osx/DarwinStorageProvider.cpp deleted file mode 100644 index 566c87ba05..0000000000 --- a/xbmc/storage/osx/DarwinStorageProvider.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (C) 2005-2013 Team XBMC - * http://kodi.tv - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * . - * - */ - -#include -#include "DarwinStorageProvider.h" -#include "utils/RegExp.h" -#include "Util.h" -#include "guilib/LocalizeStrings.h" - -#include -#if defined(TARGET_DARWIN_OSX) -#include -#include -#include -#include "platform/darwin/DarwinUtils.h" -#endif -#include "platform/darwin/osx/CocoaInterface.h" - -bool CDarwinStorageProvider::m_event = false; - -IStorageProvider* IStorageProvider::CreateInstance() -{ - return new CDarwinStorageProvider(); -} - -CDarwinStorageProvider::CDarwinStorageProvider() -{ - PumpDriveChangeEvents(NULL); -} - -void CDarwinStorageProvider::GetLocalDrives(VECSOURCES &localDrives) -{ - CMediaSource share; - - // User home folder - #ifdef TARGET_DARWIN_IOS - share.strPath = "special://envhome/"; - #else - share.strPath = getenv("HOME"); - #endif - share.strName = g_localizeStrings.Get(21440); - share.m_ignore = true; - localDrives.push_back(share); - -#if defined(TARGET_DARWIN_IOS) - // iOS Inbox folder - share.strPath = "special://envhome/Documents/Inbox"; - share.strName = "Inbox"; - share.m_ignore = true; - localDrives.push_back(share); -#endif - -#if defined(TARGET_DARWIN_OSX) - // User desktop folder - share.strPath = getenv("HOME"); - share.strPath += "/Desktop"; - share.strName = "Desktop"; - share.m_ignore = true; - localDrives.push_back(share); - - // Volumes (all mounts are present here) - share.strPath = "/Volumes"; - share.strName = "Volumes"; - share.m_ignore = true; - localDrives.push_back(share); - - // This will pick up all local non-removable disks including the Root Disk. - DASessionRef session = DASessionCreate(kCFAllocatorDefault); - if (session) - { - unsigned i, count = 0; - struct statfs *buf = NULL; - std::string mountpoint, devicepath; - - count = getmntinfo(&buf, 0); - for (i=0; i CDarwinStorageProvider::GetDiskUsage() -{ - std::vector result; - char line[1024]; - -#ifdef TARGET_DARWIN_IOS - FILE* pipe = popen("df -ht hfs,apfs", "r"); -#else - FILE* pipe = popen("df -HT ufs,cd9660,hfs,apfs,udf", "r"); -#endif - - if (pipe) - { - while (fgets(line, sizeof(line) - 1, pipe)) - { - result.push_back(line); - } - pclose(pipe); - } - - return result; -} - -bool CDarwinStorageProvider::Eject(const std::string& mountpath) -{ - return false; -} - -bool CDarwinStorageProvider::PumpDriveChangeEvents(IStorageEventsCallback *callback) -{ - bool event = m_event; - m_event = false; - return event; -} - -void CDarwinStorageProvider::SetEvent(void) -{ - CDarwinStorageProvider::m_event = true; -} diff --git a/xbmc/storage/osx/DarwinStorageProvider.h b/xbmc/storage/osx/DarwinStorageProvider.h deleted file mode 100644 index 1c01f38493..0000000000 --- a/xbmc/storage/osx/DarwinStorageProvider.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once -/* - * Copyright (C) 2005-2013 Team XBMC - * http://kodi.tv - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * . - * - */ - -#include -#include - -#include "storage/IStorageProvider.h" - -class CDarwinStorageProvider : public IStorageProvider -{ -public: - CDarwinStorageProvider(); - virtual ~CDarwinStorageProvider() { } - - virtual void Initialize() { } - virtual void Stop() { } - - virtual void GetLocalDrives(VECSOURCES &localDrives); - virtual void GetRemovableDrives(VECSOURCES &removableDrives); - - virtual std::vector GetDiskUsage(void); - - virtual bool Eject(const std::string& mountpath); - - virtual bool PumpDriveChangeEvents(IStorageEventsCallback *callback); - - static void SetEvent(void); - -private: - static bool m_event; -}; -- cgit v1.2.3