]> git.lyx.org Git - features.git/commitdiff
move chdir to FileName
authorAndré Pönitz <poenitz@gmx.net>
Sat, 1 Dec 2007 00:06:50 +0000 (00:06 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sat, 1 Dec 2007 00:06:50 +0000 (00:06 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21890 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/FileName.cpp
src/support/FileName.h
src/support/Makefile.am
src/support/Path.cpp
src/support/chdir.cpp [deleted file]
src/support/lyxlib.h
src/support/mkdir.cpp

index 5704d2cb0241ae6ac338a714b5b9777599c82fd9..67a9b8579a074b74c168f3e922d33de02904ba73 100644 (file)
@@ -236,6 +236,12 @@ std::time_t FileName::lastModified() const
 }
 
 
+bool FileName::chdir() const
+{
+       return QDir::setCurrent(d->fi.absoluteFilePath());
+}
+
+
 extern unsigned long sum(char const * file);
 
 unsigned long FileName::checksum() const
index b6a4d85086046b71a73cfe5e1062db1e2010e251..3577ed9c385efc09458f347ab7724b05940e7852 100644 (file)
@@ -136,6 +136,9 @@ public:
        /// used for display in the Gui
        docstring displayName(int threshold = 1000) const;
 
+       /// change to a directory, return success
+       bool chdir() const;
+
 //private:
        friend class DocFileName;
        ///
index c689469f3c793568118d6549a431f02e0a89eb9f..3e69f53f008bb50ac22ab11e069a158c6dabf52f 100644 (file)
@@ -24,7 +24,6 @@ liblyxsupport_la_SOURCES = \
        FileMonitor.cpp \
        RandomAccessList.h \
        abort.cpp \
-       chdir.cpp \
        convert.cpp \
        convert.h \
        copy.cpp \
index 147efd07e512bafde1dd1d3ac69e95378d0eb6ed..8b85471c979dd93f2726f37d4fa37c55293236ba 100644 (file)
@@ -28,7 +28,7 @@ PathChanger::PathChanger(FileName const & path)
        if (!path.empty()) {
                pushedDir_ = getcwd();
 
-               if (pushedDir_.empty() || chdir(path)) {
+               if (pushedDir_.empty() || !path.chdir()) {
                        /* FIXME: throw */
                }
        } else {
@@ -52,7 +52,7 @@ int PathChanger::pop()
                return 0;
        }
 
-       if (chdir(pushedDir_)) {
+       if (!pushedDir_.chdir()) {
                // should throw an exception
                // throw DirChangeError();
        }
diff --git a/src/support/chdir.cpp b/src/support/chdir.cpp
deleted file mode 100644 (file)
index 7bfca71..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * \file chdir.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Lars Gullik Bjønnes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "support/lyxlib.h"
-
-#include "support/FileName.h"
-
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#ifdef _WIN32
-# include <windows.h>
-#endif
-
-
-namespace lyx {
-
-int support::chdir(FileName const & name)
-{
-#ifdef _WIN32
-       return SetCurrentDirectory(name.toFilesystemEncoding().c_str()) != 0 ? 0 : -1;
-#else
-       return ::chdir(name.toFilesystemEncoding().c_str());
-#endif
-}
-
-
-} // namespace lyx
index f2cfaa6bdb2e80f848d5a267b7c36a3b71e944f2..b7952d2868d966a34fd4270350908a72488e9c92 100644 (file)
@@ -25,8 +25,6 @@ namespace support {
 
 /// get the current working directory
 FileName const getcwd();
-/// change to a directory, 0 is returned on success.
-int chdir(FileName const & name);
 /// Change file permissions
 bool chmod(FileName const & file, unsigned long int mode);
 /**
index 366f34006485bfb112ebc5bbb84f5b9ca5745bd7..d96dca007b7ab310a7dad92256fe2b82fbb810ed 100644 (file)
@@ -11,6 +11,7 @@
 #include <config.h>
 
 #include "support/lyxlib.h"
+#include "support/debug.h"
 #include "support/FileName.h"
 
 #ifdef HAVE_SYS_STAT_H
@@ -36,6 +37,7 @@ namespace support {
 
 int mymkdir(char const * pathname, unsigned long int mode)
 {
+       LYXERR0("MKDIR" << pathname);
        // FIXME: why don't we have mode_t in lyx::mkdir prototype ??
 #if HAVE_MKDIR
 # if MKDIR_TAKES_ONE_ARG