return std::string(without_ext).append(new_ext.data(), new_ext.length());
}
+#ifdef FILE_CLONING_SUPPORTED
void
clone_file(const std::string& src, const std::string& dest, bool via_tmp_file)
{
-#ifdef FILE_CLONING_SUPPORTED
-
# if defined(__linux__)
Fd src_fd(open(src.c_str(), O_RDONLY));
if (!src_fd) {
(void)via_tmp_file;
throw Error(strerror(EOPNOTSUPP));
# endif
-
-#else // FILE_CLONING_SUPPORTED
-
- (void)src;
- (void)dest;
- (void)via_tmp_file;
- throw Error(strerror(EOPNOTSUPP));
-
-#endif // FILE_CLONING_SUPPORTED
}
+#endif // FILE_CLONING_SUPPORTED
void
clone_hard_link_or_copy_file(const Context& ctx,
bool via_tmp_file)
{
if (ctx.config.file_clone()) {
+#ifdef FILE_CLONING_SUPPORTED
log("Cloning {} to {}", source, dest);
try {
clone_file(source, dest, via_tmp_file);
} catch (Error& e) {
log("Failed to clone: {}", e.what());
}
+#else
+ log("Not cloning {} to {} since it's unsupported");
+#endif
}
if (ctx.config.hard_link()) {
unlink(dest.c_str());