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()) {
22 string fullPath = string(dir) +
"/" + string(filenamePreferred);
23 actualName_ = fullPath;
27 fd_ = ::open(actualName_.c_str(), O_WRONLY | O_CREAT | O_EXCL
28 , S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
34 actualName_ = fullPath +
" (" + to_string(++postfix) +
")";
36 }
while(postfix < 256);
40 explicit operator bool()
const {
44 bool writeDone()
const {
45 return fullLen_ == len_;
48 size_t write(
void const* mem,
size_t l) {
49 auto wl = std::min(l, fullLen_ - len_);
52 res = ::write(fd_, mem, wl);
54 if (res > 0) len_ += res;
63 char const* name()
const {
64 return actualName_.c_str();
67 size_t fullLen()
const {
73 std::string actualName_;
Definition: DownloadFile.hpp:12
Definition: TypedString.hpp:76