]> git.lyx.org Git - features.git/commitdiff
Getting rid of normalizePath() which is unneeded for FileName purpose (the path is...
authorAbdelrazak Younes <younes@lyx.org>
Tue, 27 Nov 2007 10:01:34 +0000 (10:01 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Tue, 27 Nov 2007 10:01:34 +0000 (10:01 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21817 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/FileName.cpp
src/support/Package.cpp
src/support/filetools.cpp
src/support/filetools.h
src/support/tests/check_filetools.cpp

index d5507120f4f78ceeb76a4ca2b9909fd4e33926df..91b9a33cc4db809d17927a84737af8b7a5e7373d 100644 (file)
@@ -76,7 +76,8 @@ struct FileName::Private
 
 
 FileName::FileName() : d(new Private)
-{}
+{
+}
 
 FileName::FileName(string const & abs_filename)
        : d(abs_filename.empty() ? new Private : new Private(abs_filename))
index 0b92353860131d1ddc2e9625bd31666fbcd72a3d..6231a660ac69b067452af5d283f34937741c004d 100644 (file)
@@ -247,7 +247,7 @@ FileName buildSupportDir(string const & binary_dir,
                indirection = "../../lib";
                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>
        // 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;
@@ -490,8 +490,7 @@ get_system_support_dir(FileName const & abs_binary,
                // 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()) {
@@ -531,8 +530,8 @@ get_system_support_dir(FileName const & abs_binary,
                }
 
                // 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()) {
index 4b80d824fe4c63eb6004195917d392f14dfdc843..2357f3848229210f039f36982336bd1c42175132 100644 (file)
@@ -36,7 +36,6 @@
 #include "debug.h"
 
 #include <boost/assert.hpp>
-#include <boost/filesystem/operations.hpp>
 #include <boost/regex.hpp>
 
 #include <fcntl.h>
@@ -58,8 +57,6 @@ using std::ostringstream;
 using std::vector;
 using std::pair;
 
-namespace fs = boost::filesystem;
-
 namespace lyx {
 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.
 string const replaceEnvironmentPath(string const & path)
 {
index 7fb33baea0518a750f8502454be157f3eeea53e2..512d78db80e2d33147e0a82c7bacd7d2f40e7287 100644 (file)
@@ -230,11 +230,6 @@ makeRelPath(docstring const & abspath, docstring const & basepath);
 /// 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);
 
index 4859f8db1848e5bdab14a63a7577d6ae735d398c..ac74f3ebe62b2b1bacf08a35ffc106902e82213d 100644 (file)
@@ -1,4 +1,5 @@
 #include "../filetools.h"
+#include "../FileName.h"
 
 #include <iostream>
 
@@ -13,15 +14,15 @@ namespace lyx {
 
 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()