Free src/ from boost::filesystem.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21784 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-11-25 21:21:03 +00:00
parent 9608e4971b
commit b897636173
7 changed files with 32 additions and 27 deletions

View 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"),

View 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)) {

View File

@ -23,8 +23,6 @@
#include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
#include <boost/filesystem/operations.hpp>
#include <QLineEdit>
#include <QCheckBox>
#include <QListWidget>

View 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 {

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

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

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