tools/ceph-dencoder: print human-readable error message

if $CEPH_LIB is not specified.

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2021-04-05 16:28:11 +08:00
parent 2365f265b1
commit 195d1e8c8e

View File

@ -23,6 +23,7 @@ namespace fs = std::filesystem;
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif
#include <iomanip>
#include "ceph_ver.h"
#include "include/types.h"
@ -105,6 +106,12 @@ vector<DencoderPlugin> load_plugins()
if (auto ceph_lib = getenv("CEPH_LIB"); ceph_lib) {
mod_dir = ceph_lib;
}
if (!fs::is_directory(mod_dir)) {
std::cerr << "unable to load dencoders from "
<< std::quoted(mod_dir.native()) << ". "
<< "it is not a directory." << std::endl;
return {};
}
vector<DencoderPlugin> dencoder_plugins;
for (auto& entry : fs::directory_iterator(mod_dir)) {
static const string_view DENC_MOD_PREFIX = "denc-mod-";