diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /util/system/compat.cpp | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'util/system/compat.cpp')
-rw-r--r-- | util/system/compat.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/util/system/compat.cpp b/util/system/compat.cpp new file mode 100644 index 0000000000..18fbfa296a --- /dev/null +++ b/util/system/compat.cpp @@ -0,0 +1,45 @@ +#include "compat.h" +#include "defaults.h" +#include "progname.h" + +#include <cctype> +#include <cerrno> +#include <cstdio> +#include <cstring> +#include <cstdarg> +#include <cstdlib> + +#include <util/generic/string.h> + +#ifdef _win_ + #include "winint.h" + #include <io.h> +#endif + +#ifndef HAVE_NATIVE_GETPROGNAME +const char* getprogname() { + return GetProgramName().data(); +} +#endif + +#ifdef _win_ + +void sleep(i64 len) { + Sleep((unsigned long)len * 1000); +} + +void usleep(i64 len) { + Sleep((unsigned long)len / 1000); +} + + #include <fcntl.h> +int ftruncate(int fd, i64 length) { + return _chsize_s(fd, length); +} +int truncate(const char* name, i64 length) { + int fd = ::_open(name, _O_WRONLY); + int ret = ftruncate(fd, length); + ::close(fd); + return ret; +} +#endif |