refactor
This commit is contained in:
@ -81,49 +81,49 @@ auto directory_iterator::fill_buffer(const remote::file_offset &offset,
|
|||||||
#endif // !defined(_WIN32)
|
#endif // !defined(_WIN32)
|
||||||
|
|
||||||
auto directory_iterator::get(std::size_t offset, std::string &item) -> int {
|
auto directory_iterator::get(std::size_t offset, std::string &item) -> int {
|
||||||
if (offset < items_.size()) {
|
if (offset >= items_.size()) {
|
||||||
item = items_[offset].api_path;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
errno = 120;
|
errno = 120;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto directory_iterator::get_directory_item(std::size_t offset,
|
item = items_[offset].api_path;
|
||||||
directory_item &di) -> api_error {
|
return 0;
|
||||||
if (offset < items_.size()) {
|
|
||||||
di = items_[offset];
|
|
||||||
return api_error::success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto directory_iterator::get_directory_item(std::size_t offset,
|
||||||
|
directory_item &di) -> api_error {
|
||||||
|
if (offset >= items_.size()) {
|
||||||
return api_error::directory_end_of_files;
|
return api_error::directory_end_of_files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
di = items_[offset];
|
||||||
|
return api_error::success;
|
||||||
|
}
|
||||||
|
|
||||||
auto directory_iterator::get_directory_item(const std::string &api_path,
|
auto directory_iterator::get_directory_item(const std::string &api_path,
|
||||||
directory_item &di) -> api_error {
|
directory_item &di) -> api_error {
|
||||||
auto iter =
|
auto iter =
|
||||||
std::find_if(items_.begin(), items_.end(), [&](const auto &item) -> bool {
|
std::find_if(items_.begin(), items_.end(), [&](const auto &item) -> bool {
|
||||||
return api_path == item.api_path;
|
return api_path == item.api_path;
|
||||||
});
|
});
|
||||||
if (iter != items_.end()) {
|
if (iter == items_.end()) {
|
||||||
|
return api_error::item_not_found;
|
||||||
|
}
|
||||||
|
|
||||||
di = *iter;
|
di = *iter;
|
||||||
return api_error::success;
|
return api_error::success;
|
||||||
}
|
}
|
||||||
|
|
||||||
return api_error::item_not_found;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto directory_iterator::get_json(std::size_t offset, json &item) -> int {
|
auto directory_iterator::get_json(std::size_t offset, json &item) -> int {
|
||||||
if (offset < items_.size()) {
|
if (offset >= items_.size()) {
|
||||||
item = json(items_.at(offset));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
errno = 120;
|
errno = 120;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
item = json(items_.at(offset));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
auto directory_iterator::get_next_directory_offset(
|
auto directory_iterator::get_next_directory_offset(
|
||||||
const std::string &api_path) const -> std::size_t {
|
const std::string &api_path) const -> std::size_t {
|
||||||
const auto iter = std::find_if(items_.begin(), items_.end(),
|
const auto iter = std::find_if(items_.begin(), items_.end(),
|
||||||
|
Reference in New Issue
Block a user