[internal] remove ghc::filesystem

pull/1265/head
Tim Stack 4 weeks ago
parent 9a1f383ce1
commit 53b883d015

@ -647,12 +647,6 @@ add_library(
mapbox/variant.hpp
mapbox/variant_io.hpp
mapbox/variant_visitor.hpp
ghc/filesystem.hpp
ghc/fs_fwd.hpp
ghc/fs_impl.hpp
ghc/fs_std.hpp
ghc/fs_std_fwd.hpp
ghc/fs_std_impl.hpp
ww898/cp_utf8.hpp
log_level_re.cc

@ -379,12 +379,6 @@ noinst_HEADERS = \
xpath_vtab.hh \
xterm_mouse.hh \
spookyhash/SpookyV2.h \
ghc/filesystem.hpp \
ghc/fs_fwd.hpp \
ghc/fs_impl.hpp \
ghc/fs_std.hpp \
ghc/fs_std_fwd.hpp \
ghc/fs_std_impl.hpp \
ww898/cp_utf8.hpp
nodist_libdiag_a_SOURCES = \

@ -52,7 +52,7 @@
#include "fmt/format.h"
#include "hasher.hh"
namespace fs = ghc::filesystem;
namespace fs = std::filesystem;
namespace archive_manager {
@ -269,7 +269,9 @@ extract(const std::string& filename, const extract_cb& cb)
}
}
if (file_count > 0) {
fs::last_write_time(done_path, std::chrono::system_clock::now());
auto now = std::filesystem::file_time_type{
std::chrono::system_clock::now().time_since_epoch()};
fs::last_write_time(done_path, now);
log_info("%s: archive has already been extracted!",
done_path.c_str());
return Ok();
@ -399,7 +401,8 @@ void
cleanup_cache()
{
(void) std::async(std::launch::async, []() {
auto now = std::chrono::system_clock::now();
auto now = std::filesystem::file_time_type{
std::chrono::system_clock::now().time_since_epoch()};
auto cache_path = archive_cache_path();
const auto& cfg = injector::get<const config&>();
std::vector<fs::path> to_remove;

@ -39,28 +39,28 @@
#include "base/file_range.hh"
#include "base/result.h"
#include "ghc/filesystem.hpp"
#include <filesystem>
#include "mapbox/variant.hpp"
namespace archive_manager {
struct extract_progress {
extract_progress(ghc::filesystem::path path, ssize_t total)
extract_progress(std::filesystem::path path, ssize_t total)
: ep_path(std::move(path)), ep_total_size(total)
{
}
const ghc::filesystem::path ep_path;
const std::filesystem::path ep_path;
const ssize_t ep_total_size;
std::atomic<size_t> ep_out_size{0};
};
using extract_cb
= std::function<extract_progress*(const ghc::filesystem::path&, ssize_t)>;
= std::function<extract_progress*(const std::filesystem::path&, ssize_t)>;
struct archive_info {
struct entry {
ghc::filesystem::path e_name;
std::filesystem::path e_name;
const char* e_mode;
time_t e_mtime;
std::optional<file_ssize_t> e_size;
@ -73,9 +73,9 @@ struct unknown_file {};
using describe_result = mapbox::util::variant<archive_info, unknown_file>;
Result<describe_result, std::string> describe(
const ghc::filesystem::path& filename);
const std::filesystem::path& filename);
ghc::filesystem::path filename_to_tmp_path(const std::string& filename);
std::filesystem::path filename_to_tmp_path(const std::string& filename);
using walk_result_t = Result<void, std::string>;
@ -90,8 +90,8 @@ using walk_result_t = Result<void, std::string>;
walk_result_t walk_archive_files(
const std::string& filename,
const extract_cb& cb,
const std::function<void(const ghc::filesystem::path&,
const ghc::filesystem::directory_entry&)>&);
const std::function<void(const std::filesystem::path&,
const std::filesystem::directory_entry&)>&);
void cleanup_cache();

@ -27,6 +27,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <fstream>
#include "fs_util.hh"
#include <stdlib.h>
@ -41,7 +43,7 @@ namespace lnav {
namespace filesystem {
std::string
escape_path(const ghc::filesystem::path& p)
escape_path(const std::filesystem::path& p)
{
auto p_str = p.string();
std::string retval;
@ -70,8 +72,8 @@ escape_path(const ghc::filesystem::path& p)
return retval;
}
Result<ghc::filesystem::path, std::string>
realpath(const ghc::filesystem::path& path)
Result<std::filesystem::path, std::string>
realpath(const std::filesystem::path& path)
{
char resolved[PATH_MAX];
auto rc = ::realpath(path.c_str(), resolved);
@ -80,11 +82,11 @@ realpath(const ghc::filesystem::path& path)
return Err(std::string(strerror(errno)));
}
return Ok(ghc::filesystem::path(resolved));
return Ok(std::filesystem::path(resolved));
}
Result<auto_fd, std::string>
create_file(const ghc::filesystem::path& path, int flags, mode_t mode)
create_file(const std::filesystem::path& path, int flags, mode_t mode)
{
auto fd = openp(path, flags | O_CREAT, mode);
@ -98,7 +100,7 @@ create_file(const ghc::filesystem::path& path, int flags, mode_t mode)
}
Result<auto_fd, std::string>
open_file(const ghc::filesystem::path& path, int flags)
open_file(const std::filesystem::path& path, int flags)
{
auto fd = openp(path, flags);
@ -111,8 +113,8 @@ open_file(const ghc::filesystem::path& path, int flags)
return Ok(auto_fd(fd));
}
Result<std::pair<ghc::filesystem::path, auto_fd>, std::string>
open_temp_file(const ghc::filesystem::path& pattern)
Result<std::pair<std::filesystem::path, auto_fd>, std::string>
open_temp_file(const std::filesystem::path& pattern)
{
auto pattern_str = pattern.string();
char pattern_copy[pattern_str.size() + 1];
@ -126,14 +128,14 @@ open_temp_file(const ghc::filesystem::path& pattern)
strerror(errno)));
}
return Ok(std::make_pair(ghc::filesystem::path(pattern_copy), auto_fd(fd)));
return Ok(std::make_pair(std::filesystem::path(pattern_copy), auto_fd(fd)));
}
Result<std::string, std::string>
read_file(const ghc::filesystem::path& path)
read_file(const std::filesystem::path& path)
{
try {
ghc::filesystem::ifstream file_stream(path);
std::ifstream file_stream(path);
if (!file_stream) {
return Err(std::string(strerror(errno)));
@ -149,7 +151,7 @@ read_file(const ghc::filesystem::path& path)
}
Result<write_file_result, std::string>
write_file(const ghc::filesystem::path& path,
write_file(const std::filesystem::path& path,
const string_fragment& content,
std::set<write_file_options> options)
{
@ -175,11 +177,11 @@ write_file(const ghc::filesystem::path& path,
std::error_code ec;
if (options.count(write_file_options::backup_existing)) {
if (ghc::filesystem::exists(path, ec)) {
if (std::filesystem::exists(path, ec)) {
auto backup_path = path;
backup_path += ".bak";
ghc::filesystem::rename(path, backup_path, ec);
std::filesystem::rename(path, backup_path, ec);
if (ec) {
return Err(
fmt::format(FMT_STRING("unable to backup file {}: {}"),
@ -191,7 +193,7 @@ write_file(const ghc::filesystem::path& path,
}
}
ghc::filesystem::rename(tmp_pair.first, path, ec);
std::filesystem::rename(tmp_pair.first, path, ec);
if (ec) {
return Err(
fmt::format(FMT_STRING("unable to move temporary file {}: {}"),
@ -203,7 +205,7 @@ write_file(const ghc::filesystem::path& path,
}
std::string
build_path(const std::vector<ghc::filesystem::path>& paths)
build_path(const std::vector<std::filesystem::path>& paths)
{
return paths
| lnav::itertools::map([](const auto& path) { return path.string(); })
@ -220,7 +222,7 @@ build_path(const std::vector<ghc::filesystem::path>& paths)
}
Result<struct stat, std::string>
stat_file(const ghc::filesystem::path& path)
stat_file(const std::filesystem::path& path)
{
struct stat retval;
@ -233,7 +235,8 @@ stat_file(const ghc::filesystem::path& path)
strerror(errno)));
}
file_lock::file_lock(const ghc::filesystem::path& archive_path)
file_lock::
file_lock(const std::filesystem::path& archive_path)
{
auto lock_path = archive_path;
@ -252,7 +255,7 @@ file_lock::file_lock(const ghc::filesystem::path& archive_path)
namespace fmt {
auto
formatter<ghc::filesystem::path>::format(const ghc::filesystem::path& p,
formatter<std::filesystem::path>::format(const std::filesystem::path& p,
format_context& ctx)
-> decltype(ctx.out()) const
{

@ -30,13 +30,16 @@
#ifndef lnav_fs_util_hh
#define lnav_fs_util_hh
#include <filesystem>
#include <optional>
#include <set>
#include <string>
#include <vector>
#include <sys/stat.h>
#include <unistd.h>
#include "auto_fd.hh"
#include "ghc/filesystem.hpp"
#include "intern_string.hh"
#include "result.h"
@ -51,57 +54,57 @@ is_glob(const std::string& fn)
|| fn.find('[') != std::string::npos);
}
std::string escape_path(const ghc::filesystem::path& p);
std::string escape_path(const std::filesystem::path& p);
inline int
statp(const ghc::filesystem::path& path, struct stat* buf)
statp(const std::filesystem::path& path, struct stat* buf)
{
return stat(path.c_str(), buf);
}
inline int
openp(const ghc::filesystem::path& path, int flags)
openp(const std::filesystem::path& path, int flags)
{
return open(path.c_str(), flags);
}
inline int
openp(const ghc::filesystem::path& path, int flags, mode_t mode)
openp(const std::filesystem::path& path, int flags, mode_t mode)
{
return open(path.c_str(), flags, mode);
}
Result<ghc::filesystem::path, std::string> realpath(
const ghc::filesystem::path& path);
Result<std::filesystem::path, std::string> realpath(
const std::filesystem::path& path);
Result<auto_fd, std::string> create_file(const ghc::filesystem::path& path,
Result<auto_fd, std::string> create_file(const std::filesystem::path& path,
int flags,
mode_t mode);
Result<auto_fd, std::string> open_file(const ghc::filesystem::path& path,
Result<auto_fd, std::string> open_file(const std::filesystem::path& path,
int flags);
Result<struct stat, std::string> stat_file(const ghc::filesystem::path& path);
Result<struct stat, std::string> stat_file(const std::filesystem::path& path);
Result<std::pair<ghc::filesystem::path, auto_fd>, std::string> open_temp_file(
const ghc::filesystem::path& pattern);
Result<std::pair<std::filesystem::path, auto_fd>, std::string> open_temp_file(
const std::filesystem::path& pattern);
Result<std::string, std::string> read_file(const ghc::filesystem::path& path);
Result<std::string, std::string> read_file(const std::filesystem::path& path);
enum class write_file_options {
backup_existing,
};
struct write_file_result {
std::optional<ghc::filesystem::path> wfr_backup_path;
std::optional<std::filesystem::path> wfr_backup_path;
};
Result<write_file_result, std::string> write_file(
const ghc::filesystem::path& path,
const std::filesystem::path& path,
const string_fragment& content,
std::set<write_file_options> options = {});
std::string build_path(const std::vector<ghc::filesystem::path>& paths);
std::string build_path(const std::vector<std::filesystem::path>& paths);
class file_lock {
public:
@ -136,7 +139,7 @@ public:
void unlock() const { lockf(this->lh_fd, F_ULOCK, 0); }
explicit file_lock(const ghc::filesystem::path& archive_path);
explicit file_lock(const std::filesystem::path& archive_path);
auto_fd lh_fd;
};
@ -146,9 +149,9 @@ public:
namespace fmt {
template<>
struct formatter<ghc::filesystem::path> : formatter<string_view> {
auto format(const ghc::filesystem::path& p,
format_context& ctx) -> decltype(ctx.out()) const;
struct formatter<std::filesystem::path> : formatter<string_view> {
auto format(const std::filesystem::path& p, format_context& ctx)
-> decltype(ctx.out()) const;
};
} // namespace fmt

@ -34,6 +34,8 @@
# include <sstream>
#endif
#include <unistd.h>
#include "fmt/format.h"
#include "paths.hh"
@ -76,7 +78,7 @@ windows_to_unix_file_path(char* input)
}
#endif
ghc::filesystem::path
std::filesystem::path
dotlnav()
{
#ifdef __CYGWIN__
@ -87,26 +89,26 @@ dotlnav()
auto xdg_config_home = getenv("XDG_CONFIG_HOME");
if (home_env != nullptr) {
auto home_path = ghc::filesystem::path(home_env);
auto home_path = std::filesystem::path(home_env);
if (ghc::filesystem::is_directory(home_path)) {
if (std::filesystem::is_directory(home_path)) {
auto home_lnav = home_path / ".lnav";
if (ghc::filesystem::is_directory(home_lnav)) {
if (std::filesystem::is_directory(home_lnav)) {
return home_lnav;
}
if (xdg_config_home != nullptr) {
auto xdg_path = ghc::filesystem::path(xdg_config_home);
auto xdg_path = std::filesystem::path(xdg_config_home);
if (ghc::filesystem::is_directory(xdg_path)) {
if (std::filesystem::is_directory(xdg_path)) {
return xdg_path / "lnav";
}
}
auto home_config = home_path / ".config";
if (ghc::filesystem::is_directory(home_config)) {
if (std::filesystem::is_directory(home_config)) {
return home_config / "lnav";
}
@ -114,16 +116,16 @@ dotlnav()
}
}
return ghc::filesystem::current_path();
return std::filesystem::current_path();
}
ghc::filesystem::path
std::filesystem::path
workdir()
{
auto subdir_name = fmt::format(FMT_STRING("lnav-user-{}-work"), getuid());
auto tmp_path = ghc::filesystem::temp_directory_path();
auto tmp_path = std::filesystem::temp_directory_path();
return tmp_path / ghc::filesystem::path(subdir_name);
return tmp_path / std::filesystem::path(subdir_name);
}
} // namespace paths

@ -30,7 +30,7 @@
#ifndef lnav_paths_hh
#define lnav_paths_hh
#include "ghc/filesystem.hpp"
#include <filesystem>
namespace lnav {
namespace paths {
@ -48,9 +48,9 @@ char* windows_to_unix_file_path(char* input);
* @param sub The path to the file in the '.lnav' directory.
* @return The full path
*/
ghc::filesystem::path dotlnav();
std::filesystem::path dotlnav();
ghc::filesystem::path workdir();
std::filesystem::path workdir();
} // namespace paths
} // namespace lnav

@ -42,7 +42,7 @@ namespace piper {
const char HEADER_MAGIC[4] = {'L', 0, 'N', 1};
const ghc::filesystem::path&
const std::filesystem::path&
storage_path()
{
static auto INSTANCE = lnav::paths::workdir() / "piper";

@ -39,7 +39,7 @@
#include "auto_mem.hh"
#include "base/intern_string.hh"
#include "ghc/filesystem.hpp"
#include <filesystem>
#include "mapbox/variant_io.hpp"
#include "time_util.hh"
@ -76,7 +76,7 @@ struct header {
}
};
const ghc::filesystem::path& storage_path();
const std::filesystem::path& storage_path();
constexpr size_t HEADER_SIZE = 8;
extern const char HEADER_MAGIC[4];

@ -603,10 +603,10 @@ multiline_executor::final()
}
static Result<std::string, lnav::console::user_message>
execute_file_contents(exec_context& ec, const ghc::filesystem::path& path)
execute_file_contents(exec_context& ec, const std::filesystem::path& path)
{
static const ghc::filesystem::path stdin_path("-");
static const ghc::filesystem::path dev_stdin_path("/dev/stdin");
static const std::filesystem::path stdin_path("-");
static const std::filesystem::path dev_stdin_path("/dev/stdin");
std::string retval;
FILE* file;
@ -715,13 +715,13 @@ execute_file(exec_context& ec, const std::string& path_and_args)
} else if (errno != ENOENT) {
open_error = strerror(errno);
} else {
auto script_path = ghc::filesystem::path(script_name);
auto script_path = std::filesystem::path(script_name);
if (!script_path.is_absolute()) {
script_path = ec.ec_path_stack.back() / script_path;
}
if (ghc::filesystem::is_regular_file(script_path)) {
if (std::filesystem::is_regular_file(script_path)) {
struct script_metadata meta;
meta.sm_path = script_path;
@ -1066,7 +1066,7 @@ pipe_callback(exec_context& ec, const std::string& cmdline, auto_fd& fd)
});
}
std::error_code errc;
ghc::filesystem::create_directories(lnav::paths::workdir(), errc);
std::filesystem::create_directories(lnav::paths::workdir(), errc);
auto open_temp_res = lnav::filesystem::open_temp_file(lnav::paths::workdir()
/ "exec.XXXXXX");
if (open_temp_res.isErr()) {

@ -41,7 +41,7 @@
#include "base/lnav.console.hh"
#include "db_sub_source.hh"
#include "fmt/format.h"
#include "ghc/filesystem.hpp"
#include <filesystem>
#include "help_text.hh"
#include "shlex.resolver.hh"
#include "vis_line.hh"
@ -301,7 +301,7 @@ struct exec_context {
std::stack<std::map<std::string, scoped_value_t>> ec_local_vars;
std::vector<provenance_t> ec_provenance;
std::map<std::string, scoped_value_t> ec_global_vars;
std::vector<ghc::filesystem::path> ec_path_stack;
std::vector<std::filesystem::path> ec_path_stack;
std::vector<lnav::console::snippet> ec_source;
help_text* ec_current_help{nullptr};

@ -191,7 +191,9 @@ curl_request::complete(CURLcode result)
return -1;
}
curl_looper::curl_looper() : cl_curl_multi(curl_multi_cleanup)
curl_looper::
curl_looper()
: cl_curl_multi(curl_multi_cleanup)
{
this->cl_curl_multi.reset(curl_multi_init());
}

@ -61,7 +61,7 @@ dump_internals(const char* internals_dir)
execute_examples();
auto cmd_ref_path = ghc::filesystem::path(internals_dir) / "cmd-ref.rst";
auto cmd_ref_path = std::filesystem::path(internals_dir) / "cmd-ref.rst";
auto cmd_file = std::unique_ptr<FILE, decltype(&fclose)>(
fopen(cmd_ref_path.c_str(), "w+"), fclose);
@ -78,7 +78,7 @@ dump_internals(const char* internals_dir)
}
}
auto sql_ref_path = ghc::filesystem::path(internals_dir) / "sql-ref.rst";
auto sql_ref_path = std::filesystem::path(internals_dir) / "sql-ref.rst";
auto sql_file = std::unique_ptr<FILE, decltype(&fclose)>(
fopen(sql_ref_path.c_str(), "w+"), fclose);
std::set<const help_text*> unique_sql_help;

@ -162,7 +162,7 @@ file_collection::regenerate_unique_file_names()
safe::ReadAccess<safe_name_to_errors> errs(*this->fc_name_to_errors);
for (const auto& pair : *errs) {
auto path = ghc::filesystem::path(pair.first).filename().string();
auto path = std::filesystem::path(pair.first).filename().string();
if (path.length() > this->fc_largest_path_length) {
this->fc_largest_path_length = path.length();
@ -182,7 +182,7 @@ file_collection::regenerate_unique_file_names()
case file_format_t::ARCHIVE:
case file_format_t::MULTIPLEXED:
case file_format_t::SQLITE_DB: {
auto bn = ghc::filesystem::path(pair.first).filename().string();
auto bn = std::filesystem::path(pair.first).filename().string();
if (bn.length() > this->fc_largest_path_length) {
this->fc_largest_path_length = bn.length();
}
@ -307,7 +307,9 @@ file_collection::watch_logfile(const std::string& filename,
int rc;
auto filename_key = loo.loo_filename.empty() ? filename : loo.loo_filename;
if (this->fc_closed_files.count(filename)) {
if (this->fc_closed_files.count(filename)
|| this->fc_closed_files.count(filename_key))
{
return std::nullopt;
}
@ -464,7 +466,7 @@ file_collection::watch_logfile(const std::string& filename,
},
[&filename, &retval](const auto& tmp_path,
const auto& entry) {
auto arc_path = ghc::filesystem::relative(
auto arc_path = std::filesystem::relative(
entry.path(), tmp_path);
auto custom_name = filename / arc_path;
bool is_visible = true;

@ -44,7 +44,7 @@
namespace file_converter_manager {
static const ghc::filesystem::path&
static const std::filesystem::path&
cache_dir()
{
static auto INSTANCE = lnav::paths::workdir() / "conversion";
@ -57,7 +57,7 @@ convert(const external_file_format& eff, const std::string& filename)
{
log_info("attempting to convert file -- %s", filename.c_str());
ghc::filesystem::create_directories(cache_dir());
std::filesystem::create_directories(cache_dir());
auto outfile = TRY(lnav::filesystem::open_temp_file(
cache_dir()
/ fmt::format(FMT_STRING("{}.XXXXXX"), eff.eff_format_name)));
@ -160,14 +160,15 @@ cleanup()
{
(void) std::async(std::launch::async, []() {
const auto& cfg = injector::get<const lnav::piper::config&>();
auto now = std::chrono::system_clock::now();
auto now = std::filesystem::file_time_type{
std::chrono::system_clock::now().time_since_epoch()};
auto cache_path = cache_dir();
std::vector<ghc::filesystem::path> to_remove;
std::vector<std::filesystem::path> to_remove;
for (const auto& entry :
ghc::filesystem::directory_iterator(cache_path))
std::filesystem::directory_iterator(cache_path))
{
auto mtime = ghc::filesystem::last_write_time(entry.path());
auto mtime = std::filesystem::last_write_time(entry.path());
auto exp_time = mtime + cfg.c_ttl;
if (now < exp_time) {
continue;
@ -178,7 +179,7 @@ cleanup()
for (auto& entry : to_remove) {
log_debug("removing conversion: %s", entry.c_str());
ghc::filesystem::remove_all(entry);
std::filesystem::remove_all(entry);
}
});
}

@ -37,13 +37,13 @@
#include "base/auto_pid.hh"
#include "base/result.h"
#include "file_format.hh"
#include "ghc/filesystem.hpp"
#include <filesystem>
namespace file_converter_manager {
struct convert_result {
auto_pid<process_state::running> cr_child;
ghc::filesystem::path cr_destination;
std::filesystem::path cr_destination;
std::shared_ptr<std::vector<std::string>> cr_error_queue;
};

@ -40,7 +40,7 @@
#include "line_buffer.hh"
file_format_t
detect_file_format(const ghc::filesystem::path& filename)
detect_file_format(const std::filesystem::path& filename)
{
auto describe_res = archive_manager::describe(filename);
if (describe_res.isOk()

@ -35,7 +35,7 @@
#include <optional>
#include "fmt/format.h"
#include "ghc/filesystem.hpp"
#include <filesystem>
enum class file_format_t : int {
UNKNOWN,
@ -48,13 +48,13 @@ enum class file_format_t : int {
struct external_file_format {
std::string eff_format_name;
std::string eff_converter;
ghc::filesystem::path eff_source_path;
std::filesystem::path eff_source_path;
};
file_format_t detect_file_format(const ghc::filesystem::path& filename);
file_format_t detect_file_format(const std::filesystem::path& filename);
std::optional<external_file_format> detect_mime_type(
const ghc::filesystem::path& filename);
const std::filesystem::path& filename);
namespace fmt {
template<>

@ -115,9 +115,9 @@ file_options_collection::match(const std::string& path) const
}
std::optional<std::pair<std::string, file_options>>
file_options_hier::match(const ghc::filesystem::path& path) const
file_options_hier::match(const std::filesystem::path& path) const
{
static const auto ROOT_PATH = ghc::filesystem::path("/");
static const auto ROOT_PATH = std::filesystem::path("/");
auto lookup_path = path.parent_path();

@ -35,7 +35,7 @@
#include "base/lnav.console.hh"
#include "base/result.h"
#include "date/tz.h"
#include "ghc/filesystem.hpp"
#include <filesystem>
#include "mapbox/variant.hpp"
#include "safe/safe.h"
#include "yajlpp/yajlpp.hh"
@ -66,12 +66,12 @@ struct file_options_collection {
};
struct file_options_hier {
std::map<ghc::filesystem::path, file_options_collection>
std::map<std::filesystem::path, file_options_collection>
foh_path_to_collection;
size_t foh_generation{0};
std::optional<std::pair<std::string, file_options>> match(
const ghc::filesystem::path& path) const;
const std::filesystem::path& path) const;
};
using safe_file_options_hier = safe::Safe<file_options_hier>;

@ -268,7 +268,7 @@ files_sub_source::text_value_for_line(textview_curses& tc,
if (line < errs->size()) {
auto iter = std::next(errs->begin(), line);
auto path = ghc::filesystem::path(iter->first);
auto path = std::filesystem::path(iter->first);
auto fn = fmt::to_string(path.filename());
truncate_to(fn, filename_width);
@ -293,7 +293,7 @@ files_sub_source::text_value_for_line(textview_curses& tc,
if (line < fc.fc_other_files.size()) {
auto iter = std::next(fc.fc_other_files.begin(), line);
auto path = ghc::filesystem::path(iter->first);
auto path = std::filesystem::path(iter->first);
auto fn = fmt::to_string(path);
truncate_to(fn, filename_width);
@ -322,7 +322,7 @@ files_sub_source::text_value_for_line(textview_curses& tc,
const auto& lf = fc.fc_files[line];
auto ld_opt = lnav_data.ld_log_source.find_data(lf);
auto fn = fmt::to_string(ghc::filesystem::path(lf->get_unique_path()));
auto fn = fmt::to_string(std::filesystem::path(lf->get_unique_path()));
char start_time[64] = "", end_time[64] = "";
std::vector<std::string> file_notes;

@ -41,7 +41,7 @@
#include "base/lnav_log.hh"
#include "bound_tags.hh"
#include "config.h"
#include "ghc/filesystem.hpp"
#include <filesystem>
#include "sql_help.hh"
#include "sql_util.hh"
#include "vtab_module.hh"
@ -338,7 +338,7 @@ CREATE TABLE fstat (
SQLITE_TRANSIENT);
break;
case FSTAT_COL_DATA: {
auto fs_path = ghc::filesystem::path{path};
auto fs_path = std::filesystem::path{path};
if (!vc.c_error.empty()) {
sqlite3_result_null(ctx);
} else if (S_ISREG(vc.c_stat.st_mode)) {
@ -370,7 +370,7 @@ CREATE TABLE fstat (
to_sqlite(ctx, blob_auto_buffer{std::move(buffer)});
}
} else if (S_ISLNK(vc.c_stat.st_mode)) {
auto link_path = ghc::filesystem::read_symlink(fs_path);
auto link_path = std::filesystem::read_symlink(fs_path);
to_sqlite(ctx, link_path.string());
} else {

File diff suppressed because it is too large Load Diff

@ -1,38 +0,0 @@
//---------------------------------------------------------------------------------------
//
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
//
//---------------------------------------------------------------------------------------
//
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
//---------------------------------------------------------------------------------------
// fs_fwd.hpp - The forwarding header for the header/implementation seperated usage of
// ghc::filesystem.
// This file can be include at any place, where ghc::filesystem api is needed while
// not bleeding implementation details (e.g. system includes) into the global namespace,
// as long as one cpp includes fs_impl.hpp to deliver the matching implementations.
//---------------------------------------------------------------------------------------
#ifndef GHC_FILESYSTEM_FWD_H
#define GHC_FILESYSTEM_FWD_H
#define GHC_FILESYSTEM_FWD
#include <ghc/filesystem.hpp>
#endif // GHC_FILESYSTEM_FWD_H

@ -1,35 +0,0 @@
//---------------------------------------------------------------------------------------
//
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
//
//---------------------------------------------------------------------------------------
//
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
//---------------------------------------------------------------------------------------
// fs_impl.hpp - The implementation header for the header/implementation seperated usage of
// ghc::filesystem.
// This file can be used to hide the implementation of ghc::filesystem into a single cpp.
// The cpp has to include this before including fs_fwd.hpp directly or via a different
// header to work.
//---------------------------------------------------------------------------------------
#define GHC_FILESYSTEM_IMPLEMENTATION
#include <ghc/filesystem.hpp>

@ -1,60 +0,0 @@
//---------------------------------------------------------------------------------------
//
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
//
//---------------------------------------------------------------------------------------
//
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
//---------------------------------------------------------------------------------------
// fs_std.hpp - The dynamic switching header that includes std::filesystem if detected
// or ghc::filesystem if not, and makes the resulting API available in the
// namespace fs.
//---------------------------------------------------------------------------------------
#ifndef GHC_FILESYSTEM_STD_H
#define GHC_FILESYSTEM_STD_H
#if defined(__APPLE__)
#include <Availability.h>
#endif
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include)
#if __has_include(<filesystem>) && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500)
#define GHC_USE_STD_FS
#include <filesystem>
namespace fs {
using namespace std::filesystem;
using ifstream = std::ifstream;
using ofstream = std::ofstream;
using fstream = std::fstream;
}
#endif
#endif
#ifndef GHC_USE_STD_FS
//#define GHC_WIN_DISABLE_WSTRING_STORAGE_TYPE
#include <ghc/filesystem.hpp>
namespace fs {
using namespace ghc::filesystem;
using ifstream = ghc::filesystem::ifstream;
using ofstream = ghc::filesystem::ofstream;
using fstream = ghc::filesystem::fstream;
}
#endif
#endif // GHC_FILESYSTEM_STD_H

@ -1,63 +0,0 @@
//---------------------------------------------------------------------------------------
//
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
//
//---------------------------------------------------------------------------------------
//
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
//---------------------------------------------------------------------------------------
// fs_std_fwd.hpp - The forwarding header for the header/implementation seperated usage of
// ghc::filesystem that uses std::filesystem if it detects it.
// This file can be include at any place, where fs::filesystem api is needed while
// not bleeding implementation details (e.g. system includes) into the global namespace,
// as long as one cpp includes fs_std_impl.hpp to deliver the matching implementations.
//---------------------------------------------------------------------------------------
#ifndef GHC_FILESYSTEM_STD_FWD_H
#define GHC_FILESYSTEM_STD_FWD_H
#if defined(__APPLE__)
#include <Availability.h>
#endif
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include)
#if __has_include(<filesystem>) && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500)
#define GHC_USE_STD_FS
#include <filesystem>
namespace fs {
using namespace std::filesystem;
using ifstream = std::ifstream;
using ofstream = std::ofstream;
using fstream = std::fstream;
}
#endif
#endif
#ifndef GHC_USE_STD_FS
//#define GHC_WIN_DISABLE_WSTRING_STORAGE_TYPE
#define GHC_FILESYSTEM_FWD
#include <ghc/filesystem.hpp>
namespace fs {
using namespace ghc::filesystem;
using ifstream = ghc::filesystem::ifstream;
using ofstream = ghc::filesystem::ofstream;
using fstream = ghc::filesystem::fstream;
}
#endif
#endif // GHC_FILESYSTEM_STD_FWD_H

@ -1,46 +0,0 @@
//---------------------------------------------------------------------------------------
//
// ghc::filesystem - A C++17-like filesystem implementation for C++11/C++14
//
//---------------------------------------------------------------------------------------
//
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
//---------------------------------------------------------------------------------------
// fs_std_impl.hpp - The implementation header for the header/implementation seperated usage of
// ghc::filesystem that does nothing if std::filesystem is detected.
// This file can be used to hide the implementation of ghc::filesystem into a single cpp.
// The cpp has to include this before including fs_std_fwd.hpp directly or via a different
// header to work.
//---------------------------------------------------------------------------------------
#if defined(__APPLE__)
#include <Availability.h>
#endif
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include)
#if __has_include(<filesystem>) && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500)
#define GHC_USE_STD_FS
#endif
#endif
#ifndef GHC_USE_STD_FS
//#define GHC_WIN_DISABLE_WSTRING_STORAGE_TYPE
#define GHC_FILESYSTEM_IMPLEMENTATION
#include <ghc/filesystem.hpp>
#endif

@ -135,7 +135,8 @@ private:
#define Z_BUFSIZE 65536U
#define SYNCPOINT_SIZE (1024 * 1024)
line_buffer::gz_indexed::gz_indexed()
line_buffer::gz_indexed::
gz_indexed()
{
if ((this->inbuf = auto_mem<Bytef>::malloc(Z_BUFSIZE)) == NULL) {
throw std::bad_alloc();
@ -364,12 +365,14 @@ line_buffer::gz_indexed::read(void* buf, size_t offset, size_t size)
return bytes;
}
line_buffer::line_buffer()
line_buffer::
line_buffer()
{
ensure(this->invariant());
}
line_buffer::~line_buffer()
line_buffer::~
line_buffer()
{
if (this->lb_loader_future.valid()) {
this->lb_loader_future.wait();
@ -1312,8 +1315,8 @@ line_buffer::get_available()
static_cast<file_ssize_t>(this->lb_buffer.size())};
}
line_buffer::gz_indexed::indexDict::indexDict(const z_stream& s,
const file_size_t size)
line_buffer::gz_indexed::indexDict::
indexDict(const z_stream& s, const file_size_t size)
{
assert((s.data_type & GZ_END_OF_BLOCK_MASK));
assert(!(s.data_type & GZ_END_OF_FILE_MASK));
@ -1374,7 +1377,7 @@ line_buffer::quiesce()
}
}
static ghc::filesystem::path
static std::filesystem::path
line_buffer_cache_path()
{
return lnav::paths::workdir() / "buffer-cache";
@ -1405,7 +1408,7 @@ line_buffer::enable_cache()
.to_string();
auto cache_dir = line_buffer_cache_path() / cached_base_name.substr(0, 2);
ghc::filesystem::create_directories(cache_dir);
std::filesystem::create_directories(cache_dir);
auto cached_file_name = fmt::format(FMT_STRING("{}.bin"), cached_base_name);
auto cached_file_path = cache_dir / cached_file_name;
@ -1418,14 +1421,14 @@ line_buffer::enable_cache()
auto fl = lnav::filesystem::file_lock(cached_file_path);
auto guard = lnav::filesystem::file_lock::guard(&fl);
if (ghc::filesystem::exists(cached_done_path)) {
if (std::filesystem::exists(cached_done_path)) {
log_info("%d:using existing cache file");
auto open_res = lnav::filesystem::open_file(cached_file_path, O_RDWR);
if (open_res.isOk()) {
this->lb_cached_fd = open_res.unwrap();
return;
}
ghc::filesystem::remove(cached_done_path);
std::filesystem::remove(cached_done_path);
}
auto create_res = lnav::filesystem::create_file(
@ -1470,18 +1473,19 @@ void
line_buffer::cleanup_cache()
{
(void) std::async(std::launch::async, []() {
auto now = std::chrono::system_clock::now();
auto now = std::filesystem::file_time_type{
std::chrono::system_clock::now().time_since_epoch()};
auto cache_path = line_buffer_cache_path();
std::vector<ghc::filesystem::path> to_remove;
std::vector<std::filesystem::path> to_remove;
std::error_code ec;
for (const auto& cache_subdir :
ghc::filesystem::directory_iterator(cache_path, ec))
std::filesystem::directory_iterator(cache_path, ec))
{
for (const auto& entry :
ghc::filesystem::directory_iterator(cache_subdir, ec))
std::filesystem::directory_iterator(cache_subdir, ec))
{
auto mtime = ghc::filesystem::last_write_time(entry.path());
auto mtime = std::filesystem::last_write_time(entry.path());
auto exp_time = mtime + 1h;
if (now < exp_time) {
continue;
@ -1493,7 +1497,7 @@ line_buffer::cleanup_cache()
for (auto& entry : to_remove) {
log_debug("removing compressed file cache: %s", entry.c_str());
ghc::filesystem::remove_all(entry, ec);
std::filesystem::remove_all(entry, ec);
}
});
}

@ -319,7 +319,7 @@ static bool
append_default_files()
{
bool retval = true;
auto cwd = ghc::filesystem::current_path();
auto cwd = std::filesystem::current_path();
for (const auto& path : DEFAULT_FILES) {
if (access(path.c_str(), R_OK) == 0) {
@ -2135,7 +2135,9 @@ print_user_msgs(std::vector<lnav::console::user_message> error_list,
if (warning_count > 0 && !mf.mf_print_warnings
&& !(lnav_data.ld_flags & LNF_HEADLESS)
&& (std::chrono::system_clock::now() - lnav_data.ld_last_dot_lnav_time
&& (std::filesystem::file_time_type{
std::chrono::system_clock::now().time_since_epoch()}
- lnav_data.ld_last_dot_lnav_time
> 24h))
{
lnav::console::print(
@ -2239,7 +2241,7 @@ main(int argc, char* argv[])
curr_tz,
},
};
options_hier->foh_path_to_collection.emplace(ghc::filesystem::path("/"),
options_hier->foh_path_to_collection.emplace(std::filesystem::path("/"),
options_coll);
} catch (const std::runtime_error& e) {
log_error("failed to setup tz: %s", e.what());
@ -2260,7 +2262,7 @@ main(int argc, char* argv[])
auto dot_lnav_path = lnav::paths::dotlnav();
std::error_code last_write_ec;
lnav_data.ld_last_dot_lnav_time
= ghc::filesystem::last_write_time(dot_lnav_path, last_write_ec);
= std::filesystem::last_write_time(dot_lnav_path, last_write_ec);
ensure_dotlnav();
@ -2625,7 +2627,7 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%'
}
if (endswith(file_path, ".sql")) {
auto sql_path = ghc::filesystem::path(file_path);
auto sql_path = std::filesystem::path(file_path);
auto read_res = lnav::filesystem::read_file(sql_path);
if (read_res.isErr()) {
lnav::console::print(
@ -2675,8 +2677,8 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%'
}
auto file_type = file_type_result.unwrap();
auto src_path = ghc::filesystem::path(file_path);
ghc::filesystem::path dst_name;
auto src_path = std::filesystem::path(file_path);
std::filesystem::path dst_name;
if (file_type == config_file_type::CONFIG) {
dst_name = src_path.filename();
} else {
@ -3031,7 +3033,7 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%'
file_loc = file_path_str.substr(hash_index);
file_path_without_trailer = file_path_str.substr(0, hash_index);
}
auto file_path = ghc::filesystem::path(
auto file_path = std::filesystem::path(
stat(file_path_without_trailer.c_str(), &st) == 0
? file_path_without_trailer
: file_path_str);
@ -3207,7 +3209,7 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%'
}
std::optional<std::string> stdin_url;
ghc::filesystem::path stdin_dir;
std::filesystem::path stdin_dir;
if (load_stdin && !isatty(STDIN_FILENO) && !is_dev_null(STDIN_FILENO)
&& !exec_stdin)
{
@ -3555,7 +3557,7 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%'
{
file_size_t stdin_size = 0;
for (const auto& ent :
ghc::filesystem::directory_iterator(stdin_dir))
std::filesystem::directory_iterator(stdin_dir))
{
stdin_size += ent.file_size();
}

@ -82,7 +82,7 @@ typedef enum {
} lnav_status_t;
using ppid_time_pair_t = std::pair<int, int>;
using session_pair_t = std::pair<ppid_time_pair_t, ghc::filesystem::path>;
using session_pair_t = std::pair<ppid_time_pair_t, std::filesystem::path>;
class input_state_tracker : public log_state_dumper {
public:
@ -164,7 +164,7 @@ struct lnav_data_t {
std::list<std::string> ld_commands;
bool ld_cmd_init_done;
bool ld_session_loaded;
std::vector<ghc::filesystem::path> ld_config_paths;
std::vector<std::filesystem::path> ld_config_paths;
file_collection ld_active_files;
std::list<child_poller> ld_child_pollers;
std::list<std::pair<std::string, file_location_t>> ld_files_to_front;
@ -261,7 +261,7 @@ struct lnav_data_t {
lnav::func::scoped_cb ld_status_refresher;
ghc::filesystem::file_time_type ld_last_dot_lnav_time;
std::filesystem::file_time_type ld_last_dot_lnav_time;
};
struct static_service {};

@ -669,7 +669,7 @@ struct subcmd_format_t {
auto ppath = regex101::patch_path(validate_res.unwrap(),
en.re_permalink);
if (ghc::filesystem::exists(ppath)) {
if (std::filesystem::exists(ppath)) {
return {
console::user_message::error(
attr_line_t("cannot delete regex101 entry "
@ -772,7 +772,7 @@ struct subcmd_piper_t {
static perform_result_t list_action(const subcmd_piper_t&)
{
static const intern_string_t SRC = intern_string::lookup("piper");
static const auto DOT_HEADER = ghc::filesystem::path(".header");
static const auto DOT_HEADER = std::filesystem::path(".header");
struct item {
lnav::piper::header i_header;
@ -784,7 +784,7 @@ struct subcmd_piper_t {
std::vector<item> items;
std::error_code ec;
for (const auto& instance_dir : ghc::filesystem::directory_iterator(
for (const auto& instance_dir : std::filesystem::directory_iterator(
lnav::piper::storage_path(), ec))
{
if (!instance_dir.is_directory()) {
@ -798,7 +798,7 @@ struct subcmd_piper_t {
instance_dir.path().filename().string());
file_size_t total_size{0};
auto hdr_path = instance_dir / DOT_HEADER;
if (ghc::filesystem::exists(hdr_path)) {
if (std::filesystem::exists(hdr_path)) {
auto hdr_read_res = lnav::filesystem::read_file(hdr_path);
if (hdr_read_res.isOk()) {
auto parse_res
@ -822,7 +822,7 @@ struct subcmd_piper_t {
}
for (const auto& entry :
ghc::filesystem::directory_iterator(instance_dir.path()))
std::filesystem::directory_iterator(instance_dir.path()))
{
if (entry.path().filename() == DOT_HEADER) {
continue;
@ -1007,7 +1007,7 @@ struct subcmd_piper_t {
{
std::error_code ec;
ghc::filesystem::remove_all(lnav::piper::storage_path(), ec);
std::filesystem::remove_all(lnav::piper::storage_path(), ec);
if (ec) {
return {
lnav::console::user_message::error(

@ -385,7 +385,7 @@ com_set_file_timezone(exec_context& ec,
const auto* tz = date::locate_zone(split_args[1]);
auto pattern = split_args.size() == 2
? line_pair->first->get_filename()
: ghc::filesystem::path(split_args[2]);
: std::filesystem::path(split_args[2]);
if (!ec.ec_dry_run) {
static auto& safe_options_hier
@ -485,7 +485,7 @@ com_set_file_timezone_prompt(exec_context& ec, const std::string& cmdline)
log_error("cannot get timezones: %s", e.what());
}
}
auto arg_path = ghc::filesystem::path(pattern_arg);
auto arg_path = std::filesystem::path(pattern_arg);
auto arg_parent = lnav::filesystem::escape_path(arg_path.parent_path());
if (!endswith(arg_parent, "/")) {
arg_parent += "/";
@ -3342,7 +3342,7 @@ com_open(exec_context& ec, std::string cmdline, std::vector<std::string>& args)
fn_str);
}
} else {
auto fn = ghc::filesystem::path(fn_str);
auto fn = std::filesystem::path(fn_str);
auto detect_res = detect_file_format(fn);
attr_line_t al;
attr_line_builder alb(al);
@ -3542,7 +3542,7 @@ com_close(exec_context& ec, std::string cmdline, std::vector<std::string>& args)
}
auto* tc = *lnav_data.ld_view_stack.top();
std::vector<std::optional<ghc::filesystem::path>> actual_path_v;
std::vector<std::optional<std::filesystem::path>> actual_path_v;
std::vector<std::string> fn_v;
if (args.size() > 1) {

@ -168,9 +168,9 @@ ensure_dotlnav()
if (glob(crash_glob.c_str(), GLOB_NOCHECK, nullptr, gl.inout()) == 0) {
std::error_code ec;
for (size_t lpc = 0; lpc < gl->gl_pathc; lpc++) {
auto crash_file = ghc::filesystem::path(gl->gl_pathv[lpc]);
auto crash_file = std::filesystem::path(gl->gl_pathv[lpc]);
ghc::filesystem::rename(
std::filesystem::rename(
crash_file, crash_dir_path / crash_file.filename(), ec);
}
}
@ -241,11 +241,11 @@ install_from_git(const std::string& repo)
auto git_cmd = fork_res.unwrap();
if (git_cmd.in_child()) {
if (ghc::filesystem::is_directory(local_formats_path)) {
if (std::filesystem::is_directory(local_formats_path)) {
fmt::print("Updating format repo: {}\n", repo);
log_perror(chdir(local_formats_path.c_str()));
execlp("git", "git", "pull", nullptr);
} else if (ghc::filesystem::is_directory(local_configs_path)) {
} else if (std::filesystem::is_directory(local_configs_path)) {
fmt::print("Updating config repo: {}\n", repo);
log_perror(chdir(local_configs_path.c_str()));
execlp("git", "git", "pull", nullptr);
@ -266,12 +266,12 @@ install_from_git(const std::string& repo)
return false;
}
if (ghc::filesystem::is_directory(local_formats_path)
|| ghc::filesystem::is_directory(local_configs_path))
if (std::filesystem::is_directory(local_formats_path)
|| std::filesystem::is_directory(local_configs_path))
{
return false;
}
if (!ghc::filesystem::is_directory(local_staging_path)) {
if (!std::filesystem::is_directory(local_staging_path)) {
auto um
= lnav::console::user_message::error(
attr_line_t("failed to install git repo: ")
@ -293,7 +293,7 @@ install_from_git(const std::string& repo)
if (glob(config_path.c_str(), 0, nullptr, gl.inout()) == 0) {
for (size_t lpc = 0; lpc < gl->gl_pathc; lpc++) {
auto file_path = ghc::filesystem::path{gl->gl_pathv[lpc]};
auto file_path = std::filesystem::path{gl->gl_pathv[lpc]};
if (file_path.extension() == ".lnav") {
found_lnav_file += 1;
@ -380,7 +380,7 @@ update_installs_from_git()
if (glob(git_formats.c_str(), 0, nullptr, gl.inout()) == 0) {
for (int lpc = 0; lpc < (int) gl->gl_pathc; lpc++) {
auto git_dir
= ghc::filesystem::path(gl->gl_pathv[lpc]).parent_path();
= std::filesystem::path(gl->gl_pathv[lpc]).parent_path();
printf("Updating formats in %s\n", git_dir.c_str());
auto pull_cmd = fmt::format(FMT_STRING("cd '{}' && git pull"),
@ -1723,7 +1723,7 @@ public:
static active_key_map_listener KEYMAP_LISTENER;
Result<config_file_type, std::string>
detect_config_file_type(const ghc::filesystem::path& path)
detect_config_file_type(const std::filesystem::path& path)
{
static const char* id_path[] = {"$schema", nullptr};
@ -1758,7 +1758,7 @@ detect_config_file_type(const ghc::filesystem::path& path)
static void
load_config_from(_lnav_config& lconfig,
const ghc::filesystem::path& path,
const std::filesystem::path& path,
std::vector<lnav::console::user_message>& errors)
{
yajlpp_parse_context ypc(intern_string::lookup(path.string()),
@ -1856,7 +1856,7 @@ load_default_configs(struct _lnav_config& config_obj,
}
void
load_config(const std::vector<ghc::filesystem::path>& extra_paths,
load_config(const std::vector<std::filesystem::path>& extra_paths,
std::vector<lnav::console::user_message>& errors)
{
auto user_config = lnav::paths::dotlnav() / "config.json";

@ -45,7 +45,7 @@
#include "base/result.h"
#include "external_opener.cfg.hh"
#include "file_vtab.cfg.hh"
#include "ghc/filesystem.hpp"
#include <filesystem>
#include "lnav_config_fwd.hh"
#include "log.annotate.cfg.hh"
#include "log_level.hh"
@ -144,9 +144,9 @@ enum class config_file_type {
};
Result<config_file_type, std::string> detect_config_file_type(
const ghc::filesystem::path& path);
const std::filesystem::path& path);
void load_config(const std::vector<ghc::filesystem::path>& extra_paths,
void load_config(const std::vector<std::filesystem::path>& extra_paths,
std::vector<lnav::console::user_message>& errors);
void reset_config(const std::string& path);

@ -258,10 +258,10 @@ apply(vis_line_t vl, std::vector<intern_string_t> annos)
nullptr,
};
std::vector<ghc::filesystem::path> path_v;
std::vector<std::filesystem::path> path_v;
auto src_path
= ghc::filesystem::path(
= std::filesystem::path(
iter->second.a_handler.pp_location.sl_source.to_string())
.parent_path();
path_v.push_back(src_path);

@ -134,10 +134,10 @@ action_delegate::execute_action(const std::string& action_name)
std::move(out_pipe.read_end()),
false,
lnav::filesystem::open_temp_file(
ghc::filesystem::temp_directory_path()
std::filesystem::temp_directory_path()
/ "lnav.action.XXXXXX")
.map([](auto pair) {
ghc::filesystem::remove(pair.first);
std::filesystem::remove(pair.first);
return pair;
})

@ -2632,7 +2632,7 @@ using safe_format_header_expressions = safe::Safe<format_header_expressions>;
static safe_format_header_expressions format_header_exprs;
std::optional<external_file_format>
detect_mime_type(const ghc::filesystem::path& filename)
detect_mime_type(const std::filesystem::path& filename)
{
uint8_t buffer[1024];
size_t buffer_size = 0;

@ -322,7 +322,7 @@ public:
GRAPH_ORDERED_FORMATS;
std::set<std::string> elf_source_path;
std::vector<ghc::filesystem::path> elf_format_source_order;
std::vector<std::filesystem::path> elf_format_source_order;
std::map<intern_string_t, int> elf_format_sources;
std::list<intern_string_t> elf_collision;
factory_container<lnav::pcre2pp::code> elf_filename_pcre;

@ -69,7 +69,7 @@ static log_formats_map_t LOG_FORMATS;
struct loader_userdata {
yajlpp_parse_context* ud_parse_context{nullptr};
std::string ud_file_schema;
ghc::filesystem::path ud_format_path;
std::filesystem::path ud_format_path;
std::vector<intern_string_t>* ud_format_names{nullptr};
std::vector<lnav::console::user_message>* ud_errors{nullptr};
};
@ -1221,7 +1221,7 @@ format_error_reporter(const yajlpp_parse_context& ypc,
}
std::vector<intern_string_t>
load_format_file(const ghc::filesystem::path& filename,
load_format_file(const std::filesystem::path& filename,
std::vector<lnav::console::user_message>& errors)
{
std::vector<intern_string_t> retval;
@ -1310,7 +1310,7 @@ load_format_file(const ghc::filesystem::path& filename,
}
static void
load_from_path(const ghc::filesystem::path& path,
load_from_path(const std::filesystem::path& path,
std::vector<lnav::console::user_message>& errors)
{
auto format_path = path / "formats/*/*.json";
@ -1319,7 +1319,7 @@ load_from_path(const ghc::filesystem::path& path,
log_info("loading formats from path: %s", format_path.c_str());
if (glob(format_path.c_str(), 0, nullptr, gl.inout()) == 0) {
for (int lpc = 0; lpc < (int) gl->gl_pathc; lpc++) {
auto filepath = ghc::filesystem::path(gl->gl_pathv[lpc]);
auto filepath = std::filesystem::path(gl->gl_pathv[lpc]);
if (startswith(filepath.filename().string(), "config.")) {
log_info(" not loading config as format: %s",
@ -1343,7 +1343,7 @@ load_from_path(const ghc::filesystem::path& path,
}
void
load_formats(const std::vector<ghc::filesystem::path>& extra_paths,
load_formats(const std::vector<std::filesystem::path>& extra_paths,
std::vector<lnav::console::user_message>& errors)
{
auto default_source = lnav::paths::dotlnav() / "default";
@ -1479,7 +1479,7 @@ load_formats(const std::vector<ghc::filesystem::path>& extra_paths,
static void
exec_sql_in_path(sqlite3* db,
const std::map<std::string, scoped_value_t>& global_vars,
const ghc::filesystem::path& path,
const std::filesystem::path& path,
std::vector<lnav::console::user_message>& errors)
{
auto format_path = path / "formats/*/*.sql";
@ -1488,7 +1488,7 @@ exec_sql_in_path(sqlite3* db,
log_info("executing SQL files in path: %s", format_path.c_str());
if (glob(format_path.c_str(), 0, nullptr, gl.inout()) == 0) {
for (int lpc = 0; lpc < (int) gl->gl_pathc; lpc++) {
auto filename = ghc::filesystem::path(gl->gl_pathv[lpc]);
auto filename = std::filesystem::path(gl->gl_pathv[lpc]);
auto read_res = lnav::filesystem::read_file(filename);
if (read_res.isOk()) {
@ -1511,7 +1511,7 @@ exec_sql_in_path(sqlite3* db,
void
load_format_extra(sqlite3* db,
const std::map<std::string, scoped_value_t>& global_vars,
const std::vector<ghc::filesystem::path>& extra_paths,
const std::vector<std::filesystem::path>& extra_paths,
std::vector<lnav::console::user_message>& errors)
{
for (const auto& extra_path : extra_paths) {
@ -1585,7 +1585,7 @@ extract_metadata_from_file(struct script_metadata& meta_inout)
}
static void
find_format_in_path(const ghc::filesystem::path& path,
find_format_in_path(const std::filesystem::path& path,
available_scripts& scripts)
{
for (auto format_path :
@ -1612,7 +1612,7 @@ find_format_in_path(const ghc::filesystem::path& path,
}
void
find_format_scripts(const std::vector<ghc::filesystem::path>& extra_paths,
find_format_scripts(const std::vector<std::filesystem::path>& extra_paths,
available_scripts& scripts)
{
for (const auto& extra_path : extra_paths) {

@ -39,16 +39,16 @@
#include "base/intern_string.hh"
#include "base/lnav.console.hh"
#include "ghc/filesystem.hpp"
#include <filesystem>
#include "shlex.resolver.hh"
class log_vtab_manager;
std::vector<intern_string_t> load_format_file(
const ghc::filesystem::path& filename,
const std::filesystem::path& filename,
std::vector<lnav::console::user_message>& errors);
void load_formats(const std::vector<ghc::filesystem::path>& extra_paths,
void load_formats(const std::vector<std::filesystem::path>& extra_paths,
std::vector<lnav::console::user_message>& errors);
void load_format_vtabs(log_vtab_manager* vtab_manager,
@ -56,11 +56,11 @@ void load_format_vtabs(log_vtab_manager* vtab_manager,
void load_format_extra(sqlite3* db,
const std::map<std::string, scoped_value_t>& global_vars,
const std::vector<ghc::filesystem::path>& extra_paths,
const std::vector<std::filesystem::path>& extra_paths,
std::vector<lnav::console::user_message>& errors);
struct script_metadata {
ghc::filesystem::path sm_path;
std::filesystem::path sm_path;
std::string sm_name;
std::string sm_synopsis;
std::string sm_description;
@ -72,7 +72,7 @@ struct available_scripts {
std::map<std::string, std::vector<script_metadata>> as_scripts;
};
void find_format_scripts(const std::vector<ghc::filesystem::path>& extra_paths,
void find_format_scripts(const std::vector<std::filesystem::path>& extra_paths,
available_scripts& scripts);
extern const struct json_path_container format_handlers;

@ -70,7 +70,7 @@ static const typed_json_path_container<lnav::gzip::header> file_header_handlers
};
Result<std::shared_ptr<logfile>, std::string>
logfile::open(ghc::filesystem::path filename,
logfile::open(std::filesystem::path filename,
const logfile_open_options& loo,
auto_fd fd)
{
@ -79,7 +79,7 @@ logfile::open(ghc::filesystem::path filename,
auto lf = std::shared_ptr<logfile>(new logfile(std::move(filename), loo));
memset(&lf->lf_stat, 0, sizeof(lf->lf_stat));
ghc::filesystem::path resolved_path;
std::filesystem::path resolved_path;
if (!fd.has_value()) {
auto rp_res = lnav::filesystem::realpath(lf->lf_filename);
@ -196,7 +196,7 @@ logfile::open(ghc::filesystem::path filename,
return Ok(lf);
}
logfile::logfile(ghc::filesystem::path filename,
logfile::logfile(std::filesystem::path filename,
const logfile_open_options& loo)
: lf_filename(std::move(filename)), lf_options(loo)
{
@ -1297,7 +1297,7 @@ logfile::reobserve_from(iterator iter)
}
}
ghc::filesystem::path
std::filesystem::path
logfile::get_path() const
{
return this->lf_filename;
@ -1420,7 +1420,7 @@ logfile::set_filename(const std::string& filename)
{
if (this->lf_filename != filename) {
this->lf_filename = filename;
ghc::filesystem::path p(filename);
std::filesystem::path p(filename);
this->lf_basename = p.filename();
}
}

@ -49,7 +49,7 @@
#include "bookmarks.hh"
#include "byte_array.hh"
#include "file_options.hh"
#include "ghc/filesystem.hpp"
#include <filesystem>
#include "line_buffer.hh"
#include "log_format_fwd.hh"
#include "logfile_fwd.hh"
@ -114,7 +114,7 @@ public:
* descriptor needs to be seekable.
*/
static Result<std::shared_ptr<logfile>, std::string> open(
ghc::filesystem::path filename,
std::filesystem::path filename,
const logfile_open_options& loo,
auto_fd fd = auto_fd{});
@ -122,13 +122,13 @@ public:
const logfile_activity& get_activity() const { return this->lf_activity; }
std::optional<ghc::filesystem::path> get_actual_path() const
std::optional<std::filesystem::path> get_actual_path() const
{
return this->lf_actual_path;
}
/** @return The filename as given in the constructor. */
const ghc::filesystem::path& get_filename() const
const std::filesystem::path& get_filename() const
{
return this->lf_filename;
}
@ -371,7 +371,7 @@ public:
return true;
}
ghc::filesystem::path get_path() const override;
std::filesystem::path get_path() const override;
enum class note_type {
indexing_disabled,
@ -435,16 +435,16 @@ protected:
void set_format_base_time(log_format* lf);
private:
logfile(ghc::filesystem::path filename, const logfile_open_options& loo);
logfile(std::filesystem::path filename, const logfile_open_options& loo);
bool file_options_have_changed();
ghc::filesystem::path lf_filename;
std::filesystem::path lf_filename;
logfile_open_options lf_options;
logfile_activity lf_activity;
bool lf_named_file{true};
bool lf_valid_filename{true};
std::optional<ghc::filesystem::path> lf_actual_path;
std::optional<std::filesystem::path> lf_actual_path;
std::string lf_basename;
std::string lf_content_id;
struct stat lf_stat {};

@ -35,6 +35,8 @@
#include <chrono>
#include <string>
#include <sys/stat.h>
#include "base/auto_fd.hh"
#include "file_format.hh"
#include "piper.looper.hh"

@ -714,7 +714,7 @@ md2attr_line::to_attr_line(const pugi::xml_node& doc)
if (img_alt) {
link_label = img_alt.value();
} else if (img_src) {
link_label = ghc::filesystem::path(img_src.value())
link_label = std::filesystem::path(img_src.value())
.filename()
.string();
} else {
@ -726,14 +726,14 @@ md2attr_line::to_attr_line(const pugi::xml_node& doc)
if (is_url(src_value)) {
src_href = src_value;
} else {
auto src_path = ghc::filesystem::path(src_value);
auto src_path = std::filesystem::path(src_value);
std::error_code ec;
if (src_path.is_relative() && this->ml_source_path) {
src_path = this->ml_source_path.value().parent_path()
/ src_path;
}
auto canon_path = ghc::filesystem::canonical(src_path, ec);
auto canon_path = std::filesystem::canonical(src_path, ec);
if (!ec) {
src_path = canon_path;
}
@ -1074,7 +1074,7 @@ md2attr_line::append_url_footnote(std::string href_str)
last_block.append(to_superscript(this->ml_footnotes.size() + 1));
this->ml_last_superscript_index = last_block.length();
if (this->ml_source_path && href_str.find(':') == std::string::npos) {
auto link_path = ghc::filesystem::absolute(
auto link_path = std::filesystem::absolute(
this->ml_source_path.value().parent_path() / href_str);
href_str = fmt::format(FMT_STRING("file://{}"), link_path.string());

@ -31,7 +31,7 @@
#define lnav_md2attr_line_hh
#include "base/attr_line.hh"
#include "ghc/filesystem.hpp"
#include <filesystem>
#include "md4cpp.hh"
namespace pugi {
@ -42,7 +42,7 @@ class md2attr_line : public md4cpp::typed_event_handler<attr_line_t> {
public:
md2attr_line() { this->ml_blocks.resize(1); }
md2attr_line& with_source_path(std::optional<ghc::filesystem::path> path)
md2attr_line& with_source_path(std::optional<std::filesystem::path> path)
{
this->ml_source_path = path;
return *this;
@ -83,7 +83,7 @@ private:
void flush_footnotes();
attr_line_t to_attr_line(const pugi::xml_node& doc);
std::optional<ghc::filesystem::path> ml_source_path;
std::optional<std::filesystem::path> ml_source_path;
std::vector<attr_line_t> ml_blocks;
std::vector<list_block_t> ml_list_stack;
std::vector<table_t> ml_tables;

@ -189,7 +189,7 @@ environ_to_map()
looper::
looper(std::string name, auto_fd stdout_fd, auto_fd stderr_fd, options opts)
: l_name(std::move(name)), l_cwd(ghc::filesystem::current_path().string()),
: l_name(std::move(name)), l_cwd(std::filesystem::current_path().string()),
l_env(environ_to_map()), l_stdout(std::move(stdout_fd)),
l_stderr(std::move(stderr_fd)), l_options(opts)
{
@ -202,8 +202,8 @@ looper(std::string name, auto_fd stdout_fd, auto_fd stderr_fd, options opts)
hasher().update(getmstime()).update(l_name).to_string(),
count);
count += 1;
} while (ghc::filesystem::exists(this->l_out_dir));
ghc::filesystem::create_directories(this->l_out_dir);
} while (std::filesystem::exists(this->l_out_dir));
std::filesystem::create_directories(this->l_out_dir);
this->l_future = std::async(std::launch::async, [this]() { this->loop(); });
}
@ -638,7 +638,7 @@ looper::loop()
/ fmt::format(FMT_STRING("out.{}.{}"),
os.os_hash_id,
rotate_count % cfg.c_rotations);
ghc::filesystem::rename(tmp_path, out_path);
std::filesystem::rename(tmp_path, out_path);
}
ssize_t wrc;
@ -724,14 +724,15 @@ cleanup()
{
(void) std::async(std::launch::async, []() {
const auto& cfg = injector::get<const config&>();
auto now = std::chrono::system_clock::now();
auto now = std::filesystem::file_time_type{
std::chrono::system_clock::now().time_since_epoch()};
auto cache_path = storage_path();
std::vector<ghc::filesystem::path> to_remove;
std::vector<std::filesystem::path> to_remove;
for (const auto& cache_subdir :
ghc::filesystem::directory_iterator(cache_path))
std::filesystem::directory_iterator(cache_path))
{
auto mtime = ghc::filesystem::last_write_time(cache_subdir.path());
auto mtime = std::filesystem::last_write_time(cache_subdir.path());
auto exp_time = mtime + cfg.c_ttl;
if (now < exp_time) {
continue;
@ -740,9 +741,9 @@ cleanup()
bool is_recent = false;
for (const auto& entry :
ghc::filesystem::directory_iterator(cache_subdir))
std::filesystem::directory_iterator(cache_subdir))
{
auto mtime = ghc::filesystem::last_write_time(entry.path());
auto mtime = std::filesystem::last_write_time(entry.path());
auto exp_time = mtime + cfg.c_ttl;
if (now < exp_time) {
is_recent = true;
@ -756,7 +757,7 @@ cleanup()
for (auto& entry : to_remove) {
log_debug("removing piper directory: %s", entry.c_str());
ghc::filesystem::remove_all(entry);
std::filesystem::remove_all(entry);
}
});
}

@ -37,7 +37,7 @@
#include "base/auto_fd.hh"
#include "base/piper.file.hh"
#include "base/result.h"
#include "ghc/filesystem.hpp"
#include <filesystem>
#include "safe/safe.h"
#include "yajlpp/yajlpp_def.hh"
@ -79,9 +79,9 @@ public:
std::string get_name() const { return this->l_name; }
ghc::filesystem::path get_out_dir() const { return this->l_out_dir; }
std::filesystem::path get_out_dir() const { return this->l_out_dir; }
ghc::filesystem::path get_out_pattern() const
std::filesystem::path get_out_pattern() const
{
return this->l_out_dir / "out.*";
}
@ -124,7 +124,7 @@ private:
const std::string l_name;
const std::string l_cwd;
const std::map<std::string, std::string> l_env;
ghc::filesystem::path l_out_dir;
std::filesystem::path l_out_dir;
auto_fd l_stdout;
auto_fd l_stderr;
options l_options;
@ -144,12 +144,12 @@ public:
std::string get_name() const { return this->h_looper->get_name(); }
ghc::filesystem::path get_out_dir() const
std::filesystem::path get_out_dir() const
{
return this->h_looper->get_out_dir();
}
ghc::filesystem::path get_out_pattern() const
std::filesystem::path get_out_pattern() const
{
return this->h_looper->get_out_pattern();
}

@ -1015,7 +1015,7 @@ rl_callback_int(readline_curses* rc, bool is_alt)
case ln_mode_t::EXEC: {
std::error_code errc;
ghc::filesystem::create_directories(lnav::paths::workdir(), errc);
std::filesystem::create_directories(lnav::paths::workdir(), errc);
auto open_temp_res = lnav::filesystem::open_temp_file(
lnav::paths::workdir() / "exec.XXXXXX");

@ -35,6 +35,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <unistd.h>
@ -640,9 +641,10 @@ readline_context::command_complete(int count, int key)
return rl_insert(count, key);
}
readline_context::readline_context(std::string name,
readline_context::command_map_t* commands,
bool case_sensitive)
readline_context::
readline_context(std::string name,
readline_context::command_map_t* commands,
bool case_sensitive)
: rc_name(std::move(name)), rc_case_sensitive(case_sensitive),
rc_quote_chars("\"'"), rc_highlighter(nullptr)
{
@ -723,8 +725,8 @@ readline_context::save()
hs = nullptr;
}
readline_curses::readline_curses(
std::shared_ptr<pollable_supervisor> supervisor)
readline_curses::
readline_curses(std::shared_ptr<pollable_supervisor> supervisor)
: pollable(supervisor, pollable::category::interactive),
rc_focus(noop_func{}), rc_change(noop_func{}), rc_perform(noop_func{}),
rc_alt_perform(noop_func{}), rc_timeout(noop_func{}),
@ -734,7 +736,8 @@ readline_curses::readline_curses(
{
}
readline_curses::~readline_curses()
readline_curses::~
readline_curses()
{
this->rc_pty[RCF_MASTER].reset();
this->rc_command_pipe[RCF_MASTER].reset();
@ -849,16 +852,16 @@ readline_curses::start()
throw error(errno);
}
auto slave_path = ghc::filesystem::path(slave_path_str);
auto slave_path = std::filesystem::path(slave_path_str);
std::error_code ec;
if (!ghc::filesystem::exists(slave_path, ec)) {
if (!std::filesystem::exists(slave_path, ec)) {
log_warning("ptsname_r() result does not exist -- %s", slave_path_str);
#ifdef TIOCGPTN
int ptn = 0;
if (ioctl(this->rc_pty[RCF_MASTER], TIOCGPTN, &ptn) == 0) {
snprintf(
slave_path_str, sizeof(slave_path_str), "/dev/ttyp%d", ptn);
slave_path = ghc::filesystem::path(slave_path_str);
slave_path = std::filesystem::path(slave_path_str);
log_warning("... trying %s", slave_path.c_str());
}
#endif

@ -479,7 +479,7 @@ add_config_possibilities()
visited.insert(named_cap.get_name().to_string());
}
ghc::filesystem::path path_obj(path);
std::filesystem::path path_obj(path);
rc->add_possibility(ln_mode_t::COMMAND,
named_cap.get_name().to_string(),
path_obj.parent_path().filename().string());

@ -34,7 +34,7 @@
#include "base/itertools.hh"
#include "config.h"
#include "curl_looper.hh"
#include "ghc/filesystem.hpp"
#include <filesystem>
#include "yajlpp/yajlpp_def.hh"
namespace regex101 {
@ -80,7 +80,7 @@ static const typed_json_path_container<upsert_response> RESPONSE_HANDLERS = {
yajlpp::property_handler("version").for_field(&upsert_response::cr_version),
};
static const ghc::filesystem::path REGEX101_BASE_URL
static const std::filesystem::path REGEX101_BASE_URL
= "https://regex101.com/api/regex";
static const char* USER_AGENT = "lnav/" PACKAGE_VERSION;

@ -47,7 +47,7 @@ static const std::set<std::string> SUPPORTED_FLAVORS = {
"pcre2",
};
Result<ghc::filesystem::path, lnav::console::user_message>
Result<std::filesystem::path, lnav::console::user_message>
regex101::import(const std::string& url,
const std::string& name,
const std::string& pat_name)
@ -124,7 +124,7 @@ regex101::import(const std::string& url,
auto format_path
= lnav::paths::dotlnav() / "formats" / "installed" / format_filename;
if (ghc::filesystem::exists(format_path)) {
if (std::filesystem::exists(format_path)) {
return Err(lnav::console::user_message::error(
attr_line_t("unable to import: ")
.append(lnav::roles::file(url)))
@ -270,7 +270,7 @@ regex101::import(const std::string& url,
return Ok(format_path);
}
ghc::filesystem::path
std::filesystem::path
regex101::patch_path(const external_log_format* format,
const std::string& permalink)
{
@ -287,7 +287,7 @@ regex101::patch_path(const external_log_format* format,
fmt::format(FMT_STRING("regex101-{}.json"), permalink));
}
Result<ghc::filesystem::path, lnav::console::user_message>
Result<std::filesystem::path, lnav::console::user_message>
regex101::patch(const external_log_format* format,
const std::string& pat_name,
const regex101::client::entry& entry)

@ -33,21 +33,21 @@
#include <map>
#include "base/lnav.console.hh"
#include "ghc/filesystem.hpp"
#include <filesystem>
#include "log_format_ext.hh"
#include "regex101.client.hh"
namespace regex101 {
Result<ghc::filesystem::path, lnav::console::user_message> import(
Result<std::filesystem::path, lnav::console::user_message> import(
const std::string& url,
const std::string& name,
const std::string& pat_name);
ghc::filesystem::path patch_path(const external_log_format* format,
std::filesystem::path patch_path(const external_log_format* format,
const std::string& permalink);
Result<ghc::filesystem::path, lnav::console::user_message> patch(
Result<std::filesystem::path, lnav::console::user_message> patch(
const external_log_format* format,
const std::string& pat_name,
const regex101::client::entry& entry);

@ -113,14 +113,14 @@ struct from_sqlite<log_file_session_state> {
namespace lnav {
namespace session {
static std::optional<ghc::filesystem::path>
find_container_dir(ghc::filesystem::path file_path)
static std::optional<std::filesystem::path>
find_container_dir(std::filesystem::path file_path)
{
if (!ghc::filesystem::exists(file_path)) {
if (!std::filesystem::exists(file_path)) {
return std::nullopt;
}
std::optional<ghc::filesystem::path> dir_with_last_readme;
std::optional<std::filesystem::path> dir_with_last_readme;
while (file_path.has_parent_path()
&& file_path != file_path.root_directory())
@ -130,7 +130,7 @@ find_container_dir(ghc::filesystem::path file_path)
std::error_code ec;
for (const auto& entry :
ghc::filesystem::directory_iterator(parent, ec))
std::filesystem::directory_iterator(parent, ec))
{
if (!entry.is_regular_file()) {
continue;
@ -281,12 +281,12 @@ SELECT content_id, format, time_offset FROM lnav_file
}
auto file_path_str = name_pair.first;
auto file_path = ghc::filesystem::path(file_path_str);
auto file_path = std::filesystem::path(file_path_str);
auto container_path_opt = find_container_dir(file_path);
if (container_path_opt) {
auto container_parent = container_path_opt.value().parent_path();
auto file_container_path
= ghc::filesystem::relative(file_path, container_parent)
= std::filesystem::relative(file_path, container_parent)
.string();
file_containers[container_parent.string()].push_back(
file_container_path);
@ -474,7 +474,7 @@ SELECT content_id, format, time_offset FROM lnav_file
}
auto container_parent
= container_path_opt.value().parent_path();
auto file_container_path = ghc::filesystem::relative(
auto file_container_path = std::filesystem::relative(
ld->get_file_ptr()->get_path(), container_parent);
fmt::print(file,
FMT_STRING(":hide-file */{}\n"),

@ -37,7 +37,7 @@
#include "base/fs_util.hh"
#include "base/lnav_log.hh"
#include "config.h"
#include "ghc/filesystem.hpp"
#include <filesystem>
#include "lnav.hh"
#include "vtab_module.hh"
@ -49,7 +49,7 @@ struct static_file_vtab {
};
struct static_file_info {
ghc::filesystem::path sfi_path;
std::filesystem::path sfi_path;
};
struct sf_vtab_cursor {
@ -124,13 +124,13 @@ sfvt_destroy(sqlite3_vtab* p_vt)
static int sfvt_next(sqlite3_vtab_cursor* cur);
static void
find_static_files(sf_vtab_cursor* p_cur, const ghc::filesystem::path& dir)
find_static_files(sf_vtab_cursor* p_cur, const std::filesystem::path& dir)
{
auto& file_map = p_cur->vc_files;
std::error_code ec;
for (const auto& format_dir_entry :
ghc::filesystem::directory_iterator(dir, ec))
std::filesystem::directory_iterator(dir, ec))
{
if (!format_dir_entry.is_directory()) {
continue;
@ -138,10 +138,10 @@ find_static_files(sf_vtab_cursor* p_cur, const ghc::filesystem::path& dir)
auto format_static_files_dir = format_dir_entry.path() / "static-files";
log_debug("format static files: %s", format_static_files_dir.c_str());
for (const auto& static_file_entry :
ghc::filesystem::recursive_directory_iterator(
std::filesystem::recursive_directory_iterator(
format_static_files_dir, ec))
{
auto rel_path = ghc::filesystem::relative(static_file_entry.path(),
auto rel_path = std::filesystem::relative(static_file_entry.path(),
format_static_files_dir);
file_map[rel_path.string()] = {static_file_entry.path()};

@ -34,7 +34,7 @@
#include "base/auto_fd.hh"
#include "base/auto_pid.hh"
#include "config.h"
#include "ghc/filesystem.hpp"
#include <filesystem>
#include "line_buffer.hh"
#include "tailerpp.hh"
@ -102,7 +102,7 @@ main(int argc, char* const* argv)
err_pipe.after_fork(child.in());
if (child.in_child()) {
auto this_exe = ghc::filesystem::path(argv[0]);
auto this_exe = std::filesystem::path(argv[0]);
auto exe_dir = this_exe.parent_path();
auto tailer_exe = exe_dir / "tailer";
@ -165,8 +165,8 @@ main(int argc, char* const* argv)
pe.pe_path.c_str(),
pe.pe_msg.c_str());
auto remote_path = ghc::filesystem::absolute(
ghc::filesystem::path(pe.pe_path))
auto remote_path = std::filesystem::absolute(
std::filesystem::path(pe.pe_path))
.relative_path();
printf("removing %s\n", remote_path.c_str());
@ -177,8 +177,8 @@ main(int argc, char* const* argv)
pob.pob_offset,
pob.pob_length);
auto remote_path = ghc::filesystem::absolute(
ghc::filesystem::path(pob.pob_path))
auto remote_path = std::filesystem::absolute(
std::filesystem::path(pob.pob_path))
.relative_path();
#if 0
auto local_path = tmppath / remote_path;
@ -196,7 +196,7 @@ main(int argc, char* const* argv)
struct stat st;
if (fstat(fd, &st) == -1 || !S_ISREG(st.st_mode)) {
ghc::filesystem::remove_all(local_path);
std::filesystem::remove_all(local_path);
send_packet(to_child.get(),
TPT_NEED_BLOCK,
TPPT_STRING, pob.pob_path.c_str(),
@ -222,7 +222,7 @@ main(int argc, char* const* argv)
return;
}
} else if (bytes_read == -1) {
ghc::filesystem::remove_all(local_path);
std::filesystem::remove_all(local_path);
}
send_packet(to_child.get(),
TPT_NEED_BLOCK,
@ -234,11 +234,11 @@ main(int argc, char* const* argv)
#if 0
//printf("got a tail: %s %lld %ld\n", ptb.ptb_path.c_str(),
// ptb.ptb_offset, ptb.ptb_bits.size());
auto remote_path = ghc::filesystem::absolute(
ghc::filesystem::path(ptb.ptb_path)).relative_path();
auto remote_path = std::filesystem::absolute(
std::filesystem::path(ptb.ptb_path)).relative_path();
auto local_path = tmppath / remote_path;
ghc::filesystem::create_directories(local_path.parent_path());
std::filesystem::create_directories(local_path.parent_path());
auto fd = auto_fd(
open(local_path.c_str(), O_WRONLY | O_APPEND | O_CREAT,
0600));

@ -448,18 +448,18 @@ tailer::looper::host_tailer::for_host(const std::string& netloc)
std::move(err_pipe.read_end())));
}
static ghc::filesystem::path
static std::filesystem::path
remote_cache_path()
{
return lnav::paths::workdir() / "remotes";
}
ghc::filesystem::path
std::filesystem::path
tailer::looper::host_tailer::tmp_path()
{
auto local_path = remote_cache_path();
ghc::filesystem::create_directories(local_path);
std::filesystem::create_directories(local_path);
auto_mem<char> resolved_path;
resolved_path = realpath(local_path.c_str(), nullptr);
@ -478,11 +478,12 @@ scrub_netloc(const std::string& netloc)
return std::regex_replace(netloc, TO_SCRUB, "_");
}
tailer::looper::host_tailer::host_tailer(const std::string& netloc,
auto_pid<process_state::running> child,
auto_fd to_child,
auto_fd from_child,
auto_fd err_from_child)
tailer::looper::host_tailer::
host_tailer(const std::string& netloc,
auto_pid<process_state::running> child,
auto_fd to_child,
auto_fd from_child,
auto_fd err_from_child)
: isc::service<host_tailer>(netloc), ht_netloc(netloc),
ht_local_path(tmp_path() / scrub_netloc(netloc)),
ht_error_reader([netloc,
@ -578,9 +579,9 @@ tailer::looper::host_tailer::loop_body()
this->ht_cycle_count += 1;
if (this->ht_cycle_count % TOUCH_FREQ == 0) {
auto now
= ghc::filesystem::file_time_type{std::chrono::system_clock::now()};
ghc::filesystem::last_write_time(this->ht_local_path, now);
auto now = std::filesystem::file_time_type{
std::chrono::system_clock::now().time_since_epoch()};
std::filesystem::last_write_time(this->ht_local_path, now);
}
auto& conn = this->ht_state.get<connected>();
@ -648,14 +649,14 @@ tailer::looper::host_tailer::loop_body()
}
}
auto remote_path = ghc::filesystem::absolute(
ghc::filesystem::path(pe.pe_path))
auto remote_path = std::filesystem::absolute(
std::filesystem::path(pe.pe_path))
.relative_path();
auto local_path = this->ht_local_path / remote_path;
log_debug("removing %s", local_path.c_str());
this->ht_active_files.erase(local_path);
ghc::filesystem::remove_all(local_path);
std::filesystem::remove_all(local_path);
if (conn.c_desired_paths.empty() && conn.c_child_paths.empty())
{
@ -706,8 +707,8 @@ tailer::looper::host_tailer::loop_body()
update_tailer_description(
this->ht_netloc, conn.c_desired_paths, this->ht_uname);
auto remote_path = ghc::filesystem::absolute(
ghc::filesystem::path(pob.pob_path))
auto remote_path = std::filesystem::absolute(
std::filesystem::path(pob.pob_path))
.relative_path();
auto local_path = this->ht_local_path / remote_path;
auto open_res
@ -769,7 +770,7 @@ tailer::looper::host_tailer::loop_body()
if (fstat(fd, &st) == -1 || !S_ISREG(st.st_mode)) {
log_debug("path changed, sending need block");
ghc::filesystem::remove_all(local_path);
std::filesystem::remove_all(local_path);
send_packet(conn.ht_to_child.get(),
TPT_NEED_BLOCK,
TPPT_STRING,
@ -808,7 +809,7 @@ tailer::looper::host_tailer::loop_body()
log_debug(
"unable to read file, sending need block -- %s",
strerror(errno));
ghc::filesystem::remove_all(local_path);
std::filesystem::remove_all(local_path);
break;
}
if (bytes_read == 0) {
@ -847,8 +848,8 @@ tailer::looper::host_tailer::loop_body()
return std::move(this->ht_state);
},
[&](const tailer::packet_tail_block& ptb) {
auto remote_path = ghc::filesystem::absolute(
ghc::filesystem::path(ptb.ptb_path))
auto remote_path = std::filesystem::absolute(
std::filesystem::path(ptb.ptb_path))
.relative_path();
auto local_path = this->ht_local_path / remote_path;
@ -856,7 +857,7 @@ tailer::looper::host_tailer::loop_body()
ptb.ptb_offset,
ptb.ptb_bits.size(),
local_path.c_str());
ghc::filesystem::create_directories(local_path.parent_path());
std::filesystem::create_directories(local_path.parent_path());
auto create_res = lnav::filesystem::create_file(
local_path, O_WRONLY | O_APPEND | O_CREAT, 0600);
@ -869,10 +870,10 @@ tailer::looper::host_tailer::loop_body()
ptb.ptb_bits.data(),
ptb.ptb_bits.size(),
ptb.ptb_offset);
auto mtime = ghc::filesystem::file_time_type{
auto mtime = std::filesystem::file_time_type{
std::chrono::seconds{ptb.ptb_mtime}};
// XXX This isn't atomic with the write...
ghc::filesystem::last_write_time(local_path, mtime);
std::filesystem::last_write_time(local_path, mtime);
}
return std::move(this->ht_state);
},
@ -935,11 +936,11 @@ tailer::looper::host_tailer::loop_body()
return std::move(this->ht_state);
},
[&](const tailer::packet_link& pl) {
auto remote_path = ghc::filesystem::absolute(
ghc::filesystem::path(pl.pl_path))
auto remote_path = std::filesystem::absolute(
std::filesystem::path(pl.pl_path))
.relative_path();
auto local_path = this->ht_local_path / remote_path;
auto remote_link_path = ghc::filesystem::path(pl.pl_link_value);
auto remote_link_path = std::filesystem::path(pl.pl_link_value);
std::string link_path;
if (remote_link_path.is_absolute()) {
@ -954,8 +955,8 @@ tailer::looper::host_tailer::loop_body()
log_debug("symlinking %s -> %s",
local_path.c_str(),
link_path.c_str());
ghc::filesystem::create_directories(local_path.parent_path());
ghc::filesystem::remove_all(local_path);
std::filesystem::create_directories(local_path.parent_path());
std::filesystem::remove_all(local_path);
if (symlink(link_path.c_str(), local_path.c_str()) < 0) {
log_error("symlink failed: %s", strerror(errno));
}
@ -1169,16 +1170,17 @@ void
tailer::cleanup_cache()
{
(void) std::async(std::launch::async, []() {
auto now = std::chrono::system_clock::now();
auto now = std::filesystem::file_time_type{
std::chrono::system_clock::now().time_since_epoch()};
auto cache_path = remote_cache_path();
const auto& cfg = injector::get<const config&>();
std::vector<ghc::filesystem::path> to_remove;
std::vector<std::filesystem::path> to_remove;
log_debug("cache-ttl %d", cfg.c_cache_ttl.count());
for (const auto& entry :
ghc::filesystem::directory_iterator(cache_path))
std::filesystem::directory_iterator(cache_path))
{
auto mtime = ghc::filesystem::last_write_time(entry.path());
auto mtime = std::filesystem::last_write_time(entry.path());
auto exp_time = mtime + cfg.c_cache_ttl;
if (now < exp_time) {
continue;
@ -1189,7 +1191,7 @@ tailer::cleanup_cache()
for (auto& entry : to_remove) {
log_debug("removing cached remote: %s", entry.c_str());
ghc::filesystem::remove_all(entry);
std::filesystem::remove_all(entry);
}
});
}

@ -38,7 +38,7 @@
#include "base/auto_pid.hh"
#include "base/isc.hh"
#include "base/network.tcp.hh"
#include "ghc/filesystem.hpp"
#include <filesystem>
#include "mapbox/variant.hpp"
namespace tailer {
@ -101,7 +101,7 @@ private:
mstime_t current_time) const override;
private:
static ghc::filesystem::path tmp_path();
static std::filesystem::path tmp_path();
std::string get_display_path(const std::string& remote_path) const;
@ -125,8 +125,8 @@ private:
const std::string ht_netloc;
std::string ht_uname;
const ghc::filesystem::path ht_local_path;
std::set<ghc::filesystem::path> ht_active_files;
const std::filesystem::path ht_local_path;
std::set<std::filesystem::path> ht_active_files;
std::vector<std::string> ht_error_queue;
std::thread ht_error_reader;
state_v ht_state{disconnected()};

@ -37,7 +37,7 @@
#include "config.h"
#include "data_scanner.hh"
#include "diseases-json.h"
#include "ghc/filesystem.hpp"
#include <filesystem>
#include "hasher.hh"
#include "pcrepp/pcre2pp.hh"
#include "words-json.h"
@ -205,8 +205,8 @@ text_anonymizer::next(string_fragment line)
cu, CURLUPART_PATH, url_part.out(), CURLU_URLDECODE)
== CURLUE_OK)
{
ghc::filesystem::path url_path(url_part.in());
ghc::filesystem::path anon_path;
std::filesystem::path url_path(url_part.in());
std::filesystem::path anon_path;
for (const auto& comp : url_path) {
if (comp == comp.root_path()) {
@ -290,8 +290,8 @@ text_anonymizer::next(string_fragment line)
break;
}
case DT_PATH: {
ghc::filesystem::path inp_path(tok_res->to_string());
ghc::filesystem::path anon_path;
std::filesystem::path inp_path(tok_res->to_string());
std::filesystem::path anon_path;
for (const auto& comp : inp_path) {
auto comp_str = comp.string();

@ -40,16 +40,16 @@
text_format_t
detect_text_format(string_fragment sf,
std::optional<ghc::filesystem::path> path)
std::optional<std::filesystem::path> path)
{
static const std::set<ghc::filesystem::path> FILTER_EXTS = {
static const std::set<std::filesystem::path> FILTER_EXTS = {
".bz2",
".gz",
".lzma",
".xz",
".zst",
};
static const auto C_EXTS = std::set<ghc::filesystem::path>{
static const auto C_EXTS = std::set<std::filesystem::path>{
".h",
".hh",
".hpp",
@ -58,17 +58,17 @@ detect_text_format(string_fragment sf,
".cpp",
".tpp",
};
static const auto PY_EXT = ghc::filesystem::path(".py");
static const auto RS_EXT = ghc::filesystem::path(".rs");
static const auto JAVA_EXT = ghc::filesystem::path(".java");
static const auto TOML_EXT = ghc::filesystem::path(".toml");
static const auto XML_EXT = ghc::filesystem::path(".xml");
static const auto YAML_EXT = ghc::filesystem::path(".yaml");
static const auto YML_EXT = ghc::filesystem::path(".yml");
static const auto MAKEFILE_STEM = ghc::filesystem::path("Makefile");
static const auto MD_EXT = ghc::filesystem::path(".md");
static const auto MARKDOWN_EXT = ghc::filesystem::path(".markdown");
static const auto SH_EXT = ghc::filesystem::path(".sh");
static const auto PY_EXT = std::filesystem::path(".py");
static const auto RS_EXT = std::filesystem::path(".rs");
static const auto JAVA_EXT = std::filesystem::path(".java");
static const auto TOML_EXT = std::filesystem::path(".toml");
static const auto XML_EXT = std::filesystem::path(".xml");
static const auto YAML_EXT = std::filesystem::path(".yaml");
static const auto YML_EXT = std::filesystem::path(".yml");
static const auto MAKEFILE_STEM = std::filesystem::path("Makefile");
static const auto MD_EXT = std::filesystem::path(".md");
static const auto MARKDOWN_EXT = std::filesystem::path(".markdown");
static const auto SH_EXT = std::filesystem::path(".sh");
static const auto DIFF_MATCHERS = lnav::pcre2pp::code::from_const(
R"(^--- .*\n\+\+\+ .*\n)", PCRE2_MULTILINE);

@ -38,7 +38,7 @@
#include "base/intern_string.hh"
#include "fmt/format.h"
#include "ghc/filesystem.hpp"
#include <filesystem>
enum class text_format_t {
TF_UNKNOWN,
@ -131,7 +131,7 @@ struct formatter<text_format_t> : formatter<string_view> {
* @return The detected format.
*/
text_format_t detect_text_format(string_fragment sf,
std::optional<ghc::filesystem::path> path
std::optional<std::filesystem::path> path
= std::nullopt);
struct text_format_meta_t {

@ -37,7 +37,7 @@
#include <string>
#include <vector>
#include "ghc/filesystem.hpp"
#include <filesystem>
/**
* A source of a path for the unique_path_generator.
@ -51,26 +51,26 @@ public:
this->ups_unique_path = path;
}
const ghc::filesystem::path& get_unique_path() const
const std::filesystem::path& get_unique_path() const
{
return this->ups_unique_path;
}
virtual ghc::filesystem::path get_path() const = 0;
virtual std::filesystem::path get_path() const = 0;
const ghc::filesystem::path& get_path_prefix() const
const std::filesystem::path& get_path_prefix() const
{
return this->ups_prefix;
}
void set_path_prefix(const ghc::filesystem::path& prefix)
void set_path_prefix(const std::filesystem::path& prefix)
{
this->ups_prefix = prefix;
}
private:
ghc::filesystem::path ups_prefix;
ghc::filesystem::path ups_unique_path;
std::filesystem::path ups_prefix;
std::filesystem::path ups_unique_path;
};
/**

@ -180,7 +180,7 @@ looper::open(std::string url)
host_part_str = host_part;
}
auto source_path = ghc::filesystem::path{
auto source_path = std::filesystem::path{
proto_iter->second.p_handler.pp_location.sl_source.get()};
auto new_path = lnav::filesystem::build_path({
source_path.parent_path(),

@ -45,7 +45,7 @@ public:
url_loader(const std::string& url) : curl_request(url)
{
std::error_code errc;
ghc::filesystem::create_directories(lnav::paths::workdir(), errc);
std::filesystem::create_directories(lnav::paths::workdir(), errc);
auto tmp_res = lnav::filesystem::open_temp_file(lnav::paths::workdir()
/ "url.XXXXXX");
if (tmp_res.isErr()) {
@ -63,7 +63,7 @@ public:
curl_easy_setopt(this->cr_handle, CURLOPT_BUFFERSIZE, 128L * 1024L);
}
ghc::filesystem::path get_path() const { return this->ul_path; }
std::filesystem::path get_path() const { return this->ul_path; }
long complete(CURLcode result)
{
@ -144,7 +144,7 @@ private:
return retval;
}
ghc::filesystem::path ul_path;
std::filesystem::path ul_path;
auto_fd ul_fd;
off_t ul_resume_offset{0};
};

@ -792,7 +792,7 @@ view_colors::to_attrs(const lnav_theme& lt,
reporter(&sc.sc_color, lnav::console::user_message::warning(""));
#endif
} else {
auto role_class_path = ghc::filesystem::path(pp_sc.pp_path.to_string());
auto role_class_path = std::filesystem::path(pp_sc.pp_path.to_string());
auto inner = role_class_path.filename().string();
auto outer = role_class_path.parent_path().filename().string();

@ -36,7 +36,7 @@
#include "config.h"
#include "fmt/format.h"
#include "ghc/filesystem.hpp"
#include <filesystem>
#include "yajl/api/yajl_parse.h"
#include "yajlpp_def.hh"
@ -1592,8 +1592,8 @@ dump_schema_to(const json_path_container& jpc, const char* internals_dir)
{
yajlpp_gen genner;
yajlpp_gen_context ygc(genner, jpc);
auto internals_dir_path = ghc::filesystem::path(internals_dir);
auto schema_file_name = ghc::filesystem::path(jpc.jpc_schema_id).filename();
auto internals_dir_path = std::filesystem::path(internals_dir);
auto schema_file_name = std::filesystem::path(jpc.jpc_schema_id).filename();
auto schema_path = internals_dir_path / schema_file_name;
auto file = std::unique_ptr<FILE, decltype(&fclose)>(
fopen(schema_path.c_str(), "w+"), fclose);

@ -74,7 +74,7 @@ main(int argc, char* argv[])
}
{
std::vector<ghc::filesystem::path> paths;
std::vector<std::filesystem::path> paths;
std::vector<lnav::console::user_message> errors;
load_formats(paths, errors);

@ -42,7 +42,7 @@ main(int argc, char* argv[])
fprintf(stderr, "error: expecting file to discover\n");
retval = EXIT_FAILURE;
} else {
const auto fn = ghc::filesystem::path(argv[1]);
const auto fn = std::filesystem::path(argv[1]);
auto read_res = lnav::filesystem::read_file(fn);
if (read_res.isErr()) {
fprintf(stderr,

@ -84,7 +84,7 @@ main(int argc, char* argv[])
{
std::vector<lnav::console::user_message> errors;
vector<ghc::filesystem::path> paths;
vector<std::filesystem::path> paths;
getenv_opt("test_dir") |
[&paths](auto value) { paths.template emplace_back(value); };

@ -210,11 +210,11 @@ TEST_CASE("ptime_roundtrip")
class my_path_source : public unique_path_source {
public:
explicit my_path_source(ghc::filesystem::path p) : mps_path(std::move(p)) {}
explicit my_path_source(std::filesystem::path p) : mps_path(std::move(p)) {}
ghc::filesystem::path get_path() const override { return this->mps_path; }
std::filesystem::path get_path() const override { return this->mps_path; }
ghc::filesystem::path mps_path;
std::filesystem::path mps_path;
};
TEST_CASE("unique_path")

@ -71,6 +71,7 @@
#endif
#include <algorithm>
#include <filesystem>
#include <map>
#include <queue>
#include <sstream>
@ -81,7 +82,6 @@
#include "base/auto_mem.hh"
#include "base/string_util.hh"
#include "fmt/format.h"
#include "ghc/filesystem.hpp"
#include "styling.hh"
#include "termios_guard.hh"
#include "ww898/cp_utf8.hpp"
@ -268,9 +268,9 @@ static struct {
pid_t sd_child_pid{-1};
ghc::filesystem::path sd_actual_name;
std::filesystem::path sd_actual_name;
auto_mem<FILE> sd_from_child{fclose};
ghc::filesystem::path sd_expected_name;
std::filesystem::path sd_expected_name;
deque<struct command> sd_replay;
} scripty_data;
@ -1123,8 +1123,8 @@ main(int argc, char* argv[])
scripty_data.sd_expected_name.c_str());
auto options
= ghc::filesystem::copy_options::overwrite_existing;
ghc::filesystem::copy_file(scripty_data.sd_actual_name,
= std::filesystem::copy_options::overwrite_existing;
std::filesystem::copy_file(scripty_data.sd_actual_name,
scripty_data.sd_expected_name,
options);
} else {

@ -48,6 +48,7 @@ run_cap_test ${lnav_test} -m -I ${test_dir} config blame
export TMPDIR="piper-tmp"
rm -rf ./piper-tmp
mkdir piper-tmp
run_cap_test ${lnav_test} -n -e 'echo hi'
run_cap_test ${lnav_test} -m piper list

@ -64,7 +64,7 @@ main(int argc, char* argv[])
setenv("HOME", "/", 1);
std::vector<lnav::console::user_message> errors;
std::vector<ghc::filesystem::path> paths;
std::vector<std::filesystem::path> paths;
load_config(paths, errors);

Loading…
Cancel
Save