move chdir to FileName

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21890 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2007-12-01 00:06:50 +00:00
parent 10e961f629
commit 63d19999eb
7 changed files with 13 additions and 43 deletions

View 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

View 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;
///

View File

@ -24,7 +24,6 @@ liblyxsupport_la_SOURCES = \
FileMonitor.cpp \
RandomAccessList.h \
abort.cpp \
chdir.cpp \
convert.cpp \
convert.h \
copy.cpp \

View 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();
}

View File

@ -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

View 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);
/**

View 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