fixes
This commit is contained in:
@ -39,20 +39,19 @@ auto db_delete::dump() const -> std::string {
|
||||
}
|
||||
|
||||
auto db_delete::go() const -> db_result<context> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
|
||||
sqlite3_stmt *stmt_ptr{nullptr};
|
||||
auto query_str = dump();
|
||||
auto res = sqlite3_prepare_v2(&context_->db3, query_str.c_str(), -1,
|
||||
&stmt_ptr, nullptr);
|
||||
context_->stmt = db3_stmt_t{
|
||||
stmt_ptr,
|
||||
sqlite3_statement_deleter(),
|
||||
};
|
||||
|
||||
if (res != SQLITE_OK) {
|
||||
return {context_, res};
|
||||
}
|
||||
|
||||
context_->stmt.reset(stmt_ptr);
|
||||
|
||||
for (std::int32_t idx = 0;
|
||||
idx < static_cast<std::int32_t>(context_->where_values.size()); idx++) {
|
||||
res = std::visit(
|
||||
|
@ -68,12 +68,15 @@ auto db_insert::go() const -> db_result<context> {
|
||||
auto query_str = dump();
|
||||
auto res = sqlite3_prepare_v2(&context_->db3, query_str.c_str(), -1,
|
||||
&stmt_ptr, nullptr);
|
||||
context_->stmt = db3_stmt_t{
|
||||
stmt_ptr,
|
||||
sqlite3_statement_deleter(),
|
||||
};
|
||||
|
||||
if (res != SQLITE_OK) {
|
||||
return {context_, res};
|
||||
}
|
||||
|
||||
context_->stmt.reset(stmt_ptr);
|
||||
|
||||
for (std::int32_t idx = 0;
|
||||
idx < static_cast<std::int32_t>(context_->values.size()); idx++) {
|
||||
res = std::visit(
|
||||
|
@ -85,20 +85,19 @@ auto db_select::dump() const -> std::string {
|
||||
}
|
||||
|
||||
auto db_select::go() const -> db_result<context> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
|
||||
sqlite3_stmt *stmt_ptr{nullptr};
|
||||
auto query_str = dump();
|
||||
auto res = sqlite3_prepare_v2(&context_->db3, query_str.c_str(), -1,
|
||||
&stmt_ptr, nullptr);
|
||||
context_->stmt = db3_stmt_t{
|
||||
stmt_ptr,
|
||||
sqlite3_statement_deleter(),
|
||||
};
|
||||
|
||||
if (res != SQLITE_OK) {
|
||||
return {context_, res};
|
||||
}
|
||||
|
||||
context_->stmt.reset(stmt_ptr);
|
||||
|
||||
for (std::int32_t idx = 0;
|
||||
idx < static_cast<std::int32_t>(context_->where_values.size()); idx++) {
|
||||
res = std::visit(
|
||||
|
@ -64,18 +64,18 @@ auto db_update::dump() const -> std::string {
|
||||
}
|
||||
|
||||
auto db_update::go() const -> db_result<context> {
|
||||
static constexpr const std::string_view function_name{
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
|
||||
sqlite3_stmt *stmt_ptr{nullptr};
|
||||
auto query_str = dump();
|
||||
auto res = sqlite3_prepare_v2(&context_->db3, query_str.c_str(), -1,
|
||||
&stmt_ptr, nullptr);
|
||||
context_->stmt = db3_stmt_t{
|
||||
stmt_ptr,
|
||||
sqlite3_statement_deleter(),
|
||||
};
|
||||
|
||||
if (res != SQLITE_OK) {
|
||||
return {context_, res};
|
||||
}
|
||||
context_->stmt.reset(stmt_ptr);
|
||||
|
||||
for (std::int32_t idx = 0;
|
||||
idx < static_cast<std::int32_t>(context_->column_values.size()); idx++) {
|
||||
|
@ -119,9 +119,11 @@ void file::open() {
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
file_.reset(_fsopen(path_.c_str(), read_only_ ? "rb" : "rb+", _SH_DENYNO));
|
||||
file_ = file_t(_fsopen(path_.c_str(), read_only_ ? "rb" : "rb+", _SH_DENYNO),
|
||||
file_deleter());
|
||||
#else // !defined(_WIN32)
|
||||
file_.reset(fopen(path_.c_str(), read_only_ ? "rb" : "rb+"));
|
||||
file_ =
|
||||
file_t(fopen(path_.c_str(), read_only_ ? "rb" : "rb+"), file_deleter());
|
||||
#endif // defined(_WIN32)
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,14 @@ auto smb_directory::open(std::string_view host, std::string_view user,
|
||||
};
|
||||
|
||||
try {
|
||||
smb_session_t session{smb_session_new(), smb_session_deleter};
|
||||
netbios_ns_t ns{netbios_ns_new()};
|
||||
smb_session_t session{
|
||||
smb_session_new(),
|
||||
smb_session_deleter(),
|
||||
};
|
||||
netbios_ns_t ns{
|
||||
netbios_ns_new(),
|
||||
netbios_ns_deleter(),
|
||||
};
|
||||
|
||||
sockaddr_in addr{};
|
||||
|
||||
@ -137,7 +143,9 @@ auto smb_directory::count(bool recursive) const -> std::uint64_t {
|
||||
}
|
||||
|
||||
smb_stat_list_t list{
|
||||
smb_find(session_.get(), tid_, smb_create_search_path(path_).c_str())};
|
||||
smb_find(session_.get(), tid_, smb_create_search_path(path_).c_str()),
|
||||
smb_stat_list_deleter(),
|
||||
};
|
||||
auto count = smb_stat_list_count(list.get());
|
||||
|
||||
if (not recursive) {
|
||||
@ -247,8 +255,11 @@ auto smb_directory::exists() const -> bool {
|
||||
throw std::runtime_error("session not found|" + path_);
|
||||
}
|
||||
|
||||
smb_stat_t st{smb_fstat(session_.get(), tid_,
|
||||
smb_create_relative_path(path_).c_str())};
|
||||
smb_stat_t st{
|
||||
smb_fstat(session_.get(), tid_,
|
||||
smb_create_relative_path(path_).c_str()),
|
||||
smb_stat_deleter(),
|
||||
};
|
||||
if (not st) {
|
||||
return false;
|
||||
}
|
||||
@ -275,7 +286,10 @@ auto smb_directory::get_directory(std::string_view path) const
|
||||
}
|
||||
|
||||
auto rel_path = smb_create_and_validate_relative_path(path_, path);
|
||||
smb_stat_t st{smb_fstat(session_.get(), tid_, rel_path.c_str())};
|
||||
smb_stat_t st{
|
||||
smb_fstat(session_.get(), tid_, rel_path.c_str()),
|
||||
smb_stat_deleter(),
|
||||
};
|
||||
if (not st) {
|
||||
throw std::runtime_error("failed to stat directory|" + rel_path);
|
||||
}
|
||||
@ -313,7 +327,9 @@ auto smb_directory::get_directories() const -> std::vector<fs_directory_t> {
|
||||
}
|
||||
|
||||
smb_stat_list_t list{
|
||||
smb_find(session_.get(), tid_, smb_create_search_path(path_).c_str())};
|
||||
smb_find(session_.get(), tid_, smb_create_search_path(path_).c_str()),
|
||||
smb_stat_list_deleter(),
|
||||
};
|
||||
if (not list) {
|
||||
throw std::runtime_error("failed to get directory list|" + path_);
|
||||
}
|
||||
@ -365,7 +381,10 @@ auto smb_directory::get_file(std::string_view path) const -> fs_file_t {
|
||||
}
|
||||
|
||||
auto rel_path = smb_create_and_validate_relative_path(path_, path);
|
||||
smb_stat_t st{smb_fstat(session_.get(), tid_, rel_path.c_str())};
|
||||
smb_stat_t st{
|
||||
smb_fstat(session_.get(), tid_, rel_path.c_str()),
|
||||
smb_stat_deleter(),
|
||||
};
|
||||
if (not st) {
|
||||
throw std::runtime_error("failed to stat file|" + rel_path);
|
||||
}
|
||||
@ -398,7 +417,9 @@ auto smb_directory::get_files() const -> std::vector<fs_file_t> {
|
||||
}
|
||||
|
||||
smb_stat_list_t list{
|
||||
smb_find(session_.get(), tid_, smb_create_search_path(path_).c_str())};
|
||||
smb_find(session_.get(), tid_, smb_create_search_path(path_).c_str()),
|
||||
smb_stat_list_deleter(),
|
||||
};
|
||||
if (not list) {
|
||||
throw std::runtime_error("failed to get file list|" + path_);
|
||||
}
|
||||
@ -440,7 +461,9 @@ auto smb_directory::get_items() const -> std::vector<fs_item_t> {
|
||||
}
|
||||
|
||||
smb_stat_list_t list{
|
||||
smb_find(session_.get(), tid_, smb_create_search_path(path_).c_str())};
|
||||
smb_find(session_.get(), tid_, smb_create_search_path(path_).c_str()),
|
||||
smb_stat_list_deleter(),
|
||||
};
|
||||
if (not list) {
|
||||
throw std::runtime_error("failed to get item list|" + path_);
|
||||
}
|
||||
|
@ -70,8 +70,11 @@ auto smb_file::exists() const -> bool {
|
||||
throw std::runtime_error("session not found|" + path_);
|
||||
}
|
||||
|
||||
smb_stat_t st{smb_fstat(session_.get(), tid_,
|
||||
smb_create_relative_path(path_).c_str())};
|
||||
smb_stat_t st{
|
||||
smb_fstat(session_.get(), tid_,
|
||||
smb_create_relative_path(path_).c_str()),
|
||||
smb_stat_deleter(),
|
||||
};
|
||||
if (not st) {
|
||||
return false;
|
||||
}
|
||||
@ -113,7 +116,10 @@ auto smb_file::get_time(smb_session *session, smb_tid tid, std::string path,
|
||||
}
|
||||
|
||||
auto rel_path = smb_create_relative_path(path);
|
||||
smb_stat_t st{smb_fstat(session, tid, rel_path.c_str())};
|
||||
smb_stat_t st{
|
||||
smb_fstat(session, tid, rel_path.c_str()),
|
||||
smb_stat_deleter(),
|
||||
};
|
||||
if (not st) {
|
||||
throw std::runtime_error("failed to stat directory|" + rel_path);
|
||||
}
|
||||
@ -368,7 +374,10 @@ auto smb_file::size() const -> std::optional<std::uint64_t> {
|
||||
}
|
||||
|
||||
auto rel_path = smb_create_relative_path(path_);
|
||||
smb_stat_t st{smb_fstat(session_.get(), tid_, rel_path.c_str())};
|
||||
smb_stat_t st{
|
||||
smb_fstat(session_.get(), tid_, rel_path.c_str()),
|
||||
smb_stat_deleter(),
|
||||
};
|
||||
if (not st) {
|
||||
throw std::runtime_error("failed to stat directory|" + rel_path);
|
||||
}
|
||||
|
Reference in New Issue
Block a user