mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 05:33:33 +00:00
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:
parent
10e961f629
commit
63d19999eb
@ -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
|
||||
|
@ -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;
|
||||
///
|
||||
|
@ -24,7 +24,6 @@ liblyxsupport_la_SOURCES = \
|
||||
FileMonitor.cpp \
|
||||
RandomAccessList.h \
|
||||
abort.cpp \
|
||||
chdir.cpp \
|
||||
convert.cpp \
|
||||
convert.h \
|
||||
copy.cpp \
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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
|
@ -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);
|
||||
/**
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user