* get rid of support::absolutePath()

* remove FileName.h inclusion from filetools.h


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22188 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-12-17 16:04:46 +00:00
parent 96ee270933
commit 9439b6e6e0
33 changed files with 49 additions and 30 deletions

View File

@ -16,6 +16,7 @@
#include "Lexer.h" #include "Lexer.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/lstrings.h" #include "support/lstrings.h"

View File

@ -343,7 +343,7 @@ string const EmbeddedFiles::getInzipName(string const & abs_filename, string con
// if inzip_name is an absolute path, use filename only to avoid // if inzip_name is an absolute path, use filename only to avoid
// leaking of filesystem information in inzip_name // leaking of filesystem information in inzip_name
// The second case covers cases '../path/file' and '.' // The second case covers cases '../path/file' and '.'
if (absolutePath(inzip_name) || prefixIs(inzip_name, ".")) if (FileName(inzip_name).isAbsolute() || prefixIs(inzip_name, "."))
inzip_name = onlyFilename(abs_filename); inzip_name = onlyFilename(abs_filename);
// if this name has been used... // if this name has been used...
// use _1_name, _2_name etc // use _1_name, _2_name etc

View File

@ -21,6 +21,7 @@
#include "Lexer.h" #include "Lexer.h"
#include "support/docstream.h" #include "support/docstream.h"
#include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
#include <fstream> #include <fstream>

View File

@ -22,8 +22,9 @@
#include "support/debug.h" #include "support/debug.h"
#include "DepTable.h" #include "DepTable.h"
#include "support/filetools.h"
#include "support/convert.h" #include "support/convert.h"
#include "support/FileName.h"
#include "support/filetools.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/Systemcall.h" #include "support/Systemcall.h"
#include "support/os.h" #include "support/os.h"
@ -744,12 +745,12 @@ bool handleFoundFile(string const & ff, DepTable & head)
// (1) foundfile is an // (1) foundfile is an
// absolute path and should // absolute path and should
// be inserted. // be inserted.
if (absolutePath(foundfile)) { FileName absname(foundfile);
if (absname.isAbsolute()) {
LYXERR(Debug::DEPEND, "AbsolutePath file: " << foundfile); LYXERR(Debug::DEPEND, "AbsolutePath file: " << foundfile);
// On initial insert we want to do the update at once // On initial insert we want to do the update at once
// since this file cannot be a file generated by // since this file cannot be a file generated by
// the latex run. // the latex run.
FileName absname(foundfile);
if (!insertIfExists(absname, head)) { if (!insertIfExists(absname, head)) {
// check for spaces // check for spaces
string strippedfile = foundfile; string strippedfile = foundfile;
@ -772,7 +773,7 @@ bool handleFoundFile(string const & ff, DepTable & head)
} }
string onlyfile = onlyFilename(foundfile); string onlyfile = onlyFilename(foundfile);
FileName absname(makeAbsPath(onlyfile)); absname = makeAbsPath(onlyfile);
// check for spaces // check for spaces
while (contains(foundfile, ' ')) { while (contains(foundfile, ' ')) {

View File

@ -29,6 +29,7 @@
#include "TextClass.h" #include "TextClass.h"
#include "support/docstream.h" #include "support/docstream.h"
#include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
using namespace std; using namespace std;

View File

@ -18,6 +18,7 @@
#include "support/debug.h" #include "support/debug.h"
#include "support/convert.h" #include "support/convert.h"
#include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/gzstream.h" #include "support/gzstream.h"
#include "support/lstrings.h" #include "support/lstrings.h"

View File

@ -16,6 +16,7 @@
#include "support/debug.h" #include "support/debug.h"
#include "Lexer.h" #include "Lexer.h"
#include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/lstrings.h" #include "support/lstrings.h"

View File

@ -12,6 +12,7 @@
#include "Mover.h" #include "Mover.h"
#include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/Systemcall.h" #include "support/Systemcall.h"

View File

@ -55,11 +55,11 @@ void LastFilesSection::read(istream & is)
if (c == '[') if (c == '[')
break; break;
getline(is, tmp); getline(is, tmp);
if (tmp == "" || tmp[0] == '#' || tmp[0] == ' ' || !absolutePath(tmp)) FileName const file(tmp);
if (tmp == "" || tmp[0] == '#' || tmp[0] == ' ' || !file.isAbsolute())
continue; continue;
// read lastfiles // read lastfiles
FileName const file(tmp);
if (file.exists() && !file.isDirectory() if (file.exists() && !file.isDirectory()
&& lastfiles.size() < num_lastfiles) && lastfiles.size() < num_lastfiles)
lastfiles.push_back(file); lastfiles.push_back(file);
@ -109,10 +109,10 @@ void LastOpenedSection::read(istream & is)
if (c == '[') if (c == '[')
break; break;
getline(is, tmp); getline(is, tmp);
if (tmp == "" || tmp[0] == '#' || tmp[0] == ' ' || !absolutePath(tmp)) FileName const file(tmp);
if (tmp == "" || tmp[0] == '#' || tmp[0] == ' ' || !file.isAbsolute())
continue; continue;
FileName const file(tmp);
if (file.exists() && !file.isDirectory()) if (file.exists() && !file.isDirectory())
lastopened.push_back(file); lastopened.push_back(file);
else else

View File

@ -29,6 +29,7 @@
#include "frontends/alert.h" #include "frontends/alert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/os.h" #include "support/os.h"

View File

@ -16,6 +16,7 @@
#include "support/debug.h" #include "support/debug.h"
#include "Lexer.h" #include "Lexer.h"
#include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
#include <boost/bind.hpp> #include <boost/bind.hpp>

View File

@ -22,6 +22,7 @@
#include "LyXRC.h" #include "LyXRC.h"
#include "Text.h" #include "Text.h"
#include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/convert.h" #include "support/convert.h"

View File

@ -17,9 +17,9 @@
#include "qt_helpers.h" #include "qt_helpers.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/gettext.h"
#include "support/FileFilterList.h" #include "support/FileFilterList.h"
#include "support/FileName.h"
#include "support/gettext.h"
#include "support/os.h" #include "support/os.h"
/** when this is defined, the code will use /** when this is defined, the code will use

View File

@ -21,6 +21,7 @@
#include "insets/InsetRef.h" #include "insets/InsetRef.h"
#include "support/FileName.h"
#include "support/filetools.h" // MakeAbsPath, MakeDisplayPath #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
#include <QLineEdit> #include <QLineEdit>

View File

@ -16,7 +16,7 @@
#include "GraphicsImage.h" #include "GraphicsImage.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
#include <map> #include <map>

View File

@ -20,6 +20,7 @@
#include "support/debug.h" #include "support/debug.h"
#include "Format.h" #include "Format.h"
#include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/FileMonitor.h" #include "support/FileMonitor.h"

View File

@ -17,6 +17,7 @@
#include "support/convert.h" #include "support/convert.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/ForkedCalls.h" #include "support/ForkedCalls.h"
#include "support/lstrings.h" #include "support/lstrings.h"

View File

@ -32,6 +32,7 @@
#include "support/convert.h" #include "support/convert.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/ForkedCalls.h" #include "support/ForkedCalls.h"
#include "support/lstrings.h" #include "support/lstrings.h"

View File

@ -130,7 +130,7 @@ string const doSubstitution(InsetExternalParams const & params,
relToParentPath, use_latex_path, relToParentPath, use_latex_path,
PROTECT_EXTENSION, PROTECT_EXTENSION,
ESCAPE_DOTS); ESCAPE_DOTS);
if (absolutePath(filename)) { if (FileName(filename).isAbsolute()) {
result = subst_path(result, "$$AbsOrRelPathMaster", result = subst_path(result, "$$AbsOrRelPathMaster",
abspath, use_latex_path, abspath, use_latex_path,
PROTECT_EXTENSION, PROTECT_EXTENSION,

View File

@ -112,7 +112,7 @@ string normalizeName(Buffer const & buffer, OutputParams const & runparams,
string const & name, string const & ext) string const & name, string const & ext)
{ {
string const fname = makeAbsPath(name, buffer.filePath()).absFilename(); string const fname = makeAbsPath(name, buffer.filePath()).absFilename();
if (absolutePath(name) || !FileName(fname + ext).isReadableFile()) if (FileName(name).isAbsolute() || !FileName(fname + ext).isReadableFile())
return name; return name;
if (!runparams.nice) if (!runparams.nice)
return fname; return fname;

View File

@ -382,7 +382,7 @@ int InsetInclude::latex(Buffer const & buffer, odocstream & os,
// if incfile is relative, make it relative to the master // if incfile is relative, make it relative to the master
// buffer directory. // buffer directory.
if (!absolutePath(incfile)) { if (!FileName(incfile).isAbsolute()) {
// FIXME UNICODE // FIXME UNICODE
incfile = to_utf8(makeRelPath(from_utf8(included_file.absFilename()), incfile = to_utf8(makeRelPath(from_utf8(included_file.absFilename()),
from_utf8(masterBuffer->filePath()))); from_utf8(masterBuffer->filePath())));

View File

@ -17,6 +17,7 @@
#include "MathParser.h" #include "MathParser.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/FileName.h"
#include "support/filetools.h" // LibFileSearch #include "support/filetools.h" // LibFileSearch
#include "support/docstream.h" #include "support/docstream.h"

View File

@ -36,6 +36,7 @@
#include "MathStream.h" #include "MathStream.h"
#include "support/docstream.h" #include "support/docstream.h"
#include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/lstrings.h" #include "support/lstrings.h"

View File

@ -52,6 +52,7 @@
#include "insets/InsetCommand.h" #include "insets/InsetCommand.h"
#include "support/docstream.h" #include "support/docstream.h"
#include "support/FileName.h"
#include "support/filetools.h" // LibFileSearch #include "support/filetools.h" // LibFileSearch
#include "support/lstrings.h" #include "support/lstrings.h"

View File

@ -16,6 +16,7 @@
#include "frontends/alert.h" #include "frontends/alert.h"
#include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/lstrings.h" #include "support/lstrings.h"

View File

@ -857,8 +857,9 @@ DocFileName::DocFileName(FileName const & abs_filename, bool save_abs)
void DocFileName::set(string const & name, string const & buffer_path) void DocFileName::set(string const & name, string const & buffer_path)
{ {
save_abs_path_ = absolutePath(name); FileName::set(name);
FileName::set(save_abs_path_ ? name : makeAbsPath(name, buffer_path).absFilename()); if (!isAbsolute())
FileName::set(makeAbsPath(name, buffer_path).absFilename());
zipped_valid_ = false; zipped_valid_ = false;
} }

View File

@ -486,13 +486,6 @@ string const onlyFilename(string const & fname)
} }
/// Returns true is path is absolute
bool absolutePath(string const & path)
{
return FileName(path).isAbsolute();
}
// Create absolute path. If impossible, don't do anything // Create absolute path. If impossible, don't do anything
// Supports ./ and ~/. Later we can add support for ~logname/. (Asger) // Supports ./ and ~/. Later we can add support for ~logname/. (Asger)
string const expandPath(string const & path) string const expandPath(string const & path)

View File

@ -13,7 +13,6 @@
#define LYX_FILETOOL_H #define LYX_FILETOOL_H
#include "support/docstring.h" #include "support/docstring.h"
#include "support/FileName.h"
#include <utility> #include <utility>
#include <string> #include <string>
@ -21,6 +20,8 @@
namespace lyx { namespace lyx {
namespace support { namespace support {
class FileName;
/// Creates the per buffer temporary directory /// Creates the per buffer temporary directory
std::string const createBufferTmpDir(); std::string const createBufferTmpDir();
@ -197,9 +198,6 @@ std::string const unzippedFileName(std::string const & zipped_file);
FileName const unzipFile(FileName const & zipped_file, FileName const unzipFile(FileName const & zipped_file,
std::string const & unzipped_file = std::string()); std::string const & unzipped_file = std::string());
/// Returns true is path is absolute
bool absolutePath(std::string const & path);
/// Create absolute path. If impossible, don't do anything /// Create absolute path. If impossible, don't do anything
std::string const expandPath(std::string const & path); std::string const expandPath(std::string const & path);

View File

@ -16,6 +16,7 @@
#include "support/os.h" #include "support/os.h"
#include "support/FileName.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/debug.h" #include "support/debug.h"

View File

@ -14,6 +14,7 @@
#include "support/os.h" #include "support/os.h"
#include "support/docstring.h" #include "support/docstring.h"
#include "support/FileName.h"
#ifdef __APPLE__ #ifdef __APPLE__
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>

View File

@ -16,7 +16,9 @@
#include "support/os.h" #include "support/os.h"
#include "support/os_win32.h" #include "support/os_win32.h"
#include "support/debug.h" #include "support/debug.h"
#include "support/FileName.h"
#include "support/gettext.h" #include "support/gettext.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/lstrings.h" #include "support/lstrings.h"

View File

@ -18,7 +18,9 @@
#include "Layout.h" #include "Layout.h"
#include "Lexer.h" #include "Lexer.h"
#include "TextClass.h" #include "TextClass.h"
#include "support/convert.h" #include "support/convert.h"
#include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/lstrings.h" #include "support/lstrings.h"

View File

@ -21,9 +21,10 @@
#include "Layout.h" #include "Layout.h"
#include "Length.h" #include "Length.h"
#include "support/lstrings.h"
#include "support/convert.h" #include "support/convert.h"
#include "support/FileName.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "support/lstrings.h"
#include <iostream> #include <iostream>
#include <map> #include <map>
@ -1029,8 +1030,10 @@ string const normalize_filename(string const & name)
/// convention (relative to .lyx file) if it is relative /// convention (relative to .lyx file) if it is relative
void fix_relative_filename(string & name) void fix_relative_filename(string & name)
{ {
if (absolutePath(name)) FileName fname(name);
if (fname.isAbsolute())
return; return;
// FIXME UNICODE encoding of name may be wrong (makeAbsPath expects // FIXME UNICODE encoding of name may be wrong (makeAbsPath expects
// utf8) // utf8)
name = to_utf8(makeRelPath(from_utf8(makeAbsPath(name, getMasterFilePath()).absFilename()), name = to_utf8(makeRelPath(from_utf8(makeAbsPath(name, getMasterFilePath()).absFilename()),