aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorilikepugs <ilikepugs@yandex-team.com>2024-02-21 20:06:21 +0300
committerilikepugs <ilikepugs@yandex-team.com>2024-02-21 20:18:38 +0300
commit051211a92f37a8d0c79ffa75decab9c9793eae4c (patch)
treef0863d8873f73391f7705cb38cdbeee3569e507c
parent2e3fc003e4f7be7afd93779b51eab2d227773bc2 (diff)
downloadydb-051211a92f37a8d0c79ffa75decab9c9793eae4c.tar.gz
Fix case when 'arc export' not set executable bit
В этом ревью сделано две вещи: 1. В util/system/fs добавилась функция SetExecutable 2. В TDataFetcher добавилась функция FetchEntry, аналог FetchBlob/FetchTree но с пробросом метаинформации 06888e7a37526ef46789eafd29bd2728661d8be7
-rw-r--r--util/system/fs.cpp23
-rw-r--r--util/system/fs.h7
2 files changed, 28 insertions, 2 deletions
diff --git a/util/system/fs.cpp b/util/system/fs.cpp
index b848abac8a..808bc0b7b6 100644
--- a/util/system/fs.cpp
+++ b/util/system/fs.cpp
@@ -8,12 +8,13 @@
#include <errno.h>
#endif
+#include <util/folder/iterator.h>
+#include <util/folder/path.h>
#include <util/generic/yexception.h>
#include <util/memory/tempbuf.h>
#include <util/stream/file.h>
-#include <util/folder/iterator.h>
#include <util/system/fstat.h>
-#include <util/folder/path.h>
+#include <util/system/sysstat.h>
bool NFs::Remove(const TString& path) {
#if defined(_win_)
@@ -23,6 +24,24 @@ bool NFs::Remove(const TString& path) {
#endif
}
+bool NFs::SetExecutable(const TString& path, bool exec) {
+#ifdef _unix_
+ TFileStat stat(path);
+ ui32 mode = stat.Mode;
+ if (exec) {
+ mode |= S_IXUSR | S_IXGRP | S_IXOTH;
+ } else {
+ mode &= ~(S_IXUSR | S_IXGRP | S_IXOTH);
+ }
+ if (stat.Mode != 0 && mode != stat.Mode) {
+ return !Chmod(path.c_str(), mode);
+ }
+#endif
+ Y_UNUSED(exec);
+ Y_UNUSED(path);
+ return true;
+}
+
void NFs::RemoveRecursive(const TString& path) {
static const TStringBuf errStr = "error while removing ";
diff --git a/util/system/fs.h b/util/system/fs.h
index a28a6d84fb..f4ab746aa3 100644
--- a/util/system/fs.h
+++ b/util/system/fs.h
@@ -23,6 +23,13 @@ namespace NFs {
Y_DECLARE_FLAGS(EFilePermissions, EFilePermission);
+ /// Add executable bit
+ ///
+ /// @param[in] path Path to mark as executable
+ /// @param[in] exec New value of execution bit
+ /// @returns true if bit has changed or false otherwise
+ bool SetExecutable(const TString& path, bool exec);
+
/// Remove a file or empty directory
///
/// @param[in] path Path to file or directory