From 0e08bc5e164bf850c0c3a33d218cccf36711a924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 18 Oct 2007 19:29:32 +0000 Subject: [PATCH] start using FileName::exists() git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21044 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 13 +++--- src/ConverterCache.cpp | 12 +++--- src/Exporter.cpp | 4 +- src/Format.cpp | 7 +--- src/LaTeX.cpp | 84 ++++++++++++------------------------- src/LyX.cpp | 2 +- src/LyXFunc.cpp | 6 +-- src/Session.cpp | 8 ++-- src/TextClass.cpp | 6 +-- src/TextClassList.cpp | 5 +-- src/buffer_funcs.cpp | 12 ++---- src/insets/InsetInclude.cpp | 5 +-- src/support/FileMonitor.cpp | 11 ++--- src/support/Package.cpp | 14 +++---- src/tex2lyx/text.cpp | 10 ++--- 15 files changed, 73 insertions(+), 126 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 03632c41b7..d1cbd25870 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -416,9 +416,8 @@ pair const Buffer::getLogName() const // If no Latex log or Build log is newer, show Build log - if (fs::exists(bname.toFilesystemEncoding()) && - (!fs::exists(fname.toFilesystemEncoding()) || - fs::last_write_time(fname.toFilesystemEncoding()) < fs::last_write_time(bname.toFilesystemEncoding()))) { + if (bname.exists() && + (!fname.exists() || fname.lastModified() < bname.lastModified())) { LYXERR(Debug::FILES) << "Log name calculated as: " << bname << endl; return make_pair(Buffer::buildlog, bname.absFilename()); } @@ -688,7 +687,7 @@ bool Buffer::readFile(FileName const & filename) // FileName lyxfile(addName(temppath(), "content.lyx")); // if both manifest.txt and file.lyx exist, this is am embedded file - if (fs::exists(lyxfile.toFilesystemEncoding())) { + if (lyxfile.exists()) { params().embedded = true; fname = lyxfile; } @@ -1645,10 +1644,10 @@ bool Buffer::isBakClean() const bool Buffer::isExternallyModified(CheckMethod method) const { - BOOST_ASSERT(fs::exists(pimpl_->filename.toFilesystemEncoding())); + BOOST_ASSERT(pimpl_->filename.exists()); // if method == timestamp, check timestamp before checksum return (method == checksum_method - || pimpl_->timestamp_ != fs::last_write_time(pimpl_->filename.toFilesystemEncoding())) + || pimpl_->timestamp_ != pimpl_->filename.lastModified()) && pimpl_->checksum_ != sum(pimpl_->filename); } @@ -2136,7 +2135,7 @@ bool Buffer::writeAs(string const & newname) } else fname = makeAbsPath(newname, onlyPath(oldname)).absFilename(); - if (fs::exists(FileName(fname).toFilesystemEncoding())) { + if (FileName(fname).exists()) { docstring const file = makeDisplayPath(fname, 30); docstring text = bformat(_("The document %1$s already " "exists.\n\nDo you want to " diff --git a/src/ConverterCache.cpp b/src/ConverterCache.cpp index 72425ed8b3..611bf63e33 100644 --- a/src/ConverterCache.cpp +++ b/src/ConverterCache.cpp @@ -135,7 +135,7 @@ void ConverterCache::Impl::readIndex() CacheItem item(orig_from_name, to_format, timestamp, checksum); // Don't cache files that do not exist anymore - if (!fs::exists(orig_from_name.toFilesystemEncoding())) { + if (!orig_from_name.exists()) { LYXERR(Debug::FILES) << "Not caching file `" << orig_from << "' (does not exist anymore)." << std::endl; @@ -146,7 +146,7 @@ void ConverterCache::Impl::readIndex() // Don't add items that are not in the cache anymore // This can happen if two instances of LyX are running // at the same time and update the index file independantly. - if (!fs::exists(item.cache_name.toFilesystemEncoding())) { + if (!item.cache_name.exists()) { LYXERR(Debug::FILES) << "Not caching file `" << orig_from << "' (cached copy does not exist anymore)." @@ -155,8 +155,8 @@ void ConverterCache::Impl::readIndex() } // Delete the cached file if it is too old - if (difftime(now, fs::last_write_time(item.cache_name.toFilesystemEncoding())) > - lyxrc.converter_cache_maxage) { + if (difftime(now, item.cache_name.lastModified()) + > lyxrc.converter_cache_maxage) { LYXERR(Debug::FILES) << "Not caching file `" << orig_from << "' (too old)." << std::endl; support::unlink(item.cache_name); @@ -228,7 +228,7 @@ void ConverterCache::init() // We do this here and not in the constructor because package() gets // initialized after all static variables. cache_dir = FileName(addName(support::package().user_support().absFilename(), "cache")); - if (!fs::exists(cache_dir.toFilesystemEncoding())) + if (!cache_dir.exists()) if (support::mkdir(cache_dir, 0700) != 0) { lyxerr << "Could not create cache directory `" << cache_dir << "'." << std::endl; @@ -273,7 +273,7 @@ void ConverterCache::add(FileName const & orig_from, string const & to_format, // Is the file in the cache already? CacheItem * item = pimpl_->find(orig_from, to_format); - time_t const timestamp = fs::last_write_time(orig_from.toFilesystemEncoding()); + time_t const timestamp = orig_from.lastModified(); Mover const & mover = getMover(to_format); if (item) { LYXERR(Debug::FILES) << "ConverterCache::add(" << orig_from << "):\n" diff --git a/src/Exporter.cpp b/src/Exporter.cpp index 5826cb52fc..2dc94daeb9 100644 --- a/src/Exporter.cpp +++ b/src/Exporter.cpp @@ -78,7 +78,7 @@ vector const Backends(Buffer const & buffer) /// ask the user what to do if a file already exists int checkOverwrite(FileName const & filename) { - if (fs::exists(filename.toFilesystemEncoding())) { + if (filename.exists()) { docstring text = bformat(_("The file %1$s already exists.\n\n" "Do you want to overwrite that file?"), makeDisplayPath(filename.absFilename())); @@ -243,7 +243,7 @@ bool Exporter::Export(Buffer * buffer, string const & format, } if (status == CANCEL) { buffer->message(_("Document export cancelled.")); - } else if (fs::exists(tmp_result_file.toFilesystemEncoding())) { + } else if (tmp_result_file.exists()) { // Finally copy the main file status = copyFile(format, tmp_result_file, FileName(result_file), result_file, diff --git a/src/Format.cpp b/src/Format.cpp index 8bd34ad489..28c588c9ac 100644 --- a/src/Format.cpp +++ b/src/Format.cpp @@ -26,8 +26,6 @@ #include "support/os.h" #include "support/Systemcall.h" -#include - using std::find_if; using std::string; using std::distance; @@ -49,7 +47,6 @@ using support::Systemcall; using support::token; namespace Alert = frontend::Alert; -namespace fs = boost::filesystem; namespace os = support::os; namespace { @@ -266,7 +263,7 @@ void Formats::setViewer(string const & name, string const & command) bool Formats::view(Buffer const & buffer, FileName const & filename, string const & format_name) const { - if (filename.empty() || !fs::exists(filename.toFilesystemEncoding())) { + if (filename.empty() || !filename.exists()) { Alert::error(_("Cannot view file"), bformat(_("File does not exist: %1$s"), from_utf8(filename.absFilename()))); @@ -336,7 +333,7 @@ bool Formats::view(Buffer const & buffer, FileName const & filename, bool Formats::edit(Buffer const & buffer, FileName const & filename, string const & format_name) const { - if (filename.empty() || !fs::exists(filename.toFilesystemEncoding())) { + if (filename.empty() || !filename.exists()) { Alert::error(_("Cannot edit file"), bformat(_("File does not exist: %1$s"), from_utf8(filename.absFilename()))); diff --git a/src/LaTeX.cpp b/src/LaTeX.cpp index d326630c6d..63f8083977 100644 --- a/src/LaTeX.cpp +++ b/src/LaTeX.cpp @@ -213,7 +213,7 @@ int LaTeX::run(TeXErrors & terr) // remake the dependency file. // - bool had_depfile = fs::exists(depfile.toFilesystemEncoding()); + bool had_depfile = depfile.exists(); bool run_bibtex = false; FileName const aux_file(changeExtension(file.absFilename(), "aux")); @@ -230,7 +230,7 @@ int LaTeX::run(TeXErrors & terr) // have aborted on error last time... in which cas we need // to re-run latex and collect the error messages // (even if they are the same). - if (!fs::exists(output_file.toFilesystemEncoding())) { + if (!output_file.exists()) { LYXERR(Debug::DEPEND) << "re-running LaTeX because output file doesn't exist." << endl; @@ -291,8 +291,7 @@ int LaTeX::run(TeXErrors & terr) // memoir (at least) writes an empty *idx file in the first place. // A second latex run is needed. FileName const idxfile(changeExtension(file.absFilename(), ".idx")); - rerun = fs::exists(idxfile.toFilesystemEncoding()) && - fs::is_empty(idxfile.toFilesystemEncoding()); + rerun = idxfile.exists() && fs::is_empty(idxfile.toFilesystemEncoding()); // run makeindex if (head.haschanged(idxfile)) { @@ -480,7 +479,7 @@ LaTeX::scanAuxFiles(FileName const & file) FileName const file2(basename + '.' + convert(i) + ".aux"); - if (!fs::exists(file2.toFilesystemEncoding())) + if (!file2.exists()) break; result.push_back(scanAuxFile(file2)); } @@ -770,30 +769,9 @@ int LaTeX::scanLogFile(TeXErrors & terr) namespace { -/** - * Wrapper around fs::exists that can handle invalid file names. - * In theory we could test with fs::native whether a filename is valid - * before calling fs::exists, but in practice it is unusable: On windows it - * does not allow spaces, and on unix it does not allow absolute file names. - * This function has the disadvantage that it catches also other errors than - * invalid names, but for dependency checking we can live with that. - */ -bool exists(FileName const & possible_name) { - try { - return fs::exists(possible_name.toFilesystemEncoding()); - } - catch (fs::filesystem_error const & fe) { - LYXERR(Debug::DEPEND) << "Got error `" << fe.what() - << "' while checking whether file `" << possible_name - << "' exists." << endl; - return false; - } -} - - bool insertIfExists(FileName const & absname, DepTable & head) { - if (exists(absname) && + if (absname.exists() && !fs::is_directory(absname.toFilesystemEncoding())) { head.insert(absname, true); return true; @@ -851,7 +829,7 @@ bool handleFoundFile(string const & ff, DepTable & head) // check for spaces while (contains(foundfile, ' ')) { - if (exists(absname)) + if (absname.exists()) // everything o.k. break; else { @@ -859,7 +837,7 @@ bool handleFoundFile(string const & ff, DepTable & head) // marks; those have to be removed string unquoted = subst(foundfile, "\"", ""); absname = makeAbsPath(unquoted); - if (exists(absname)) + if (absname.exists()) break; // strip off part after last space and try again string strippedfile; @@ -873,38 +851,28 @@ bool handleFoundFile(string const & ff, DepTable & head) // (2) foundfile is in the tmpdir // insert it into head - if (exists(absname) && + if (absname.exists() && !fs::is_directory(absname.toFilesystemEncoding())) { // FIXME: This regex contained glo, but glo is used by the old // version of nomencl.sty. Do we need to put it back? - static regex unwanted("^.*\\.(aux|log|dvi|bbl|ind)$"); + static regex const unwanted("^.*\\.(aux|log|dvi|bbl|ind)$"); if (regex_match(onlyfile, unwanted)) { - LYXERR(Debug::DEPEND) - << "We don't want " - << onlyfile - << " in the dep file" - << endl; + LYXERR(Debug::DEPEND) << "We don't want " << onlyfile + << " in the dep file" << endl; } else if (suffixIs(onlyfile, ".tex")) { // This is a tex file generated by LyX // and latex is not likely to change this // during its runs. - LYXERR(Debug::DEPEND) - << "Tmpdir TeX file: " - << onlyfile - << endl; + LYXERR(Debug::DEPEND) << "Tmpdir TeX file: " << onlyfile << endl; head.insert(absname, true); } else { - LYXERR(Debug::DEPEND) - << "In tmpdir file:" - << onlyfile - << endl; + LYXERR(Debug::DEPEND) << "In tmpdir file:" << onlyfile << endl; head.insert(absname); } return true; } else { LYXERR(Debug::DEPEND) - << "Not a file or we are unable to find it." - << endl; + << "Not a file or we are unable to find it." << endl; return false; } } @@ -932,28 +900,28 @@ void LaTeX::deplog(DepTable & head) string const logfile = onlyFilename(changeExtension(file.absFilename(), ".log")); - static regex reg1("File: (.+).*"); - static regex reg2("No file (.+)(.).*"); - static regex reg3("\\\\openout[0-9]+.*=.*`(.+)(..).*"); + static regex const reg1("File: (.+).*"); + static regex const reg2("No file (.+)(.).*"); + static regex const reg3("\\\\openout[0-9]+.*=.*`(.+)(..).*"); // If an index should be created, MikTex does not write a line like // \openout# = 'sample.idx'. // but instead only a line like this into the log: // Writing index file sample.idx - static regex reg4("Writing index file (.+).*"); + static regex const reg4("Writing index file (.+).*"); // files also can be enclosed in <...> - static regex reg5("<([^>]+)(.).*"); - static regex regoldnomencl("Writing glossary file (.+).*"); - static regex regnomencl("Writing nomenclature file (.+).*"); + static regex const reg5("<([^>]+)(.).*"); + static regex const regoldnomencl("Writing glossary file (.+).*"); + static regex const regnomencl("Writing nomenclature file (.+).*"); // If a toc should be created, MikTex does not write a line like // \openout# = `sample.toc'. // but only a line like this into the log: // \tf@toc=\write# // This line is also written by tetex. // This line is not present if no toc should be created. - static regex miktexTocReg("\\\\tf@toc=\\\\write.*"); - static regex reg6(".*\\([^)]+.*"); + static regex const miktexTocReg("\\\\tf@toc=\\\\write.*"); + static regex const reg6(".*\\([^)]+.*"); - FileName const fn(makeAbsPath(logfile)); + FileName const fn = makeAbsPath(logfile); ifstream ifs(fn.toFilesystemEncoding().c_str()); string lastline; while (ifs) { @@ -980,8 +948,8 @@ void LaTeX::deplog(DepTable & head) // Here we exclude some cases where we are sure // that there is no continued filename if (!lastline.empty()) { - static regex package_info("Package \\w+ Info: .*"); - static regex package_warning("Package \\w+ Warning: .*"); + static regex const package_info("Package \\w+ Info: .*"); + static regex const package_warning("Package \\w+ Warning: .*"); if (prefixIs(token, "File:") || prefixIs(token, "(Font)") || prefixIs(token, "Package:") || prefixIs(token, "Language:") diff --git a/src/LyX.cpp b/src/LyX.cpp index 81acf9f6cf..69fff59667 100644 --- a/src/LyX.cpp +++ b/src/LyX.cpp @@ -985,7 +985,7 @@ bool LyX::init() prependEnvPath("PATH", lyxrc.path_prefix); FileName const document_path(lyxrc.document_path); - if (fs::exists(document_path.toFilesystemEncoding()) && + if (document_path.exists() && fs::is_directory(document_path.toFilesystemEncoding())) package().document_dir() = document_path; diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index b4d2bc3a3f..cb4c476062 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -1152,7 +1152,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) FileName const filename(makeAbsPath(target_name, lyx_view_->buffer()->filePath())); FileName const dvifile(makeAbsPath(dviname, path)); - if (fs::exists(filename.toFilesystemEncoding())) { + if (filename.exists()) { docstring text = bformat( _("The file %1$s already exists.\n\n" "Do you want to overwrite that file?"), @@ -2155,7 +2155,7 @@ void LyXFunc::open(string const & fname) filename = fullname.absFilename(); // if the file doesn't exist, let the user create one - if (!fs::exists(fullname.toFilesystemEncoding())) { + if (!fullname.exists()) { // the user specifically chose this name. Believe him. Buffer * const b = newFile(filename, string(), true); if (b) @@ -2247,7 +2247,7 @@ void LyXFunc::doImport(string const & argument) // if the file exists already, and we didn't do // -i lyx thefile.lyx, warn - if (fs::exists(lyxfile.toFilesystemEncoding()) && fullname != lyxfile) { + if (lyxfile.exists() && fullname != lyxfile) { docstring const file = makeDisplayPath(lyxfile.absFilename(), 30); docstring text = bformat(_("The document %1$s already exists.\n\n" diff --git a/src/Session.cpp b/src/Session.cpp index 8abc70051e..60f44cde2b 100644 --- a/src/Session.cpp +++ b/src/Session.cpp @@ -78,7 +78,7 @@ void LastFilesSection::read(istream & is) // read lastfiles FileName const file(tmp); - if (fs::exists(file.toFilesystemEncoding()) && + if (file.exists() && !fs::is_directory(file.toFilesystemEncoding()) && lastfiles.size() < num_lastfiles) lastfiles.push_back(file); @@ -133,7 +133,7 @@ void LastOpenedSection::read(istream & is) continue; FileName const file(tmp); - if (fs::exists(file.toFilesystemEncoding()) && + if (file.exists() && !fs::is_directory(file.toFilesystemEncoding())) lastopened.push_back(file); else @@ -188,7 +188,7 @@ void LastFilePosSection::read(istream & is) if (!absolutePath(fname)) continue; FileName const file(fname); - if (fs::exists(file.toFilesystemEncoding()) && + if (file.exists() && !fs::is_directory(file.toFilesystemEncoding()) && lastfilepos.size() < num_lastfilepos) lastfilepos[file] = boost::tie(pit, pos); @@ -269,7 +269,7 @@ void BookmarksSection::read(istream & is) continue; FileName const file(fname); // only load valid bookmarks - if (fs::exists(file.toFilesystemEncoding()) && + if (file.exists() && !fs::is_directory(file.toFilesystemEncoding()) && idx <= max_bookmarks) bookmarks[idx] = Bookmark(file, pit, pos, 0, 0); diff --git a/src/TextClass.cpp b/src/TextClass.cpp index eb71d7380b..2a6c5fabfe 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -30,12 +30,8 @@ #include "support/filetools.h" #include "support/os.h" -#include - #include -namespace fs = boost::filesystem; - namespace lyx { using support::FileName; @@ -1014,7 +1010,7 @@ bool TextClass::load(string const & path) const FileName layout_file; if (!path.empty()) layout_file = FileName(addName(path, name_ + ".layout")); - if (layout_file.empty() || !fs::exists(layout_file.toFilesystemEncoding())) + if (layout_file.empty() || !layout_file.exists()) layout_file = libFileSearch("layouts", name_, "layout"); loaded_ = const_cast(this)->read(layout_file) == 0; diff --git a/src/TextClassList.cpp b/src/TextClassList.cpp index 708b1ac534..430e9e3ade 100644 --- a/src/TextClassList.cpp +++ b/src/TextClassList.cpp @@ -20,12 +20,11 @@ #include #include -#include + #include namespace lyx { -namespace fs = boost::filesystem; using support::FileName; using support::addName; @@ -194,7 +193,7 @@ TextClassList::addTextClass(std::string const & textclass, std::string const & p // only check for textclass.layout file, .cls can be anywhere in $TEXINPUTS // NOTE: latex class name is defined in textclass.layout, which can be different from textclass FileName const layout_file(addName(path, textclass + ".layout")); - if (fs::exists(layout_file.toFilesystemEncoding())) { + if (layout_file.exists()) { LYXERR(Debug::TCLASS) << "Adding class " << textclass << " from directory " << path << endl; // Read .layout file and get description, real latex classname etc // diff --git a/src/buffer_funcs.cpp b/src/buffer_funcs.cpp index 5ce299e12f..e5ef760014 100644 --- a/src/buffer_funcs.cpp +++ b/src/buffer_funcs.cpp @@ -82,7 +82,7 @@ bool readFile(Buffer * const b, FileName const & s) BOOST_ASSERT(b); // File information about normal file - if (!fs::exists(s.toFilesystemEncoding())) { + if (!s.exists()) { docstring const file = makeDisplayPath(s.absFilename(), 50); docstring text = bformat(_("The specified document\n%1$s" "\ncould not be read."), file); @@ -93,10 +93,7 @@ bool readFile(Buffer * const b, FileName const & s) // Check if emergency save file exists and is newer. FileName const e(s.absFilename() + ".emergency"); - if (fs::exists(e.toFilesystemEncoding()) && - fs::exists(s.toFilesystemEncoding()) && - fs::last_write_time(e.toFilesystemEncoding()) > fs::last_write_time(s.toFilesystemEncoding())) - { + if (e.exists() && s.exists() && e.lastModified() > s.lastModified()) { docstring const file = makeDisplayPath(s.absFilename(), 20); docstring const text = bformat(_("An emergency save of the document " @@ -120,10 +117,7 @@ bool readFile(Buffer * const b, FileName const & s) // Now check if autosave file is newer. FileName const a(onlyPath(s.absFilename()) + '#' + onlyFilename(s.absFilename()) + '#'); - if (fs::exists(a.toFilesystemEncoding()) && - fs::exists(s.toFilesystemEncoding()) && - fs::last_write_time(a.toFilesystemEncoding()) > fs::last_write_time(s.toFilesystemEncoding())) - { + if (a.exists() && s.exists() && a.lastModified() > s.lastModified()) { docstring const file = makeDisplayPath(s.absFilename(), 20); docstring const text = bformat(_("The backup of the document " diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 6e688883af..910292be96 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -48,7 +48,6 @@ #include "support/convert.h" #include -#include namespace lyx { @@ -88,7 +87,6 @@ using std::ostringstream; using std::vector; namespace Alert = frontend::Alert; -namespace fs = boost::filesystem; namespace { @@ -386,6 +384,7 @@ Buffer * getChildBuffer(Buffer const & buffer, InsetCommandParams const & params } // namespace anon + /// return true if the file is or got loaded. Buffer * loadIfNeeded(Buffer const & parent, InsetCommandParams const & params) { @@ -402,7 +401,7 @@ Buffer * loadIfNeeded(Buffer const & parent, InsetCommandParams const & params) Buffer * child = theBufferList().getBuffer(included_file.absFilename()); if (!child) { // the readonly flag can/will be wrong, not anymore I think. - if (!fs::exists(included_file.toFilesystemEncoding())) + if (!included_file.exists()) return 0; child = theBufferList().newBuffer(included_file.absFilename()); diff --git a/src/support/FileMonitor.cpp b/src/support/FileMonitor.cpp index 595f3e0da0..6ec87a738e 100644 --- a/src/support/FileMonitor.cpp +++ b/src/support/FileMonitor.cpp @@ -16,14 +16,11 @@ #include "support/Timeout.h" #include -#include #include using std::string; -namespace fs = boost::filesystem; - namespace lyx { namespace support { @@ -90,10 +87,10 @@ void FileMonitor::start() const if (monitoring()) return; - if (!fs::exists(pimpl_->filename_.toFilesystemEncoding())) + if (!pimpl_->filename_.exists()) return; - pimpl_->timestamp_ = fs::last_write_time(pimpl_->filename_.toFilesystemEncoding()); + pimpl_->timestamp_ = pimpl_->filename_.lastModified(); pimpl_->checksum_ = sum(pimpl_->filename_); if (pimpl_->timestamp_ && pimpl_->checksum_) { @@ -155,13 +152,13 @@ void FileMonitor::Impl::monitorFile() { bool changed = false; - if (!fs::exists(filename_.toFilesystemEncoding())) { + if (!filename_.exists()) { changed = timestamp_ || checksum_; timestamp_ = 0; checksum_ = 0; } else { - time_t const new_timestamp = fs::last_write_time(filename_.toFilesystemEncoding()); + time_t const new_timestamp = filename_.lastModified(); if (new_timestamp != timestamp_) { timestamp_ = new_timestamp; diff --git a/src/support/Package.cpp b/src/support/Package.cpp index 3535f7a625..0244a2f2eb 100644 --- a/src/support/Package.cpp +++ b/src/support/Package.cpp @@ -356,14 +356,12 @@ FileName const get_locale_dir(FileName const & system_support_dir) FileName path(normalizePath(addPath(system_support_dir.absFilename(), relative_locale_dir()))); - if (fs::exists(path.toFilesystemEncoding()) && - fs::is_directory(path.toFilesystemEncoding())) + if (path.exists() && fs::is_directory(path.toFilesystemEncoding())) return path; // 3. Fall back to the hard-coded LOCALEDIR. path = hardcoded_localedir(); - if (fs::exists(path.toFilesystemEncoding()) && - fs::is_directory(path.toFilesystemEncoding())) + if (path.exists() && fs::is_directory(path.toFilesystemEncoding())) return path; return FileName(); @@ -415,7 +413,7 @@ FileName const get_binary_path(string const & exe) // Two possibilities present themselves. // 1. The binary is relative to the CWD. FileName const abs_exe_path = makeAbsPath(exe_path); - if (fs::exists(abs_exe_path.toFilesystemEncoding())) + if (abs_exe_path.exists()) return abs_exe_path; // 2. exe must be the name of the binary only and it @@ -432,7 +430,7 @@ FileName const get_binary_path(string const & exe) string const exe_dir = makeAbsPath(*it).absFilename(); FileName const exe_path(addName(exe_dir, exe_name)); - if (fs::exists(exe_path.toFilesystemEncoding())) + if (exe_path.exists()) return exe_path; } @@ -697,8 +695,8 @@ bool check_env_var_dir(FileName const & dir, bool check_env_var_dir(FileName const & dir, string const & env_var) { - string const encoded(dir.toFilesystemEncoding()); - bool const success = (fs::exists(encoded) && fs::is_directory(encoded)); + string const encoded = dir.toFilesystemEncoding(); + bool const success = (dir.exists() && fs::is_directory(encoded)); if (!success) { // Put this string on a single line so that the gettext diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index eceb061bae..1993098ff6 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -360,7 +360,7 @@ string find_file(string const & name, string const & path, // expects utf8) for (char const * const * what = extensions; *what; ++what) { string const trial = addExtension(name, *what); - if (fs::exists(makeAbsPath(trial, path).toFilesystemEncoding())) + if (makeAbsPath(trial, path).exists()) return trial; } return string(); @@ -1539,7 +1539,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, // therefore path is only used for testing // FIXME UNICODE encoding of name and path may be // wrong (makeAbsPath expects utf8) - if (!fs::exists(makeAbsPath(name, path).toFilesystemEncoding())) { + if (!makeAbsPath(name, path).exists()) { // The file extension is probably missing. // Now try to find it out. string const dvips_name = @@ -1571,7 +1571,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, // FIXME UNICODE encoding of name and path may be // wrong (makeAbsPath expects utf8) - if (fs::exists(makeAbsPath(name, path).toFilesystemEncoding())) + if (makeAbsPath(name, path).exists()) fix_relative_filename(name); else cerr << "Warning: Could not find graphics file '" @@ -2203,7 +2203,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, // FIXME UNICODE encoding of filename and path may be // wrong (makeAbsPath expects utf8) if ((t.cs() == "include" || t.cs() == "input") && - !fs::exists(makeAbsPath(filename, path).toFilesystemEncoding())) { + !makeAbsPath(filename, path).exists()) { // The file extension is probably missing. // Now try to find it out. string const tex_name = @@ -2214,7 +2214,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, } // FIXME UNICODE encoding of filename and path may be // wrong (makeAbsPath expects utf8) - if (fs::exists(makeAbsPath(filename, path).toFilesystemEncoding())) { + if (makeAbsPath(filename, path).exists()) { string const abstexname = makeAbsPath(filename, path).absFilename(); string const abslyxname =