]> git.lyx.org Git - features.git/commitdiff
Free src/ from boost::filesystem.
authorAbdelrazak Younes <younes@lyx.org>
Sun, 25 Nov 2007 21:21:03 +0000 (21:21 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sun, 25 Nov 2007 21:21:03 +0000 (21:21 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21784 a592a061-630c-0410-9148-cb99ea01b6c8

src/EmbeddedFiles.cpp
src/LaTeX.cpp
src/frontends/qt4/GuiRef.cpp
src/insets/InsetInclude.cpp
src/support/FileName.cpp
src/support/FileName.h
src/support/Package.cpp

index 63d0dcd811c031166fe7cbb83d4e0c4a8f55e9a8..bf2e5fbd358c3089ca5335d350c2c64d0568b24f 100644 (file)
@@ -25,8 +25,6 @@
 
 #include "frontends/alert.h"
 
-#include <boost/filesystem/operations.hpp>
-
 #include "support/filetools.h"
 #include "support/convert.h"
 #include "support/lyxlib.h"
@@ -52,7 +50,6 @@ using std::istringstream;
 
 namespace lyx {
 
-namespace fs = boost::filesystem;
 namespace Alert = frontend::Alert;
 
 using support::FileName;
@@ -156,9 +153,9 @@ bool EmbeddedFile::extract(Buffer const * buf) const
        // copy file
 
        // need to make directory?
-       string path = support::onlyPath(ext_file);
-       if (!fs::is_directory(path))
-               makedir(const_cast<char*>(path.c_str()), 0755);
+       FileName path = ext.onlyPath();
+       if (!path.isDirectory())
+               makedir(const_cast<char*>(path.absFilename().c_str()), 0755);
        if (emb.copyTo(ext, false))
                return true;
        Alert::error(_("Copy file failure"),
@@ -198,9 +195,9 @@ bool EmbeddedFile::updateFromExternalFile(Buffer const * buf) const
        }
        // copy file
        // need to make directory?
-       string path = support::onlyPath(emb_file);
-       if (!fs::is_directory(path))
-               makedir(const_cast<char*>(path.c_str()), 0755);
+       FileName path = emb.onlyPath();
+       if (!path.isDirectory())
+               makedir(const_cast<char*>(path.absFilename().c_str()), 0755);
        if (ext.copyTo(emb, false))
                return true;
        Alert::error(_("Copy file failure"),
index 7c9d8e077862c9d1eb5386ebff63f73b34101ec5..16e504ad2c742c244d3888a1ab75dd838a39b4c3 100644 (file)
@@ -29,8 +29,6 @@
 #include "support/Systemcall.h"
 #include "support/os.h"
 
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
 #include <boost/regex.hpp>
 
 #include <fstream>
@@ -74,7 +72,6 @@ using support::unlink;
 using support::trim;
 
 namespace os = support::os;
-namespace fs = boost::filesystem;
 
 // TODO: in no particular order
 // - get rid of the call to
@@ -288,7 +285,7 @@ int LaTeX::run(TeXErrors & terr)
        // memoir (at least) writes an empty *idx file in the first place.
        // A second latex run is needed.
        FileName const idxfile(changeExtension(file.absFilename(), ".idx"));
-       rerun = idxfile.exists() && fs::is_empty(idxfile.toFilesystemEncoding());
+       rerun = idxfile.exists() && idxfile.isFileEmpty();
 
        // run makeindex
        if (head.haschanged(idxfile)) {
index b0ae6958ccd818f040e124d4804b7d08f35a7dae..5a0c01c054b77ada8b7189c7cee595d7a2a3fd9e 100644 (file)
@@ -23,8 +23,6 @@
 
 #include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
 
-#include <boost/filesystem/operations.hpp>
-
 #include <QLineEdit>
 #include <QCheckBox>
 #include <QListWidget>
index 4006bb1d0b97fdfde69b21f2e495d5da09315cbb..f05f9022ad12fa79f6c1515732a328b1af06e8f5 100644 (file)
@@ -455,7 +455,7 @@ int InsetInclude::latex(Buffer const & buffer, odocstream & os,
                Encoding const * const oldEnc = runparams.encoding;
                runparams.encoding = &tmp->params().encoding();
                tmp->makeLaTeXFile(writefile,
-                                  masterFileName(buffer).onlyPath(),
+                                  masterFileName(buffer).onlyPath().absFilename(),
                                   runparams, false);
                runparams.encoding = oldEnc;
        } else {
index 467b43dcceddad5830d1c376ffc6c1e123a94bfb..a99de6750cf2905ee4917f97f358219b5ccb1ad2 100644 (file)
@@ -204,6 +204,18 @@ bool FileName::exists() const
 }
 
 
+bool FileName::isSymLink() const
+{
+       return QFileInfo(toqstr(name_)).isSymLink();
+}
+
+
+bool FileName::isFileEmpty() const
+{
+       return QFileInfo(toqstr(name_)).size() == 0;
+}
+
+
 bool FileName::isDirectory() const
 {
        return QFileInfo(toqstr(name_)).isDir();
@@ -230,9 +242,9 @@ std::string FileName::onlyFileName() const
 }
 
 
-std::string FileName::onlyPath() const
+FileName FileName::onlyPath() const
 {
-       return support::onlyPath(absFilename());
+       return FileName(support::onlyPath(absFilename()));
 }
 
 
index 7b1fb066660995bf22262687587f5a8db6bc044f..7ff353ee7677207cbbf0cc8c8c7fae6600205fe4 100644 (file)
@@ -57,6 +57,10 @@ public:
 
        /// returns true if the file exists
        bool exists() const;
+       /// \return true if this object points to a symbolic link.
+       bool isSymLink() const;
+       /// \return true if the file is empty.
+       bool isFileEmpty() const;
        /// returns time of last write access
        std::time_t lastModified() const;
        /// return true when file is readable but not writabel
@@ -107,7 +111,7 @@ public:
        /// filename without path
        std::string onlyFileName() const;
        /// path without file name
-       std::string onlyPath() const;
+       FileName onlyPath() const;
        /// used for display in the Gui
        docstring displayName(int threshold = 1000) const;
 
index 2f3bad68f1891966c733ab0718c03cdce59b63b7..6c6587832782edc6f6e63447aafbdd2011cf68ed 100644 (file)
@@ -26,7 +26,6 @@
 # include "support/os_win32.h"
 #endif
 
-#include <boost/filesystem/operations.hpp>
 #include <boost/tuple/tuple.hpp>
 
 #include <list>
@@ -44,8 +43,6 @@
 
 using std::string;
 
-namespace fs = boost::filesystem;
-
 namespace lyx {
 namespace support {
 
@@ -295,7 +292,7 @@ get_build_dirs(FileName const & abs_binary,
 
                // Check whether binary is a symbolic link.
                // If so, resolve it and repeat the exercise.
-               if (!fs::symbolic_link_exists(binary.toFilesystemEncoding()))
+               if (!binary.isSymLink())
                        break;
 
                FileName link;
@@ -356,12 +353,12 @@ FileName const get_locale_dir(FileName const & system_support_dir)
        FileName path(normalizePath(addPath(system_support_dir.absFilename(),
                                            relative_locale_dir())));
 
-       if (path.exists() && fs::is_directory(path.toFilesystemEncoding()))
+       if (path.exists() && path.isDirectory())
                return path;
 
        // 3. Fall back to the hard-coded LOCALEDIR.
        path = hardcoded_localedir();
-       if (path.exists() && fs::is_directory(path.toFilesystemEncoding()))
+       if (path.exists() && path.isDirectory())
                return path;
 
        return FileName();
@@ -508,7 +505,7 @@ get_system_support_dir(FileName const & abs_binary,
 
                // Check whether binary is a symbolic link.
                // If so, resolve it and repeat the exercise.
-               if (!fs::symbolic_link_exists(binary.toFilesystemEncoding()))
+               if (!binary.isSymLink())
                        break;
 
                FileName link;
@@ -526,7 +523,7 @@ get_system_support_dir(FileName const & abs_binary,
                // This time test whether the directory is a symbolic link
                // *before* looking for "chkconfig.ltx".
                // (We've looked relative to the original already.)
-               if (!fs::symbolic_link_exists(binary.toFilesystemEncoding()))
+               if (!binary.isSymLink())
                        break;
 
                FileName link;