Merge pull request #2575 from unxed/wiki_help
[far2l.git] / utils / src / WriteWholeFile.cpp
blob81ff48964933fe78cd0509060cd7ad84a8c04613
1 #include <fcntl.h>
2 #include "utils.h"
3 #include "ScopeHelpers.h"
5 bool WriteWholeFile(const char *path, const void *content, size_t length, unsigned int mode)
7 FDScope fd(path, O_RDWR | O_CREAT | O_TRUNC, mode);
8 if (!fd.Valid())
9 return false;
11 return WriteAll(fd, content, length, 0x100000) == length;
14 bool WriteWholeFile(const char *path, const std::string &content, unsigned int mode)
16 return WriteWholeFile(path, content.data(), content.size(), mode);