mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Getting rid of normalizePath() which is unneeded for FileName purpose (the path is always normalized internally). This commit frees up src/ from boost::filesystem. Some remaining references stays in src/client and src/tex2lyx.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21817 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3df451b6d0
commit
c23db901ec
@ -76,7 +76,8 @@ struct FileName::Private
|
|||||||
|
|
||||||
|
|
||||||
FileName::FileName() : d(new Private)
|
FileName::FileName() : d(new Private)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
FileName::FileName(string const & abs_filename)
|
FileName::FileName(string const & abs_filename)
|
||||||
: d(abs_filename.empty() ? new Private : new Private(abs_filename))
|
: d(abs_filename.empty() ? new Private : new Private(abs_filename))
|
||||||
|
@ -247,7 +247,7 @@ FileName buildSupportDir(string const & binary_dir,
|
|||||||
indirection = "../../lib";
|
indirection = "../../lib";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return FileName(normalizePath(addPath(binary_dir, indirection)));
|
return FileName(addPath(binary_dir, indirection));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -346,8 +346,8 @@ FileName const get_locale_dir(FileName const & system_support_dir)
|
|||||||
// 2. Search for system_support_dir / <relative locale dir>
|
// 2. Search for system_support_dir / <relative locale dir>
|
||||||
// The <relative locale dir> is OS-dependent. (On Unix, it will
|
// The <relative locale dir> is OS-dependent. (On Unix, it will
|
||||||
// be "../locale/".)
|
// be "../locale/".)
|
||||||
FileName path(normalizePath(addPath(system_support_dir.absFilename(),
|
FileName path(addPath(system_support_dir.absFilename(),
|
||||||
relative_locale_dir())));
|
relative_locale_dir()));
|
||||||
|
|
||||||
if (path.exists() && path.isDirectory())
|
if (path.exists() && path.isDirectory())
|
||||||
return path;
|
return path;
|
||||||
@ -490,8 +490,7 @@ get_system_support_dir(FileName const & abs_binary,
|
|||||||
// Try and find "chkconfig.ltx".
|
// Try and find "chkconfig.ltx".
|
||||||
string const binary_dir = onlyPath(binary.absFilename());
|
string const binary_dir = onlyPath(binary.absFilename());
|
||||||
|
|
||||||
FileName const lyxdir(
|
FileName const lyxdir(addPath(binary_dir, relative_lyxdir));
|
||||||
normalizePath(addPath(binary_dir, relative_lyxdir)));
|
|
||||||
searched_dirs.push_back(lyxdir);
|
searched_dirs.push_back(lyxdir);
|
||||||
|
|
||||||
if (!fileSearch(lyxdir.absFilename(), chkconfig_ltx).empty()) {
|
if (!fileSearch(lyxdir.absFilename(), chkconfig_ltx).empty()) {
|
||||||
@ -531,8 +530,8 @@ get_system_support_dir(FileName const & abs_binary,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try and find "chkconfig.ltx".
|
// Try and find "chkconfig.ltx".
|
||||||
FileName const lyxdir(
|
FileName const lyxdir(addPath(binary_dir.absFilename(),
|
||||||
normalizePath(addPath(binary_dir.absFilename(), relative_lyxdir)));
|
relative_lyxdir));
|
||||||
searched_dirs.push_back(lyxdir);
|
searched_dirs.push_back(lyxdir);
|
||||||
|
|
||||||
if (!fileSearch(lyxdir.absFilename(), chkconfig_ltx).empty()) {
|
if (!fileSearch(lyxdir.absFilename(), chkconfig_ltx).empty()) {
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/filesystem/operations.hpp>
|
|
||||||
#include <boost/regex.hpp>
|
#include <boost/regex.hpp>
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -58,8 +57,6 @@ using std::ostringstream;
|
|||||||
using std::vector;
|
using std::vector;
|
||||||
using std::pair;
|
using std::pair;
|
||||||
|
|
||||||
namespace fs = boost::filesystem;
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace support {
|
namespace support {
|
||||||
|
|
||||||
@ -524,24 +521,6 @@ string const expandPath(string const & path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Normalize a path. Constracts path/../path
|
|
||||||
// Can't handle "../../" or "/../" (Asger)
|
|
||||||
// Also converts paths like /foo//bar ==> /foo/bar
|
|
||||||
string const normalizePath(string const & path)
|
|
||||||
{
|
|
||||||
// Normalize paths like /foo//bar ==> /foo/bar
|
|
||||||
static boost::regex regex("/{2,}");
|
|
||||||
string const tmppath = boost::regex_merge(path, regex, "/");
|
|
||||||
|
|
||||||
fs::path const npath = fs::path(tmppath, fs::no_check).normalize();
|
|
||||||
|
|
||||||
if (!npath.is_complete())
|
|
||||||
return "./" + npath.string() + '/';
|
|
||||||
|
|
||||||
return npath.string() + '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Search the string for ${VAR} and $VAR and replace VAR using getenv.
|
// Search the string for ${VAR} and $VAR and replace VAR using getenv.
|
||||||
string const replaceEnvironmentPath(string const & path)
|
string const replaceEnvironmentPath(string const & path)
|
||||||
{
|
{
|
||||||
|
@ -230,11 +230,6 @@ makeRelPath(docstring const & abspath, docstring const & basepath);
|
|||||||
/// Strip filename from path name
|
/// Strip filename from path name
|
||||||
std::string const onlyPath(std::string const & fname);
|
std::string const onlyPath(std::string const & fname);
|
||||||
|
|
||||||
/** Normalize a path. Constracts path/../path
|
|
||||||
* Also converts paths like /foo//bar ==> /foo/bar
|
|
||||||
*/
|
|
||||||
std::string const normalizePath(std::string const & path);
|
|
||||||
|
|
||||||
/// Strips path from filename
|
/// Strips path from filename
|
||||||
std::string const onlyFilename(std::string const & fname);
|
std::string const onlyFilename(std::string const & fname);
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "../filetools.h"
|
#include "../filetools.h"
|
||||||
|
#include "../FileName.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -13,15 +14,15 @@ namespace lyx {
|
|||||||
|
|
||||||
void test_normalizePath()
|
void test_normalizePath()
|
||||||
{
|
{
|
||||||
cout << normalizePath("foo/../bar") << endl;
|
cout << FileName("foo/../bar").absFilename() << endl;
|
||||||
cout << normalizePath("foo/./bar") << endl;
|
cout << FileName("foo/./bar").absFilename() << endl;
|
||||||
cout << normalizePath("./foo/../bar") << endl;
|
cout << FileName("./foo/../bar").absFilename() << endl;
|
||||||
cout << normalizePath("./foo/./bar") << endl;
|
cout << FileName("./foo/./bar").absFilename() << endl;
|
||||||
cout << normalizePath("/foo/../bar") << endl;
|
cout << FileName("/foo/../bar").absFilename() << endl;
|
||||||
cout << normalizePath("/foo/./bar") << endl;
|
cout << FileName("/foo/./bar").absFilename() << endl;
|
||||||
cout << normalizePath("foo//bar") << endl;
|
cout << FileName("foo//bar").absFilename() << endl;
|
||||||
cout << normalizePath("./foo//bar") << endl;
|
cout << FileName("./foo//bar").absFilename() << endl;
|
||||||
cout << normalizePath("/foo//bar") << endl;
|
cout << FileName("/foo//bar").absFilename() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
Loading…
Reference in New Issue
Block a user