Skip to content
Draft
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions include/chia/copy.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,22 @@
#include <cstdio>
#include <cstdint>

#ifdef __linux__
#include <filesystem>
namespace fs = std::filesystem;
#endif

inline
uint64_t copy_file(const std::string& src_path, const std::string& dst_path)
{
#ifdef __linux__
int plotsize = 109000000000
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure that number fits into an int lol
you need uint64_t here

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it const uint64_t too

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I was wondering about that! I guess it would be better to get the real size value but just put a rough value for now

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not a constant anyways, all good

fs::space_info tmp = fs::space(dst_path);
if(tmp.available < plotsize) {
throw std::runtime_error("Destination does not have enough available disk space left");
// some code to switch to alternative destination dirs could be here
}
#endif
FILE* src = fopen(src_path.c_str(), "rb");
if(!src) {
throw std::runtime_error("fopen() failed");
Expand Down