diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 4b64d52b2a..f1ed3ce599 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -2504,7 +2504,7 @@ bool Buffer::readFileHelper(FileName const & s) bool Buffer::loadLyXFile(FileName const & s) { - if (s.isReadable()) { + if (s.isReadableFile()) { if (readFileHelper(s)) { lyxvc().file_found_hook(s); if (!s.isWritable()) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index d114781742..84c877f55a 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -2025,7 +2025,7 @@ docstring BufferView::contentsOfPlaintextFile(string const & f, fname = makeAbsPath(to_utf8(result.second)); } - if (!fname.isReadable()) { + if (!fname.isReadableFile()) { docstring const error = from_ascii(strerror(errno)); docstring const file = makeDisplayPath(fname.absFilename(), 50); docstring const text = diff --git a/src/Converter.cpp b/src/Converter.cpp index a943857341..1fe895e314 100644 --- a/src/Converter.cpp +++ b/src/Converter.cpp @@ -320,7 +320,7 @@ bool Converters::convert(Buffer const * buffer, "I use convertDefault.py:\n\t" << command); Systemcall one; one.startscript(Systemcall::Wait, command); - if (to_file.isFileReadable()) { + if (to_file.isReadableFile()) { if (conversionflags & try_cache) ConverterCache::get().add(orig_from, to_format, to_file); diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 99d30be41a..627be90f70 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -1945,7 +1945,7 @@ void LyXFunc::menuNew(string const & name, bool fromTemplate) filename = addName(lyxrc.document_path, "newfile" + convert(++newfile_number) + ".lyx"); while (theBufferList().exists(filename) || - FileName(filename).isReadable()) { + FileName(filename).isReadableFile()) { ++newfile_number; filename = addName(lyxrc.document_path, "newfile" + convert(newfile_number) + diff --git a/src/LyXVC.cpp b/src/LyXVC.cpp index 8b9d7c608e..5b31fae692 100644 --- a/src/LyXVC.cpp +++ b/src/LyXVC.cpp @@ -57,13 +57,13 @@ bool LyXVC::file_found_hook(FileName const & fn) { FileName found_file; // Check if file is under RCS - if (!(found_file = RCS::find_file(fn)).empty()) { + if (!(found_file = RCS::findFile(fn)).empty()) { vcs.reset(new RCS(found_file)); vcs->owner(owner_); return true; } // Check if file is under CVS - if (!(found_file = CVS::find_file(fn)).empty()) { + if (!(found_file = CVS::findFile(fn)).empty()) { vcs.reset(new CVS(found_file, fn)); vcs->owner(owner_); return true; @@ -76,9 +76,9 @@ bool LyXVC::file_found_hook(FileName const & fn) bool LyXVC::file_not_found_hook(FileName const & fn) { // Check if file is under RCS - if (!RCS::find_file(fn).empty()) + if (!RCS::findFile(fn).empty()) return true; - if (!CVS::find_file(fn).empty()) + if (!CVS::findFile(fn).empty()) return true; return false; } @@ -95,7 +95,7 @@ void LyXVC::registrer() FileName const filename = owner_->fileName(); // there must be a file to save - if (!filename.isFileReadable()) { + if (!filename.isReadableFile()) { Alert::error(_("Document not saved"), _("You must save the document " "before it can be registered.")); @@ -106,7 +106,7 @@ void LyXVC::registrer() if (!vcs) { FileName const cvs_entries(makeAbsPath("CVS/Entries")); - if (cvs_entries.isFileReadable()) { + if (cvs_entries.isReadableFile()) { LYXERR(Debug::LYXVC, "LyXVC: registering " << to_utf8(filename.displayName()) << " with CVS"); vcs.reset(new CVS(cvs_entries, filename)); diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 58dca7a152..57dd90ec35 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -176,7 +176,7 @@ enum TextClassTags { // Reads a textclass structure from file. bool TextClass::read(FileName const & filename, ReadType rt) { - if (!filename.isFileReadable()) { + if (!filename.isReadableFile()) { lyxerr << "Cannot read layout file `" << filename << "'." << endl; return true; diff --git a/src/VCBackend.cpp b/src/VCBackend.cpp index 01ad8378e2..dbcb7b502f 100644 --- a/src/VCBackend.cpp +++ b/src/VCBackend.cpp @@ -75,12 +75,12 @@ RCS::RCS(FileName const & m) } -FileName const RCS::find_file(FileName const & file) +FileName const RCS::findFile(FileName const & file) { // Check if *,v exists. FileName tmp(file.absFilename() + ",v"); LYXERR(Debug::LYXVC, "Checking if file is under rcs: " << tmp); - if (tmp.isReadable()) { + if (tmp.isReadableFile()) { LYXERR(Debug::LYXVC, "Yes " << file << " is under rcs."); return tmp; } @@ -88,7 +88,7 @@ FileName const RCS::find_file(FileName const & file) // Check if RCS/*,v exists. tmp = FileName(addName(addPath(onlyPath(file.absFilename()), "RCS"), file.absFilename()) + ",v"); LYXERR(Debug::LYXVC, "Checking if file is under rcs: " << tmp); - if (tmp.isReadable()) { + if (tmp.isReadableFile()) { LYXERR(Debug::LYXVC, "Yes " << file << " it is under rcs."); return tmp; } @@ -232,7 +232,7 @@ CVS::CVS(FileName const & m, FileName const & f) } -FileName const CVS::find_file(FileName const & file) +FileName const CVS::findFile(FileName const & file) { // First we look for the CVS/Entries in the same dir // where we have file. @@ -240,7 +240,7 @@ FileName const CVS::find_file(FileName const & file) string const tmpf = '/' + onlyFilename(file.absFilename()) + '/'; LYXERR(Debug::LYXVC, "LyXVC: checking in `" << dir << "' for `" << tmpf << '\''); - if (dir.isReadable()) { + if (dir.isReadableDirectory()) { // Ok we are at least in a CVS dir. Parse the CVS/Entries // and see if we can find this file. We do a fast and // dirty parse here. diff --git a/src/VCBackend.h b/src/VCBackend.h index 598f1328eb..551874f3d1 100644 --- a/src/VCBackend.h +++ b/src/VCBackend.h @@ -101,7 +101,7 @@ public: RCS(support::FileName const & m); /// return the revision file for the given file, if found - static support::FileName const find_file(support::FileName const & file); + static support::FileName const findFile(support::FileName const & file); static void retrieve(support::FileName const & file); @@ -134,7 +134,7 @@ public: CVS(support::FileName const & m, support::FileName const & f); /// return the revision file for the given file, if found - static support::FileName const find_file(support::FileName const & file); + static support::FileName const findFile(support::FileName const & file); virtual void registrer(std::string const & msg); diff --git a/src/buffer_funcs.cpp b/src/buffer_funcs.cpp index 544856a8e9..749e2cbe8a 100644 --- a/src/buffer_funcs.cpp +++ b/src/buffer_funcs.cpp @@ -90,7 +90,7 @@ Buffer * checkAndLoadLyXFile(FileName const & filename) return 0; } - if (filename.isFileReadable()) { + if (filename.isReadableFile()) { Buffer * b = theBufferList().newBuffer(filename.absFilename()); if (!b->loadLyXFile(filename)) { theBufferList().release(b); diff --git a/src/frontends/qt4/GuiGraphics.cpp b/src/frontends/qt4/GuiGraphics.cpp index a263d8f07c..f9a3484dd2 100644 --- a/src/frontends/qt4/GuiGraphics.cpp +++ b/src/frontends/qt4/GuiGraphics.cpp @@ -807,7 +807,7 @@ string const GuiGraphics::readBB(string const & file) bool GuiGraphics::isFilenameValid(string const & fname) const { // It may be that the filename is relative. - return makeAbsPath(fname, bufferFilepath()).isFileReadable(); + return makeAbsPath(fname, bufferFilepath()).isReadableFile(); } diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 0b02e46ee6..9a5674d5b0 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -962,7 +962,7 @@ FuncStatus GuiView::getStatus(FuncRequest const & cmd) } } else if (name == "latexlog") - enable = FileName(buf->logName()).isFileReadable(); + enable = FileName(buf->logName()).isReadableFile(); else if (name == "spellchecker") #if defined (USE_ASPELL) || defined (USE_ISPELL) || defined (USE_PSPELL) enable = !buf->isReadonly(); diff --git a/src/graphics/GraphicsCacheItem.cpp b/src/graphics/GraphicsCacheItem.cpp index 83bf09d289..4f776033d7 100644 --- a/src/graphics/GraphicsCacheItem.cpp +++ b/src/graphics/GraphicsCacheItem.cpp @@ -269,7 +269,7 @@ void CacheItem::Impl::imageConverted(bool success) converter_.reset(); cc_.disconnect(); - success = !file_to_load_.empty() && file_to_load_.isFileReadable(); + success = !file_to_load_.empty() && file_to_load_.isReadableFile(); if (!success) { LYXERR(Debug::GRAPHICS, "Unable to find converted file!"); @@ -370,7 +370,7 @@ void CacheItem::Impl::convertToDisplayFormat() setStatus(Converting); // First, check that the file exists! - if (!filename_.isFileReadable()) { + if (!filename_.isReadableFile()) { if (status_ != ErrorNoFile) { setStatus(ErrorNoFile); LYXERR(Debug::GRAPHICS, "\tThe file is not readable"); diff --git a/src/insets/ExternalSupport.cpp b/src/insets/ExternalSupport.cpp index 41a8f8e087..6694537220 100644 --- a/src/insets/ExternalSupport.cpp +++ b/src/insets/ExternalSupport.cpp @@ -187,7 +187,7 @@ string const doSubstitution(InsetExternalParams const & params, FileName const absfile( support::makeAbsPath(file, masterBuffer->temppath())); - if (absfile.isFileReadable()) + if (absfile.isReadableFile()) contents = absfile.fileContents(); size_t const pos = result.find("$$Contents(\""); diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index 31145541d7..b8028dc8f3 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -140,7 +140,7 @@ string normalizeName(Buffer const & buffer, OutputParams const & runparams, string const & name, string const & ext) { string const fname = makeAbsPath(name, buffer.filePath()).absFilename(); - if (absolutePath(name) || !FileName(fname + ext).isFileReadable()) + if (absolutePath(name) || !FileName(fname + ext).isReadableFile()) return name; if (!runparams.nice) return fname; @@ -195,7 +195,7 @@ int InsetBibtex::latex(Buffer const & buffer, odocstream & os, string database = normalizeName(buffer, runparams, utf8input, ".bib"); FileName const try_in_file(makeAbsPath(database + ".bib", buffer.filePath())); - bool const not_from_texmf = try_in_file.isFileReadable(); + bool const not_from_texmf = try_in_file.isReadableFile(); if (!runparams.inComment && !runparams.dryrun && !runparams.nice && not_from_texmf) { @@ -253,7 +253,7 @@ int InsetBibtex::latex(Buffer const & buffer, odocstream & os, if (!style.empty()) { string base = normalizeName(buffer, runparams, style, ".bst"); FileName const try_in_file(makeAbsPath(base + ".bst", buffer.filePath())); - bool const not_from_texmf = try_in_file.isFileReadable(); + bool const not_from_texmf = try_in_file.isReadableFile(); // If this style does not come from texmf and we are not // exporting to .tex copy it to the tmp directory. // This prevents problems with spaces and 8bit charcaters diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index 75aeb66580..92092afeb8 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -817,7 +817,7 @@ namespace { bool preview_wanted(InsetExternalParams const & params) { return params.display == external::PreviewDisplay && - params.filename.isFileReadable(); + params.filename.isReadableFile(); } diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp index 1ad3118583..4ec3ddf352 100644 --- a/src/insets/InsetGraphics.cpp +++ b/src/insets/InsetGraphics.cpp @@ -611,7 +611,7 @@ string const InsetGraphics::prepareFile(Buffer const & buf, // not exist. // We are not going to change the extension or using the name of the // temporary file, the code is already complicated enough. - if (runparams.inComment || !params().filename.isFileReadable()) + if (runparams.inComment || !params().filename.isReadableFile()) return params().filename.outputFilename(masterBuffer->filePath()); // We place all temporary files in the master buffer's temp dir. @@ -783,7 +783,7 @@ int InsetGraphics::latex(Buffer const & buf, odocstream & os, params().filename.relFilename(buf.filePath()); bool const file_exists = !params().filename.empty() - && params().filename.isFileReadable(); + && params().filename.isReadableFile(); string const message = file_exists ? string() : string("bb = 0 0 200 100, draft, type=eps"); // if !message.empty() then there was no existing file diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index bfc286de5d..4006bb1d0b 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -787,7 +787,7 @@ bool preview_wanted(InsetCommandParams const & params, Buffer const & buffer) FileName const included_file = includedFilename(buffer, params); return type(params) == INPUT && params.preview() && - included_file.isFileReadable(); + included_file.isReadableFile(); } diff --git a/src/support/FileName.cpp b/src/support/FileName.cpp index d3320ce8ae..467b43dcce 100644 --- a/src/support/FileName.cpp +++ b/src/support/FileName.cpp @@ -217,10 +217,10 @@ bool FileName::isReadOnly() const } -bool FileName::isReadable() const +bool FileName::isReadableDirectory() const { QFileInfo const fi(toqstr(name_)); - return fi.isReadable(); + return fi.isDir() && fi.isReadable(); } @@ -236,7 +236,7 @@ std::string FileName::onlyPath() const } -bool FileName::isFileReadable() const +bool FileName::isReadableFile() const { QFileInfo const fi(toqstr(name_)); return fi.isFile() && fi.isReadable(); @@ -348,7 +348,7 @@ string FileName::guessFormatFromContents() const // Z \037\235 UNIX compress // paranoia check - if (empty() || !isFileReadable()) + if (empty() || !isReadableFile()) return string(); ifstream ifs(toFilesystemEncoding().c_str()); diff --git a/src/support/FileName.h b/src/support/FileName.h index 80db2ed35a..7b1fb06666 100644 --- a/src/support/FileName.h +++ b/src/support/FileName.h @@ -64,9 +64,9 @@ public: /// return true when it names a directory bool isDirectory() const; /// return true when file/directory is readable - bool isReadable() const; + bool isReadableDirectory() const; /// return true when it is a file and readable - bool isFileReadable() const; + bool isReadableFile() const; /// return true when file/directory is writable bool isWritable() const; /// return true when file/directory is writable (write test file) diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp index 882b758de5..f3a4914d9f 100644 --- a/src/support/filetools.cpp +++ b/src/support/filetools.cpp @@ -231,7 +231,7 @@ FileName const fileSearch(string const & path, string const & name, string const tmpname = replaceEnvironmentPath(name); FileName fullname(makeAbsPath(tmpname, path)); // search first without extension, then with it. - if (fullname.isFileReadable()) + if (fullname.isReadableFile()) return fullname; if (ext.empty()) // We are done. @@ -240,7 +240,7 @@ FileName const fileSearch(string const & path, string const & name, // fullname. if (getExtension(fullname.absFilename()) != ext) fullname = FileName(addExtension(fullname.absFilename(), ext)); - if (fullname.isFileReadable() || mode == allow_unreadable) + if (fullname.isReadableFile() || mode == allow_unreadable) return fullname; return FileName(); } diff --git a/src/tex2lyx/tex2lyx.cpp b/src/tex2lyx/tex2lyx.cpp index 5c987b177b..e29c350023 100644 --- a/src/tex2lyx/tex2lyx.cpp +++ b/src/tex2lyx/tex2lyx.cpp @@ -92,7 +92,7 @@ string const trim(string const & a, char const * p) void split(string const & s, vector & result, char delim) -{ +:{ //cerr << "split 1: '" << s << "'\n"; istringstream is(s); string t; @@ -420,7 +420,7 @@ namespace { * You must ensure that \p parentFilePath is properly set before calling * this function! */ -void tex2lyx(std::istream &is, std::ostream &os) +void tex2lyx(std::istream & is, std::ostream & os) { Parser p(is); //p.dump(); @@ -451,7 +451,7 @@ void tex2lyx(std::istream &is, std::ostream &os) /// convert TeX from \p infilename to LyX and write it to \p os -bool tex2lyx(FileName const & infilename, std::ostream &os) +bool tex2lyx(FileName const & infilename, std::ostream & os) { ifstream is(infilename.toFilesystemEncoding().c_str()); if (!is.good()) { @@ -469,9 +469,9 @@ bool tex2lyx(FileName const & infilename, std::ostream &os) } // anonymous namespace -bool tex2lyx(string const &infilename, FileName const &outfilename) +bool tex2lyx(string const & infilename, FileName const & outfilename) { - if (outfilename.isFileReadable()) { + if (outfilename.isReadableFile()) { if (overwrite_files) { cerr << "Overwriting existing file " << outfilename << endl;