mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
s/isFileReadable/isReadableFile;
introduce isReadableDirectory replace isReadable by either isReadableFile or isReadableDirectory remove isReadable git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21769 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
e7317582fb
commit
d95451ae5c
@ -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())
|
||||
|
@ -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 =
|
||||
|
@ -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);
|
||||
|
@ -1945,7 +1945,7 @@ void LyXFunc::menuNew(string const & name, bool fromTemplate)
|
||||
filename = addName(lyxrc.document_path,
|
||||
"newfile" + convert<string>(++newfile_number) + ".lyx");
|
||||
while (theBufferList().exists(filename) ||
|
||||
FileName(filename).isReadable()) {
|
||||
FileName(filename).isReadableFile()) {
|
||||
++newfile_number;
|
||||
filename = addName(lyxrc.document_path,
|
||||
"newfile" + convert<string>(newfile_number) +
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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");
|
||||
|
@ -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(\"");
|
||||
|
@ -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
|
||||
|
@ -817,7 +817,7 @@ namespace {
|
||||
bool preview_wanted(InsetExternalParams const & params)
|
||||
{
|
||||
return params.display == external::PreviewDisplay &&
|
||||
params.filename.isFileReadable();
|
||||
params.filename.isReadableFile();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ string const trim(string const & a, char const * p)
|
||||
|
||||
|
||||
void split(string const & s, vector<string> & 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;
|
||||
|
Loading…
Reference in New Issue
Block a user