From 47324ff0713d888c6d89205f81e530d737b1c8ae Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 9 Jan 2018 14:25:56 +0100 Subject: [PATCH] feat(utils): add new fs namespace with copy function --- include/CMakeLists.txt | 1 + src/CMakeLists.txt | 1 + src/utils/fs.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 src/utils/fs.cpp diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index a332c1bab..eb505c75c 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -100,6 +100,7 @@ set(ENUMS_HEADER_FILES set(UTILS_HEADER_FILES enum-generator.h enum-mask.h + fs.h general.h magic-macros.h traits.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1dc090fe6..1bb99e7be 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -252,6 +252,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES sal/refer-op.cpp sal/register-op.cpp sal/sal.cpp + utils/fs.cpp utils/general.cpp utils/payload-type-handler.cpp utils/utils.cpp diff --git a/src/utils/fs.cpp b/src/utils/fs.cpp new file mode 100644 index 000000000..235247cb2 --- /dev/null +++ b/src/utils/fs.cpp @@ -0,0 +1,39 @@ +/* + * fs.cpp + * Copyright (C) 2010-2017 Belledonne Communications SARL + * + * 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 + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include + +#include "linphone/utils/fs.h" + +// ============================================================================= + +using namespace std; + +LINPHONE_BEGIN_NAMESPACE + +namespace Fs { + bool copy (const string &srcPath, const string &destPath) { + ifstream src(srcPath, ios::binary); + ofstream dest(destPath, ios::binary); + dest << src.rdbuf(); + return !dest.fail(); + } +} + +LINPHONE_END_NAMESPACE