diff --git a/packages/mediacenter/xbmc/patches/xbmc-999.91.02-PR4838.patch b/packages/mediacenter/xbmc/patches/xbmc-999.91.02-PR4838.patch new file mode 100644 index 0000000000..47684234a5 --- /dev/null +++ b/packages/mediacenter/xbmc/patches/xbmc-999.91.02-PR4838.patch @@ -0,0 +1,236 @@ +From 856d88d87f27370e8471963790db4e4e7c4ba910 Mon Sep 17 00:00:00 2001 +From: Matthias Kortstiege +Date: Fri, 30 May 2014 15:57:25 +0200 +Subject: [PATCH] added: CPosixDirectory implementation + +--- + XBMC.xcodeproj/project.pbxproj | 18 +++++ + xbmc/filesystem/DirectoryFactory.cpp | 7 ++ + xbmc/filesystem/Makefile.in | 1 + + xbmc/filesystem/posix/PosixDirectory.cpp | 130 +++++++++++++++++++++++++++++++ + xbmc/filesystem/posix/PosixDirectory.h | 37 +++++++++ + 5 files changed, 193 insertions(+) + create mode 100644 xbmc/filesystem/posix/PosixDirectory.cpp + create mode 100644 xbmc/filesystem/posix/PosixDirectory.h + +diff --git a/xbmc/filesystem/DirectoryFactory.cpp b/xbmc/filesystem/DirectoryFactory.cpp +index 260d53c..dc39a93 100644 +--- a/xbmc/filesystem/DirectoryFactory.cpp ++++ b/xbmc/filesystem/DirectoryFactory.cpp +@@ -46,6 +46,9 @@ + #include "utils/log.h" + #include "network/WakeOnAccess.h" + ++#ifdef TARGET_POSIX ++#include "posix/PosixDirectory.h" ++#endif + #ifdef HAS_FILESYSTEM_SMB + #ifdef TARGET_WINDOWS + #include "windows/WINSMBDirectory.h" +@@ -135,7 +138,11 @@ IDirectory* CDirectoryFactory::Create(const CStdString& strPath) + + CStdString strProtocol = url.GetProtocol(); + ++#ifdef TARGET_POSIX ++ if (strProtocol.size() == 0 || strProtocol == "file") return new CPosixDirectory(); ++#else + if (strProtocol.size() == 0 || strProtocol == "file") return new CHDDirectory(); ++#endif + if (strProtocol == "special") return new CSpecialProtocolDirectory(); + if (strProtocol == "sources") return new CSourcesDirectory(); + if (strProtocol == "addons") return new CAddonsDirectory(); +diff --git a/xbmc/filesystem/Makefile.in b/xbmc/filesystem/Makefile.in +index 623bbb8..725951e 100644 +--- a/xbmc/filesystem/Makefile.in ++++ b/xbmc/filesystem/Makefile.in +@@ -57,6 +57,7 @@ SRCS += PlaylistFileDirectory.cpp + SRCS += PipeFile.cpp + SRCS += PipesManager.cpp + SRCS += PluginDirectory.cpp ++SRCS += posix/PosixDirectory.cpp + SRCS += PVRFile.cpp + SRCS += PVRDirectory.cpp + SRCS += RSSDirectory.cpp +diff --git a/xbmc/filesystem/posix/PosixDirectory.cpp b/xbmc/filesystem/posix/PosixDirectory.cpp +new file mode 100644 +index 0000000..e60c6f9 +--- /dev/null ++++ b/xbmc/filesystem/posix/PosixDirectory.cpp +@@ -0,0 +1,131 @@ ++/* ++ * Copyright (C) 2014 Team XBMC ++ * http://xbmc.org ++ * ++ * 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 ++ * . ++ * ++ */ ++ ++#if defined(TARGET_POSIX) ++ ++#include "PosixDirectory.h" ++#include "utils/StringUtils.h" ++#include "utils/URIUtils.h" ++#include "FileItem.h" ++#include "XTimeUtils.h" ++ ++#include ++#include ++ ++using namespace std; ++using namespace XFILE; ++ ++CPosixDirectory::CPosixDirectory(void) ++{} ++ ++CPosixDirectory::~CPosixDirectory(void) ++{} ++ ++bool CPosixDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items) ++{ ++ const char* root = strPath; ++ struct dirent* entry; ++ DIR *dir = opendir(root); ++ ++ if (!dir) ++ return false; ++ ++ while ((entry = readdir(dir)) != NULL) ++ { ++ if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) ++ continue; ++ ++ CFileItemPtr pItem(new CFileItem(entry->d_name)); ++ std::string itemPath(URIUtils::AddFileToFolder(root, entry->d_name)); ++ ++ bool bStat = false; ++ struct stat buffer; ++ ++ // Unix-based readdir implementations may return an incorrect dirent.d_ino value that ++ // is not equal to the (correct) stat() obtained one. In this case the file type ++ // could not be determined and the value of dirent.d_type is set to DT_UNKNOWN. ++ // In order to get a correct value we have to incur the cost of calling stat. ++ if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK) ++ { ++ if (stat(itemPath.c_str(), &buffer) == 0) ++ bStat = true; ++ } ++ ++ if (entry->d_type == DT_DIR || (bStat && buffer.st_mode & S_IFDIR)) ++ { ++ pItem->m_bIsFolder = true; ++ URIUtils::AddSlashAtEnd(itemPath); ++ } ++ else ++ { ++ pItem->m_bIsFolder = false; ++ } ++ ++ if (StringUtils::StartsWith(entry->d_name, ".")) ++ pItem->SetProperty("file:hidden", true); ++ ++ pItem->SetPath(itemPath); ++ ++ if (!(m_flags & DIR_FLAG_NO_FILE_INFO)) ++ { ++ if (bStat || stat(pItem->GetPath(), &buffer) == 0) ++ { ++ FILETIME fileTime, localTime; ++ TimeTToFileTime(buffer.st_mtime, &fileTime); ++ FileTimeToLocalFileTime(&fileTime, &localTime); ++ pItem->m_dateTime = localTime; ++ ++ if (!pItem->m_bIsFolder) ++ pItem->m_dwSize = buffer.st_size; ++ } ++ } ++ items.Add(pItem); ++ } ++ closedir(dir); ++ return true; ++} ++ ++bool CPosixDirectory::Create(const char* strPath) ++{ ++ if (!strPath || !*strPath) ++ return false; ++ ++ return (mkdir(strPath, 0755) == 0 || errno == EEXIST); ++} ++ ++bool CPosixDirectory::Remove(const char* strPath) ++{ ++ if (!strPath || !*strPath) ++ return false; ++ ++ return (rmdir(strPath) == 0); ++} ++ ++bool CPosixDirectory::Exists(const char* strPath) ++{ ++ if (!strPath || !*strPath) ++ return false; ++ ++ struct stat buffer; ++ if (stat(strPath, &buffer) != 0) ++ return false; ++ return S_ISDIR(buffer.st_mode) ? true : false; ++} ++#endif +diff --git a/xbmc/filesystem/posix/PosixDirectory.h b/xbmc/filesystem/posix/PosixDirectory.h +new file mode 100644 +index 0000000..a3fd01e +--- /dev/null ++++ b/xbmc/filesystem/posix/PosixDirectory.h +@@ -0,0 +1,37 @@ ++#pragma once ++/* ++ * Copyright (C) 2014 Team XBMC ++ * http://xbmc.org ++ * ++ * 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 "filesystem/IDirectory.h" ++ ++namespace XFILE ++{ ++ ++class CPosixDirectory : public IDirectory ++{ ++public: ++ CPosixDirectory(void); ++ virtual ~CPosixDirectory(void); ++ virtual bool GetDirectory(const CStdString& strPath, CFileItemList &items); ++ virtual bool Create(const char* strPath); ++ virtual bool Exists(const char* strPath); ++ virtual bool Remove(const char* strPath); ++}; ++} +-- +1.9.3 +