mirror of https://github.com/Icinga/icinga2.git
parent
6bfd6312f5
commit
9227d990dc
|
@ -30,6 +30,9 @@
|
|||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
#include <ios>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
# include <pthread_np.h>
|
||||
|
@ -638,6 +641,21 @@ bool Utility::MkDirP(const String& path, int flags)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool Utility::CopyFile(const String& source, const String& target)
|
||||
{
|
||||
if (Utility::PathExists(target)) {
|
||||
Log(LogWarning, "Utility")
|
||||
<< "Target file '" << target << "' already exists.";
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ifstream ifs(source.CStr(), std::ios::binary);
|
||||
std::ofstream ofs(target.CStr(), std::ios::binary);
|
||||
|
||||
ofs << ifs.rdbuf();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
void Utility::SetNonBlocking(int fd)
|
||||
|
|
|
@ -137,6 +137,8 @@ public:
|
|||
|
||||
static bool PathExists(const String& path);
|
||||
|
||||
static bool CopyFile(const String& source, const String& target);
|
||||
|
||||
private:
|
||||
Utility(void);
|
||||
|
||||
|
|
Loading…
Reference in New Issue