mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
transfer os::is_absolute_path() to FileName::isAbsolute().
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22187 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
908a119973
commit
96ee270933
@ -163,9 +163,9 @@ void LastFilePosSection::read(istream & is)
|
||||
itmp >> filepos.pos;
|
||||
itmp.ignore(2); // ignore ", "
|
||||
getline(itmp, fname);
|
||||
if (!absolutePath(fname))
|
||||
continue;
|
||||
FileName const file(fname);
|
||||
if (!file.isAbsolute())
|
||||
continue;
|
||||
if (file.exists() && !file.isDirectory()
|
||||
&& lastfilepos.size() < num_lastfilepos)
|
||||
lastfilepos[file] = filepos;
|
||||
@ -240,9 +240,9 @@ void BookmarksSection::read(istream & is)
|
||||
itmp >> pos;
|
||||
itmp.ignore(2); // ignore ", "
|
||||
getline(itmp, fname);
|
||||
if (!absolutePath(fname))
|
||||
continue;
|
||||
FileName const file(fname);
|
||||
if (!file.isAbsolute())
|
||||
continue;
|
||||
// only load valid bookmarks
|
||||
if (file.exists() && !file.isDirectory() && idx <= max_bookmarks)
|
||||
bookmarks[idx] = Bookmark(file, pit, pos, 0, 0);
|
||||
|
@ -140,6 +140,12 @@ bool FileName::empty() const
|
||||
}
|
||||
|
||||
|
||||
bool FileName::isAbsolute() const
|
||||
{
|
||||
return d->fi.isAbsolute();
|
||||
}
|
||||
|
||||
|
||||
string FileName::absFilename() const
|
||||
{
|
||||
return fromqstr(d->fi.absoluteFilePath());
|
||||
|
@ -55,6 +55,9 @@ public:
|
||||
virtual void erase();
|
||||
/// Is this filename empty?
|
||||
bool empty() const;
|
||||
/// Is the filename absolute?
|
||||
bool isAbsolute() const;
|
||||
|
||||
/// get the absolute file name in UTF-8 encoding
|
||||
std::string absFilename() const;
|
||||
/**
|
||||
|
@ -379,8 +379,9 @@ FileName const abs_path_from_command_line(string const & command_line)
|
||||
if (command_line.empty())
|
||||
return FileName();
|
||||
|
||||
string const path = fix_dir_name(command_line);
|
||||
return os::is_absolute_path(path) ? FileName(path) : makeAbsPath(path);
|
||||
string const str_path = fix_dir_name(command_line);
|
||||
FileName path(str_path);
|
||||
return path.isAbsolute() ? path : makeAbsPath(str_path);
|
||||
}
|
||||
|
||||
|
||||
@ -397,8 +398,9 @@ FileName const get_binary_path(string const & exe)
|
||||
#else
|
||||
string const exe_path = os::internal_path(exe);
|
||||
#endif
|
||||
if (os::is_absolute_path(exe_path))
|
||||
return FileName(exe_path);
|
||||
FileName exepath(exe_path);
|
||||
if (exepath.isAbsolute())
|
||||
return exepath;
|
||||
|
||||
// Two possibilities present themselves.
|
||||
// 1. The binary is relative to the CWD.
|
||||
|
@ -395,9 +395,10 @@ string const onlyPath(string const & filename)
|
||||
// If basepath is empty, use CWD as base.
|
||||
FileName const makeAbsPath(string const & relPath, string const & basePath)
|
||||
{
|
||||
FileName relative_path(relPath);
|
||||
// checks for already absolute path
|
||||
if (os::is_absolute_path(relPath))
|
||||
return FileName(relPath);
|
||||
if (relative_path.isAbsolute())
|
||||
return relative_path;
|
||||
|
||||
// Copies given paths
|
||||
string tempRel = os::internal_path(relPath);
|
||||
@ -406,7 +407,8 @@ FileName const makeAbsPath(string const & relPath, string const & basePath)
|
||||
|
||||
string tempBase;
|
||||
|
||||
if (os::is_absolute_path(basePath))
|
||||
FileName base_path(basePath);
|
||||
if (base_path.isAbsolute())
|
||||
tempBase = basePath;
|
||||
else
|
||||
tempBase = addPath(FileName::getcwd().absFilename(), basePath);
|
||||
@ -487,7 +489,7 @@ string const onlyFilename(string const & fname)
|
||||
/// Returns true is path is absolute
|
||||
bool absolutePath(string const & path)
|
||||
{
|
||||
return os::is_absolute_path(path);
|
||||
return FileName(path).isAbsolute();
|
||||
}
|
||||
|
||||
|
||||
@ -497,7 +499,8 @@ string const expandPath(string const & path)
|
||||
{
|
||||
// checks for already absolute path
|
||||
string rTemp = replaceEnvironmentPath(path);
|
||||
if (os::is_absolute_path(rTemp))
|
||||
FileName abs_path(rTemp);
|
||||
if (abs_path.isAbsolute())
|
||||
return rTemp;
|
||||
|
||||
string temp;
|
||||
|
@ -71,10 +71,6 @@ std::string internal_path_list(std::string const & p);
|
||||
*/
|
||||
std::string latex_path(std::string const & p);
|
||||
|
||||
/// Is the path absolute?
|
||||
/// \p p is encoded in utf8.
|
||||
bool is_absolute_path(std::string const & p);
|
||||
|
||||
/** Returns a string suitable to be passed to popen when
|
||||
* reading a file.
|
||||
*/
|
||||
|
@ -187,7 +187,7 @@ string latex_path(string const & p)
|
||||
// on windows_style_tex_paths_), but we use always forward slashes,
|
||||
// since it gets written into a .tex file.
|
||||
|
||||
if (windows_style_tex_paths_ && is_absolute_path(p)) {
|
||||
if (windows_style_tex_paths_ && FileName(p).isAbsolute()) {
|
||||
string dos_path = convert_path(p, PathStyle(windows));
|
||||
LYXERR(Debug::LATEX, "<Path correction for LaTeX> ["
|
||||
<< p << "]->>[" << dos_path << ']');
|
||||
@ -198,18 +198,6 @@ string latex_path(string const & p)
|
||||
}
|
||||
|
||||
|
||||
bool is_absolute_path(string const & p)
|
||||
{
|
||||
if (p.empty())
|
||||
return false;
|
||||
|
||||
bool isDosPath = (p.length() > 1 && p[1] == ':');
|
||||
bool isUnixPath = (p[0] == '/');
|
||||
|
||||
return isDosPath || isUnixPath;
|
||||
}
|
||||
|
||||
|
||||
// returns a string suitable to be passed to popen when
|
||||
// reading a pipe
|
||||
char const * popen_read_mode()
|
||||
|
@ -85,12 +85,6 @@ string latex_path(string const & p)
|
||||
}
|
||||
|
||||
|
||||
bool is_absolute_path(string const & p)
|
||||
{
|
||||
return !p.empty() && p[0] == '/';
|
||||
}
|
||||
|
||||
|
||||
char const * popen_read_mode()
|
||||
{
|
||||
return "r";
|
||||
|
@ -240,7 +240,8 @@ string latex_path(string const & p)
|
||||
// on windows_style_tex_paths_), but we use always forward slashes,
|
||||
// since it gets written into a .tex file.
|
||||
|
||||
if (!windows_style_tex_paths_ && is_absolute_path(p)) {
|
||||
FileName path(p);
|
||||
if (!windows_style_tex_paths_ && path.isAbsolute()) {
|
||||
string const drive = p.substr(0, 2);
|
||||
string const cygprefix = cygdrive + "/" + drive.substr(0, 1);
|
||||
string const cygpath = subst(subst(p, '\\', '/'), drive, cygprefix);
|
||||
@ -252,37 +253,6 @@ string latex_path(string const & p)
|
||||
}
|
||||
|
||||
|
||||
// (Claus H.) On Win32 both Unix and Win32/DOS pathnames are used.
|
||||
// Therefore an absolute path could be either a pathname starting
|
||||
// with a slash (Unix) or a pathname starting with a drive letter
|
||||
// followed by a colon. Because a colon is not valid in pathes in Unix
|
||||
// and at another location in Win32 testing just for the existance
|
||||
// of the colon in the 2nd position seems to be enough!
|
||||
// FIXME: Port to FileName!
|
||||
bool is_absolute_path(string const & p)
|
||||
{
|
||||
if (p.empty())
|
||||
return false;
|
||||
|
||||
if (p[0] == '/')
|
||||
// Unix style.
|
||||
return true;
|
||||
|
||||
if (p.length() <= 1)
|
||||
return false;
|
||||
|
||||
if (p[1] == ':')
|
||||
// 'X:\' style.
|
||||
return true;
|
||||
|
||||
if (p[0] == '\\' && p[1] == '\\')
|
||||
// Network folder style: '\\server\share'
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// returns a string suitable to be passed to popen when
|
||||
// reading a pipe
|
||||
char const * popen_read_mode()
|
||||
|
Loading…
Reference in New Issue
Block a user