updated build system
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
This commit is contained in:
@ -27,55 +27,56 @@
|
||||
#include "utils/string.hpp"
|
||||
|
||||
namespace repertory::utils::file {
|
||||
auto file::attach_file(native_handle handle,
|
||||
bool read_only) -> std::unique_ptr<i_file> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
|
||||
try {
|
||||
std::string path;
|
||||
|
||||
#if defined(_WIN32)
|
||||
path.resize(repertory::max_path_length + 1);
|
||||
::GetFinalPathNameByHandleA(handle, path.data(),
|
||||
static_cast<DWORD>(path.size()),
|
||||
FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
|
||||
#else // !defined(_WIN32)
|
||||
path.resize(repertory::max_path_length + 1);
|
||||
|
||||
#if defined(__APPLE__)
|
||||
fcntl(handle, F_GETPATH, source_path.data());
|
||||
#else // !defined(__APPLE__)
|
||||
readlink(("/proc/self/fd/" + std::to_string(handle)).c_str(), path.data(),
|
||||
path.size());
|
||||
#endif // defined(__APPLE__)
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
path = path.c_str();
|
||||
|
||||
#if defined(_WIN32)
|
||||
auto *ptr = _fdopen(
|
||||
static_cast<int>(_open_osfhandle(reinterpret_cast<intptr_t>(handle),
|
||||
read_only ? _O_RDONLY : _O_RDWR)),
|
||||
read_only ? "rb" : "rb+");
|
||||
#else // !defined(_WIN32)
|
||||
auto *ptr = fdopen(handle, read_only ? "rb" : "rb+");
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
return std::unique_ptr<i_file>(new file{
|
||||
file_t{ptr},
|
||||
utils::path::absolute(path),
|
||||
read_only,
|
||||
});
|
||||
} catch (const std::exception &e) {
|
||||
utils::error::handle_exception(function_name, e);
|
||||
} catch (...) {
|
||||
utils::error::handle_exception(function_name);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
// auto file::attach_file(native_handle handle,
|
||||
// bool read_only) -> std::unique_ptr<i_file> {
|
||||
// static constexpr const std::string_view function_name{
|
||||
// static_cast<const char *>(__FUNCTION__),
|
||||
// };
|
||||
//
|
||||
// try {
|
||||
// std::string path;
|
||||
//
|
||||
// #if defined(_WIN32)
|
||||
// path.resize(repertory::max_path_length + 1);
|
||||
// ::GetFinalPathNameByHandleA(handle, path.data(),
|
||||
// static_cast<DWORD>(path.size()),
|
||||
// FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
|
||||
// #else // !defined(_WIN32)
|
||||
// path.resize(repertory::max_path_length + 1);
|
||||
//
|
||||
// #if defined(__APPLE__)
|
||||
// fcntl(handle, F_GETPATH, source_path.data());
|
||||
// #else // !defined(__APPLE__)
|
||||
// readlink(("/proc/self/fd/" + std::to_string(handle)).c_str(),
|
||||
// path.data(),
|
||||
// path.size());
|
||||
// #endif // defined(__APPLE__)
|
||||
// #endif // defined(_WIN32)
|
||||
//
|
||||
// path = path.c_str();
|
||||
//
|
||||
// #if defined(_WIN32)
|
||||
// auto *ptr = _fdopen(
|
||||
// static_cast<int>(_open_osfhandle(reinterpret_cast<intptr_t>(handle),
|
||||
// read_only ? _O_RDONLY : _O_RDWR)),
|
||||
// read_only ? "rb" : "rb+");
|
||||
// #else // !defined(_WIN32)
|
||||
// auto *ptr = fdopen(handle, read_only ? "rb" : "rb+");
|
||||
// #endif // defined(_WIN32)
|
||||
//
|
||||
// return std::unique_ptr<i_file>(new file{
|
||||
// file_t{ptr},
|
||||
// utils::path::absolute(path),
|
||||
// read_only,
|
||||
// });
|
||||
// } catch (const std::exception &e) {
|
||||
// utils::error::handle_exception(function_name, e);
|
||||
// } catch (...) {
|
||||
// utils::error::handle_exception(function_name);
|
||||
// }
|
||||
//
|
||||
// return nullptr;
|
||||
// }
|
||||
|
||||
void file::open() {
|
||||
if (not is_file(path_)) {
|
||||
|
@ -22,8 +22,8 @@
|
||||
#include "utils/file.hpp"
|
||||
|
||||
namespace repertory::utils::file {
|
||||
auto thread_file::attach_file(native_handle handle,
|
||||
bool read_only) -> std::unique_ptr<i_file> {}
|
||||
// auto thread_file::attach_file(native_handle handle,
|
||||
// bool read_only) -> std::unique_ptr<i_file> {}
|
||||
|
||||
auto thread_file::open_file(std::string_view path,
|
||||
bool read_only) -> std::unique_ptr<i_file> {}
|
||||
|
Reference in New Issue
Block a user