1 #include "hmbdc/Copyright.hpp" 10 namespace hmbdc {
namespace os {
19 bool open(
char const* dir,
char const* filenamePreferred,
size_t len) {
20 string fullPath = string(dir) +
"/" + string(filenamePreferred);
21 actualName_ = fullPath;
25 fd_ = ::open(actualName_.c_str(), O_WRONLY | O_CREAT | O_EXCL
26 , S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
32 actualName_ = fullPath +
" (" + to_string(++postfix) +
")";
34 }
while(postfix < 256);
38 explicit operator bool()
const {
42 bool writeDone()
const {
43 return fullLen_ == len_;
46 size_t write(
void const* mem,
size_t l) {
47 auto wl = min(l, fullLen_ - len_);
50 res = ::write(fd_, mem, wl);
52 if (res > 0) len_ += res;
61 char const* name()
const {
62 return actualName_.c_str();
65 size_t fullLen()
const {
Definition: DownloadFile.hpp:12
Definition: TypedString.hpp:74
Definition: Client.hpp:11