FileName::FileName() : d(new Private)
-{}
+{
+}
FileName::FileName(string const & abs_filename)
: d(abs_filename.empty() ? new Private : new Private(abs_filename))
indirection = "../../lib";
break;
}
- return FileName(normalizePath(addPath(binary_dir, indirection)));
+ return FileName(addPath(binary_dir, indirection));
}
// 2. Search for system_support_dir / <relative locale dir>
// The <relative locale dir> is OS-dependent. (On Unix, it will
// be "../locale/".)
- FileName path(normalizePath(addPath(system_support_dir.absFilename(),
- relative_locale_dir())));
+ FileName path(addPath(system_support_dir.absFilename(),
+ relative_locale_dir()));
if (path.exists() && path.isDirectory())
return path;
// Try and find "chkconfig.ltx".
string const binary_dir = onlyPath(binary.absFilename());
- FileName const lyxdir(
- normalizePath(addPath(binary_dir, relative_lyxdir)));
+ FileName const lyxdir(addPath(binary_dir, relative_lyxdir));
searched_dirs.push_back(lyxdir);
if (!fileSearch(lyxdir.absFilename(), chkconfig_ltx).empty()) {
}
// Try and find "chkconfig.ltx".
- FileName const lyxdir(
- normalizePath(addPath(binary_dir.absFilename(), relative_lyxdir)));
+ FileName const lyxdir(addPath(binary_dir.absFilename(),
+ relative_lyxdir));
searched_dirs.push_back(lyxdir);
if (!fileSearch(lyxdir.absFilename(), chkconfig_ltx).empty()) {
#include "debug.h"
#include <boost/assert.hpp>
-#include <boost/filesystem/operations.hpp>
#include <boost/regex.hpp>
#include <fcntl.h>
using std::vector;
using std::pair;
-namespace fs = boost::filesystem;
-
namespace lyx {
namespace support {
}
-// 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.
string const replaceEnvironmentPath(string const & path)
{
/// Strip filename from path name
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
std::string const onlyFilename(std::string const & fname);
#include "../filetools.h"
+#include "../FileName.h"
#include <iostream>
void test_normalizePath()
{
- cout << normalizePath("foo/../bar") << endl;
- cout << normalizePath("foo/./bar") << endl;
- cout << normalizePath("./foo/../bar") << endl;
- cout << normalizePath("./foo/./bar") << endl;
- cout << normalizePath("/foo/../bar") << endl;
- cout << normalizePath("/foo/./bar") << endl;
- cout << normalizePath("foo//bar") << endl;
- cout << normalizePath("./foo//bar") << endl;
- cout << normalizePath("/foo//bar") << endl;
+ cout << FileName("foo/../bar").absFilename() << endl;
+ cout << FileName("foo/./bar").absFilename() << endl;
+ cout << FileName("./foo/../bar").absFilename() << endl;
+ cout << FileName("./foo/./bar").absFilename() << endl;
+ cout << FileName("/foo/../bar").absFilename() << endl;
+ cout << FileName("/foo/./bar").absFilename() << endl;
+ cout << FileName("foo//bar").absFilename() << endl;
+ cout << FileName("./foo//bar").absFilename() << endl;
+ cout << FileName("/foo//bar").absFilename() << endl;
}
int main()