From 9fb439ac12c81a3d58eecd30de2b2655b27c6f38 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Sat, 25 Mar 2023 22:28:50 -0500 Subject: image: C++2x and Boost.Filesystem fixes * Ensure that Boost.Filesystem is still usable. * Don't use a reference to a temporary in loops. Fixes: #333 --- image/backends/iso.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'image/backends/iso.cc') diff --git a/image/backends/iso.cc b/image/backends/iso.cc index c70f004..4b27cc8 100644 --- a/image/backends/iso.cc +++ b/image/backends/iso.cc @@ -57,7 +57,7 @@ const std::vector data_dirs() { return dirs; } -const fs::path find_data_file(std::string name) { +const fs::path find_data_file(const std::string &name) { error_code ec; for(const auto &p : data_dirs()) { fs::path src = fs::path(p).append("horizon").append("iso").append(name); @@ -87,7 +87,7 @@ bool copy_volume_icon_to(fs::path ir_dir) { } bool write_etc_mtab_to(fs::path target) { - std::ofstream mtab(target.append("etc/conf.d/mtab")); + std::ofstream mtab(target.append("etc/conf.d/mtab").string()); if(!mtab) { output_error("CD backend", "failed to open mtab configuration"); return false; @@ -103,7 +103,7 @@ bool write_etc_mtab_to(fs::path target) { } bool write_fstab_to(fs::path target) { - std::ofstream fstab{target.append("etc/fstab")}; + std::ofstream fstab{target.append("etc/fstab").string()}; if(!fstab) { output_error("CD backend", "failed to open fstab"); return false; @@ -138,7 +138,7 @@ bool write_etc_issue_to(fs::path target) { } /* We don't have a file, so write out our default. */ - std::ofstream issue(dest); + std::ofstream issue(dest.string()); if(!issue) { output_error("CD backend", "failed to open issue file"); return false; @@ -189,7 +189,7 @@ public: /* try to umount first, just in case * We don't care if the call fails. */ - for(const std::string &mount : {"dev", "proc", "sys"}) { + for(const std::string mount : {"dev", "proc", "sys"}) { const std::string path = this->ir_dir + "/target/" + mount; ::umount(path.c_str()); } @@ -278,7 +278,7 @@ public: /* REQ: ISO.10 */ output_info("CD backend", "enabling required services"); const std::string targetsi = target + "/etc/runlevels/sysinit/"; - for(const std::string &svc : {"udev", "udev-trigger", "lvmetad"}) { + for(const std::string svc : {"udev", "udev-trigger", "lvmetad"}) { fs::create_symlink("/etc/init.d/" + svc, targetsi + svc, ec); if(ec && ec.value() != EEXIST) { output_error("CD backend", "could not enable service " + svc, @@ -354,7 +354,7 @@ public: for(const auto &dent : fs::recursive_directory_iterator(target + "/usr/share/kernel", ec)) { - if(dent.is_regular_file() && + if(fs::is_regular_file(dent.path()) && dent.path().filename().string() == "kernel.release") { kverpath = dent.path().string(); break; @@ -391,7 +391,7 @@ public: fs::path candidate{fs::path{path}.append("horizon") .append("iso").append("post-" + my_arch + ".sh")}; if(fs::exists(candidate, ec)) { - postscript = candidate; + postscript = candidate.string(); break; } } @@ -431,7 +431,7 @@ public: { const fs::path param_file = find_data_file("iso-params-" + my_arch); if(param_file.has_filename()) { - std::ifstream params{param_file}; + std::ifstream params{param_file.string()}; if(!params) { output_warning("CD backend", "couldn't read ISO params"); } else { -- cgit v1.2.3-60-g2f50