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;
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);
}
+bool FileName::isAbsolute() const
+{
+ return d->fi.isAbsolute();
+}
+
+
string FileName::absFilename() const
{
return fromqstr(d->fi.absoluteFilePath());
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;
/**
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);
}
#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.
// 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);
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);
/// Returns true is path is absolute
bool absolutePath(string const & path)
{
- return os::is_absolute_path(path);
+ return FileName(path).isAbsolute();
}
{
// 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;
*/
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.
*/
// 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 << ']');
}
-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()
}
-bool is_absolute_path(string const & p)
-{
- return !p.empty() && p[0] == '/';
-}
-
-
char const * popen_read_mode()
{
return "r";
// 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);
}
-// (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()