Projects
home:sagiben
kodi-next
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 50
View file
kodi-next.spec
Changed
@@ -80,8 +80,8 @@ BuildRequires: fdupes BuildRequires: gawk # need gcc5 -BuildRequires: gcc5 -BuildRequires: gcc5-c++ +BuildRequires: gcc +BuildRequires: gcc-c++ BuildRequires: libtool BuildRequires: pkg-config BuildRequires: pkgconfig(python2)
View file
_service:download_files:master.tar.gz/xbmc/platform/Filesystem.h
Changed
@@ -33,7 +33,11 @@ std::uintmax_t available; }; -space_info space(const std::string& path, std::error_code& ec); +space_info space(const std::string &path, std::error_code &ec); + +std::string temp_directory_path(std::error_code &ec); +std::string create_temp_directory(std::error_code &ec); +std::string temp_file_path(std::string suffix, std::error_code &ec); } } } \ No newline at end of file
View file
_service:download_files:master.tar.gz/xbmc/platform/posix/Filesystem.cpp
Changed
@@ -21,6 +21,7 @@ #include "platform/Filesystem.h" #include "system.h" #include "filesystem/SpecialProtocol.h" +#include "utils/URIUtils.h" #if defined(TARGET_LINUX) #include <sys/statvfs.h> @@ -31,6 +32,9 @@ #include <sys/statfs.h> #endif +#include <cstdlib> +#include <limits.h> + namespace KODI { namespace PLATFORM @@ -65,6 +69,67 @@ return sp; } + +std::string temp_directory_path(std::error_code &ec) +{ + ec.clear(); + + auto result = getenv("TMPDIR"); + if (result) + return URIUtils::AppendSlash(result); + + return "/tmp/"; +} + +std::string create_temp_directory(std::error_code &ec) +{ + char buf[PATH_MAX]; + + auto path = temp_directory_path(ec); + + strcpy(buf, (path + "xbmctempXXXXXX").c_str()); + + auto tmp = mkdtemp(buf); + if (!tmp) + { + ec.assign(errno, std::system_category()); + return std::string(); + } + + ec.clear(); + return std::string(tmp); +} + +std::string temp_file_path(std::string suffix, std::error_code &ec) +{ + char tmp[PATH_MAX]; + + auto tempPath = create_temp_directory(ec); + if (ec) + return std::string(); + + tempPath = URIUtils::AddFileToFolder(tempPath, "xbmctempfileXXXXXX" + suffix); + if (tempPath.length() >= PATH_MAX) + { + ec.assign(EOVERFLOW, std::system_category()); + return std::string(); + } + + strcpy(tmp, tempPath.c_str()); + + auto fd = mkstemps(tmp, suffix.length()); + if (fd < 0) + { + ec.assign(errno, std::system_category()); + return std::string(); + } + + close(fd); + + ec.clear(); + return std::string(tmp); +} + +} } } -} \ No newline at end of file
View file
_service:download_files:master.tar.gz/xbmc/platform/win32/Filesystem.cpp
Changed
@@ -26,6 +26,8 @@ #endif #include <Windows.h> +namespace win = KODI::PLATFORM::WINDOWS; + namespace KODI { namespace PLATFORM @@ -34,11 +36,10 @@ { space_info space(const std::string& path, std::error_code& ec) { - using WINDOWS::ToW; ec.clear(); space_info sp; - auto pathW = ToW(path); + auto pathW = win::ToW(path); ULARGE_INTEGER capacity; ULARGE_INTEGER available; @@ -60,6 +61,69 @@ return sp; } + +std::string temp_directory_path(std::error_code &ec) +{ + wchar_t lpTempPathBuffer[MAX_PATH + 1]; + + if (!GetTempPathW(MAX_PATH, lpTempPathBuffer)) + { + ec.assign(GetLastError(), std::system_category()); + return std::string(); + } + + ec.clear(); + return win::FromW(lpTempPathBuffer); +} + +std::string create_temp_directory(std::error_code &ec) +{ + wchar_t lpTempPathBuffer[MAX_PATH + 1]; + + std::wstring xbmcTempPath = win::ToW(temp_directory_path(ec)); + + if (ec) + return std::string(); + + if (!GetTempFileNameW(xbmcTempPath.c_str(), L"xbm", 0, lpTempPathBuffer)) + { + ec.assign(GetLastError(), std::system_category()); + return std::string(); + } + + DeleteFileW(lpTempPathBuffer); + + if (!CreateDirectoryW(lpTempPathBuffer, nullptr)) + { + ec.assign(GetLastError(), std::system_category()); + return std::string(); + } + + ec.clear(); + return win::FromW(lpTempPathBuffer); +} + +std::string temp_file_path(std::string, std::error_code &ec) +{ + wchar_t lpTempPathBuffer[MAX_PATH + 1]; + + std::wstring xbmcTempPath = win::ToW(create_temp_directory(ec)); + + if (ec) + return std::string(); + + if (!GetTempFileNameW(xbmcTempPath.c_str(), L"xbm", 0, lpTempPathBuffer)) + { + ec.assign(GetLastError(), std::system_category()); + return std::string(); + } + + DeleteFileW(lpTempPathBuffer); + + ec.clear(); + return win::FromW(lpTempPathBuffer); +} + } } } \ No newline at end of file
View file
_service:download_files:master.tar.gz/xbmc/test/TestBasicEnvironment.cpp
Changed
@@ -29,11 +29,7 @@ #include "Application.h" #include "AppParamParser.h" #include "windowing/WinSystem.h" - -#if defined(TARGET_WINDOWS) -#include "platform/win32/WIN32Util.h" -#include "platform/win32/CharsetConverter.h" -#endif +#include "platform/Filesystem.h" #ifdef TARGET_DARWIN #include "Util.h" @@ -42,6 +38,9 @@ #include <cstdio> #include <cstdlib> #include <climits> +#include <system_error> + +namespace fs = KODI::PLATFORM::FILESYSTEM; void TestBasicEnvironment::SetUp() { @@ -74,29 +73,19 @@ /* Create a temporary directory and set it to be used throughout the * test suite run. */ -#ifdef TARGET_WINDOWS - using KODI::PLATFORM::WINDOWS::FromW; - std::wstring xbmcTempPath; - TCHAR lpTempPathBuffer[MAX_PATH]; - if (!GetTempPath(MAX_PATH, lpTempPathBuffer)) - SetUpError(); - xbmcTempPath = lpTempPathBuffer; - if (!GetTempFileName(xbmcTempPath.c_str(), L"xbmctempdir", 0, lpTempPathBuffer)) - SetUpError(); - DeleteFile(lpTempPathBuffer); - if (!CreateDirectory(lpTempPathBuffer, NULL)) - SetUpError(); - CSpecialProtocol::SetTempPath(FromW(lpTempPathBuffer)); - CSpecialProtocol::SetProfilePath(FromW(lpTempPathBuffer)); -#else - char buf[MAX_PATH]; - char *tmp; - strcpy(buf, "/tmp/xbmctempdirXXXXXX"); - if ((tmp = mkdtemp(buf)) == NULL) + + g_application.EnablePlatformDirectories(false); + + std::error_code ec; + m_tempPath = fs::create_temp_directory(ec); + if (ec) + { + TearDown(); SetUpError(); - CSpecialProtocol::SetTempPath(tmp); - CSpecialProtocol::SetProfilePath(tmp); -#endif + } + + CSpecialProtocol::SetTempPath(m_tempPath); + CSpecialProtocol::SetProfilePath(m_tempPath); /* Create and delete a tempfile to initialize the VFS (really to initialize * CLibcdio). This is done so that the initialization of the VFS does not @@ -120,8 +109,8 @@ void TestBasicEnvironment::TearDown() { - std::string xbmcTempPath = CSpecialProtocol::TranslatePath("special://temp/"); - XFILE::CDirectory::Remove(xbmcTempPath); + XFILE::CDirectory::RemoveRecursive(m_tempPath); + CServiceBroker::GetSettings().Uninitialize(); g_application.m_ServiceManager->DeinitTesting(); }
View file
_service:download_files:master.tar.gz/xbmc/test/TestBasicEnvironment.h
Changed
@@ -21,6 +21,8 @@ #include "gtest/gtest.h" +#include <string> + class TestBasicEnvironment : public testing::Environment { public: @@ -28,4 +30,5 @@ void TearDown() override; private: void SetUpError(); + std::string m_tempPath; };
View file
_service:download_files:master.tar.gz/xbmc/test/TestUtils.cpp
Changed
@@ -22,7 +22,7 @@ #include "Util.h" #include "filesystem/File.h" #include "filesystem/SpecialProtocol.h" -#include "platform/win32/CharsetConverter.h" +#include "platform/Filesystem.h" #include "utils/StringUtils.h" #include "utils/URIUtils.h" @@ -34,6 +34,10 @@ #include <ctime> #endif +#include <system_error> + +namespace fs = KODI::PLATFORM::FILESYSTEM; + class CTempFile : public XFILE::CFile { public: @@ -44,38 +48,13 @@ } bool Create(const std::string &suffix) { - char tmp[MAX_PATH]; - - m_ptempFileDirectory = CSpecialProtocol::TranslatePath("special://temp/"); - m_ptempFilePath = m_ptempFileDirectory + "xbmctempfileXXXXXX"; - m_ptempFilePath += suffix; - if (m_ptempFilePath.length() >= MAX_PATH) - { - m_ptempFilePath = ""; + std::error_code ec; + m_ptempFilePath = fs::temp_file_path(suffix, ec); + if (ec) return false; - } - strcpy(tmp, m_ptempFilePath.c_str()); -#ifdef TARGET_WINDOWS - using namespace KODI::PLATFORM::WINDOWS; - wchar_t tmpW[MAX_PATH]; - if (!GetTempFileName(ToW(CSpecialProtocol::TranslatePath("special://temp/")).c_str(), - L"xbmctempfile", 0, tmpW)) - { - m_ptempFilePath = ""; + if (m_ptempFilePath.empty()) return false; - } - m_ptempFilePath = FromW(tmpW); -#else - int fd; - if ((fd = mkstemps(tmp, suffix.length())) < 0) - { - m_ptempFilePath = ""; - return false; - } - close(fd); - m_ptempFilePath = tmp; -#endif OpenForWrite(m_ptempFilePath.c_str(), true); return true; @@ -91,11 +70,10 @@ } std::string getTempFileDirectory() const { - return m_ptempFileDirectory; + return URIUtils::GetDirectory(m_ptempFilePath); } private: std::string m_ptempFilePath; - std::string m_ptempFileDirectory; }; CXBMCTestUtils::CXBMCTestUtils()
View file
_service:download_files:master.tar.gz/xbmc/utils/Literals.h
Added
@@ -0,0 +1,40 @@ +#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 + * <http://www.gnu.org/licenses/>. + * + */ + +constexpr unsigned long long int operator"" _kib (unsigned long long int val) +{ + return val * 1024ull; +} + +constexpr unsigned long long int operator"" _kb (unsigned long long int val) +{ + return val * 1000ull; +} + +constexpr unsigned long long int operator"" _mib (unsigned long long int val) +{ + return val * 1024ull * 1024ull; +} + +constexpr unsigned long long int operator"" _mb (unsigned long long int val) +{ + return val * 1000ull * 1000ull; +} \ No newline at end of file
View file
_service:download_files:master.tar.gz/xbmc/utils/URIUtils.cpp
Changed
@@ -1087,6 +1087,12 @@ return false; } +std::string URIUtils::AppendSlash(std::string strFolder) +{ + AddSlashAtEnd(strFolder); + return strFolder; +} + void URIUtils::AddSlashAtEnd(std::string& strFolder) { if (IsURL(strFolder))
View file
_service:download_files:master.tar.gz/xbmc/utils/URIUtils.h
Changed
@@ -166,6 +166,7 @@ static bool IsPVRGuideItem(const std::string& strFile); static bool IsUsingFastSwitch(const std::string& strFile); + static std::string AppendSlash(std::string strFolder); static void AddSlashAtEnd(std::string& strFolder); static bool HasSlashAtEnd(const std::string& strFile, bool checkURL = false); static void RemoveSlashAtEnd(std::string& strFolder);
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.