1 #include "hmbdc/Copyright.hpp" 11 namespace hmbdc {
namespace os {
19 bool open(
char const* dir,
char const* filenamePreferred
20 ,
size_t len = std::numeric_limits<size_t>::max()) {
21 std::string fullPath = std::string(dir) +
"/" + std::string(filenamePreferred);
22 actualName_ = fullPath;
26 fd_ = ::open(actualName_.c_str(), O_WRONLY | O_CREAT | O_EXCL
27 , S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
33 actualName_ = fullPath +
" (" + std::to_string(++postfix) +
")";
35 }
while(postfix < 256);
39 explicit operator bool()
const {
43 bool writeDone()
const {
44 return fullLen_ == len_;
47 size_t write(
void const* mem,
size_t l) {
48 auto wl = std::min(l, fullLen_ - len_);
51 res = ::write(fd_, mem, wl);
53 if (res > 0) len_ += res;
62 char const* name()
const {
63 return actualName_.c_str();
66 size_t fullLen()
const {
72 std::string actualName_;
Definition: DownloadFile.hpp:12