diff --git a/src/backend/opencl/OclCache.cpp b/src/backend/opencl/OclCache.cpp new file mode 100644 index 00000000..b17e2f5e --- /dev/null +++ b/src/backend/opencl/OclCache.cpp @@ -0,0 +1,26 @@ +/* XMRig + * Copyright 2010 Jeff Garzik + * Copyright 2012-2014 pooler + * Copyright 2014 Lucas Jones + * Copyright 2014-2016 Wolf9466 + * Copyright 2016 Jay D Dee + * Copyright 2017-2018 XMR-Stak , + * Copyright 2018-2019 SChernykh + * Copyright 2016-2019 XMRig , + * + * 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 3 of the License, 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 this program. If not, see . + */ + + +#include "backend/opencl/OclCache.h" diff --git a/src/backend/opencl/OclCache.h b/src/backend/opencl/OclCache.h new file mode 100644 index 00000000..629eec3a --- /dev/null +++ b/src/backend/opencl/OclCache.h @@ -0,0 +1,49 @@ +/* XMRig + * Copyright 2010 Jeff Garzik + * Copyright 2012-2014 pooler + * Copyright 2014 Lucas Jones + * Copyright 2014-2016 Wolf9466 + * Copyright 2016 Jay D Dee + * Copyright 2017-2018 XMR-Stak , + * Copyright 2018-2019 SChernykh + * Copyright 2016-2019 XMRig , + * + * 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 3 of the License, 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 this program. If not, see . + */ + +#ifndef XMRIG_OCLCACHE_H +#define XMRIG_OCLCACHE_H + + +#include + + +namespace xmrig { + + +class OclCache +{ +public: + + +private: + void createDirectory() const; + static std::string prefix(); +}; + + +} // namespace xmrig + + +#endif /* XMRIG_OCLCACHE_H */ diff --git a/src/backend/opencl/OclCache_unix.cpp b/src/backend/opencl/OclCache_unix.cpp new file mode 100644 index 00000000..0d97ea07 --- /dev/null +++ b/src/backend/opencl/OclCache_unix.cpp @@ -0,0 +1,42 @@ +/* XMRig + * Copyright 2010 Jeff Garzik + * Copyright 2012-2014 pooler + * Copyright 2014 Lucas Jones + * Copyright 2014-2016 Wolf9466 + * Copyright 2016 Jay D Dee + * Copyright 2017-2018 XMR-Stak , + * Copyright 2018-2019 SChernykh + * Copyright 2016-2019 XMRig , + * + * 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 3 of the License, 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 this program. If not, see . + */ + +#include +#include + + +#include "backend/opencl/OclCache.h" + + +void xmrig::OclCache::createDirectory() const +{ + std::string path = prefix() + "/.cache"; + mkdir(path.c_str(), 0744); +} + + +std::string xmrig::OclCache::prefix() +{ + return "."; +} diff --git a/src/backend/opencl/OclCache_win.cpp b/src/backend/opencl/OclCache_win.cpp new file mode 100644 index 00000000..4e473a57 --- /dev/null +++ b/src/backend/opencl/OclCache_win.cpp @@ -0,0 +1,52 @@ +/* XMRig + * Copyright 2010 Jeff Garzik + * Copyright 2012-2014 pooler + * Copyright 2014 Lucas Jones + * Copyright 2014-2016 Wolf9466 + * Copyright 2016 Jay D Dee + * Copyright 2017-2018 XMR-Stak , + * Copyright 2018-2019 SChernykh + * Copyright 2016-2019 XMRig , + * + * 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 3 of the License, 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 this program. If not, see . + */ + + +#include +#include +#include + + +#include "backend/opencl/OclCache.h" + + +void xmrig::OclCache::createDirectory() const +{ + std::string path = prefix() + "/xmrig"; + _mkdir(path.c_str()); + + path += "/.cache"; + _mkdir(path.c_str()); +} + + +std::string xmrig::OclCache::prefix() +{ + char path[MAX_PATH + 1]; + if (SHGetSpecialFolderPathA(HWND_DESKTOP, path, CSIDL_LOCAL_APPDATA, FALSE)) { + return path; + } + + return "."; +} diff --git a/src/backend/opencl/opencl.cmake b/src/backend/opencl/opencl.cmake index 43218bf8..5d64d191 100644 --- a/src/backend/opencl/opencl.cmake +++ b/src/backend/opencl/opencl.cmake @@ -5,6 +5,7 @@ if (WITH_OPENCL) set(HEADERS_BACKEND_OPENCL src/backend/opencl/OclBackend.h + src/backend/opencl/OclCache.h src/backend/opencl/OclConfig.h src/backend/opencl/OclLaunchData.h src/backend/opencl/OclThread.h @@ -18,6 +19,7 @@ if (WITH_OPENCL) set(SOURCES_BACKEND_OPENCL src/backend/opencl/OclBackend.cpp + src/backend/opencl/OclCache.cpp src/backend/opencl/OclConfig.cpp src/backend/opencl/OclLaunchData.cpp src/backend/opencl/OclThread.cpp @@ -27,6 +29,12 @@ if (WITH_OPENCL) src/backend/opencl/wrappers/OclLib.cpp src/backend/opencl/wrappers/OclPlatform.cpp ) + + if (WIN32) + list(APPEND SOURCES_BACKEND_OPENCL src/backend/opencl/OclCache_win.cpp) + else() + list(APPEND SOURCES_BACKEND_OPENCL src/backend/opencl/OclCache_unix.cpp) + endif() else() remove_definitions(/DXMRIG_FEATURE_OPENCL)