refactor
This commit is contained in:
@ -33,49 +33,50 @@ auto directory_iterator::fill_buffer(const remote::file_offset &offset,
|
||||
-> int {
|
||||
REPERTORY_USES_FUNCTION_NAME();
|
||||
|
||||
if (offset < items_.size()) {
|
||||
try {
|
||||
std::string item_name;
|
||||
struct stat st{};
|
||||
struct stat *pst = nullptr;
|
||||
switch (offset) {
|
||||
case 0: {
|
||||
item_name = ".";
|
||||
} break;
|
||||
|
||||
case 1: {
|
||||
item_name = "..";
|
||||
} break;
|
||||
|
||||
default: {
|
||||
const auto &item = items_[offset];
|
||||
item_name = utils::path::strip_to_file_name(item.api_path);
|
||||
populate_stat(item.api_path, item.size, item.meta, item.directory, &st);
|
||||
pst = &st;
|
||||
} break;
|
||||
}
|
||||
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
if (filler_function(buffer, item_name.data(), pst,
|
||||
static_cast<off_t>(offset + 1),
|
||||
FUSE_FILL_DIR_PLUS) != 0) {
|
||||
#else // FUSE_USE_VERSION < 30
|
||||
if (filler_function(buffer, item_name.data(), pst,
|
||||
static_cast<off_t>(offset + 1)) != 0) {
|
||||
#endif // FUSE_USE_VERSION >= 30
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
utils::error::raise_error(function_name, e,
|
||||
"failed to fill fuse directory buffer");
|
||||
}
|
||||
|
||||
return 0;
|
||||
if (offset >= items_.size()) {
|
||||
errno = 120;
|
||||
return -1;
|
||||
}
|
||||
|
||||
errno = 120;
|
||||
return -1;
|
||||
try {
|
||||
std::string item_name;
|
||||
struct stat st{};
|
||||
struct stat *pst = nullptr;
|
||||
switch (offset) {
|
||||
case 0: {
|
||||
item_name = ".";
|
||||
} break;
|
||||
|
||||
case 1: {
|
||||
item_name = "..";
|
||||
} break;
|
||||
|
||||
default: {
|
||||
const auto &item = items_[offset];
|
||||
item_name = utils::path::strip_to_file_name(item.api_path);
|
||||
populate_stat(item.api_path, item.size, item.meta, item.directory, &st);
|
||||
pst = &st;
|
||||
} break;
|
||||
}
|
||||
|
||||
#if FUSE_USE_VERSION >= 30
|
||||
if (filler_function(buffer, item_name.data(), pst,
|
||||
static_cast<off_t>(offset + 1),
|
||||
FUSE_FILL_DIR_PLUS) != 0)
|
||||
#else // FUSE_USE_VERSION < 30
|
||||
if (filler_function(buffer, item_name.data(), pst,
|
||||
static_cast<off_t>(offset + 1)) != 0)
|
||||
#endif // FUSE_USE_VERSION >= 30
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
utils::error::raise_error(function_name, e,
|
||||
"failed to fill fuse directory buffer");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif // !defined(_WIN32)
|
||||
|
||||
|
Reference in New Issue
Block a user