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);
|
extern unsigned long sum(char const * file);
|
||||||
|
|
||||||
unsigned long FileName::checksum() const
|
unsigned long FileName::checksum() const
|
||||||
|
@ -136,6 +136,9 @@ public:
|
|||||||
/// used for display in the Gui
|
/// used for display in the Gui
|
||||||
docstring displayName(int threshold = 1000) const;
|
docstring displayName(int threshold = 1000) const;
|
||||||
|
|
||||||
|
/// change to a directory, return success
|
||||||
|
bool chdir() const;
|
||||||
|
|
||||||
//private:
|
//private:
|
||||||
friend class DocFileName;
|
friend class DocFileName;
|
||||||
///
|
///
|
||||||
|
@ -24,7 +24,6 @@ liblyxsupport_la_SOURCES = \
|
|||||||
FileMonitor.cpp \
|
FileMonitor.cpp \
|
||||||
RandomAccessList.h \
|
RandomAccessList.h \
|
||||||
abort.cpp \
|
abort.cpp \
|
||||||
chdir.cpp \
|
|
||||||
convert.cpp \
|
convert.cpp \
|
||||||
convert.h \
|
convert.h \
|
||||||
copy.cpp \
|
copy.cpp \
|
||||||
|
@ -28,7 +28,7 @@ PathChanger::PathChanger(FileName const & path)
|
|||||||
if (!path.empty()) {
|
if (!path.empty()) {
|
||||||
pushedDir_ = getcwd();
|
pushedDir_ = getcwd();
|
||||||
|
|
||||||
if (pushedDir_.empty() || chdir(path)) {
|
if (pushedDir_.empty() || !path.chdir()) {
|
||||||
/* FIXME: throw */
|
/* FIXME: throw */
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -52,7 +52,7 @@ int PathChanger::pop()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chdir(pushedDir_)) {
|
if (!pushedDir_.chdir()) {
|
||||||
// should throw an exception
|
// should throw an exception
|
||||||
// throw DirChangeError();
|
// 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
|
/// get the current working directory
|
||||||
FileName const getcwd();
|
FileName const getcwd();
|
||||||
/// change to a directory, 0 is returned on success.
|
|
||||||
int chdir(FileName const & name);
|
|
||||||
/// Change file permissions
|
/// Change file permissions
|
||||||
bool chmod(FileName const & file, unsigned long int mode);
|
bool chmod(FileName const & file, unsigned long int mode);
|
||||||
/**
|
/**
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "support/lyxlib.h"
|
#include "support/lyxlib.h"
|
||||||
|
#include "support/debug.h"
|
||||||
#include "support/FileName.h"
|
#include "support/FileName.h"
|
||||||
|
|
||||||
#ifdef HAVE_SYS_STAT_H
|
#ifdef HAVE_SYS_STAT_H
|
||||||
@ -36,6 +37,7 @@ namespace support {
|
|||||||
|
|
||||||
int mymkdir(char const * pathname, unsigned long int mode)
|
int mymkdir(char const * pathname, unsigned long int mode)
|
||||||
{
|
{
|
||||||
|
LYXERR0("MKDIR" << pathname);
|
||||||
// FIXME: why don't we have mode_t in lyx::mkdir prototype ??
|
// FIXME: why don't we have mode_t in lyx::mkdir prototype ??
|
||||||
#if HAVE_MKDIR
|
#if HAVE_MKDIR
|
||||||
# if MKDIR_TAKES_ONE_ARG
|
# if MKDIR_TAKES_ONE_ARG
|
||||||
|
Loading…
Reference in New Issue
Block a user