33 lines
534 B
C++
33 lines
534 B
C++
// TJP COPYRIGHT HEADER
|
|
|
|
|
|
#ifdef TJP_CORE_HEADER_ONLY
|
|
#pragma once
|
|
#endif
|
|
|
|
#include <tjp/core/header_only/compile.h>
|
|
|
|
#include "move.hpp"
|
|
#include <tjp/core/exception/Exception.hpp>
|
|
|
|
#include <cstdio>
|
|
|
|
namespace tjp::core::file {
|
|
|
|
TJP_CORE_HEADER_ONLY_INLINE
|
|
bool move(const String &from, const String &to)
|
|
{
|
|
return std::rename(from.c_str(), to.c_str()) != 0;
|
|
}
|
|
|
|
TJP_CORE_HEADER_ONLY_INLINE
|
|
void require_move(const String &from, const String &to)
|
|
{
|
|
if (!move(from, to))
|
|
{
|
|
throw Exception { "Move failed" };
|
|
}
|
|
}
|
|
|
|
} // namespace
|