#include "support/debug.h"
#include "support/filetools.h"
#include "support/lstrings.h"
-#include "support/lyxlib.h"
#include "support/os.h"
#include "support/Package.h"
#include "support/qstring_helpers.h"
#include <QList>
#include <QTime>
-#include <boost/assert.hpp>
+#include "support/assert.h"
#include <boost/scoped_array.hpp>
#include <map>
}
+bool FileName::isAbsolute() const
+{
+ return d->fi.isAbsolute();
+}
+
+
string FileName::absFilename() const
{
return fromqstr(d->fi.absoluteFilePath());
void FileName::set(string const & name)
{
d->fi.setFile(toqstr(name));
- BOOST_ASSERT(d->fi.isAbsolute());
}
bool FileName::changePermission(unsigned long int mode) const
{
- if (!isWritable()) {
- LYXERR0("File " << *this << " is not writable!");
- return false;
- }
-
#if defined (HAVE_CHMOD) && defined (HAVE_MODE_T)
if (::chmod(toFilesystemEncoding().c_str(), mode_t(mode)) != 0) {
LYXERR0("File " << *this << ": cannot change permission to "
string FileName::onlyFileName() const
{
- return support::onlyFilename(absFilename());
+ return fromqstr(d->fi.fileName());
+}
+
+
+string FileName::onlyFileNameWithoutExt() const
+{
+ return fromqstr(d->fi.baseName());
}
FileName FileName::onlyPath() const
{
- return FileName(support::onlyPath(absFilename()));
+ FileName path;
+ path.d->fi.setFile(d->fi.path());
+ return path;
}
unsigned long FileName::checksum() const
{
if (!exists()) {
- LYXERR0("File \"" << absFilename() << "\" does not exist!");
+ //LYXERR0("File \"" << absFilename() << "\" does not exist!");
return 0;
}
// a directory may be passed here so we need to test it. (bug 3622)
bool FileName::createDirectory(int permission) const
{
- BOOST_ASSERT(!empty());
+ LASSERT(!empty(), /**/);
return mymkdir(toFilesystemEncoding().c_str(), permission) == 0;
}
bool FileName::createPath() const
{
- BOOST_ASSERT(!empty());
+ LASSERT(!empty(), /**/);
if (isDirectory())
return true;
void DocFileName::set(string const & name, string const & buffer_path)
{
- save_abs_path_ = absolutePath(name);
- FileName::set(save_abs_path_ ? name : makeAbsPath(name, buffer_path).absFilename());
+ FileName::set(name);
+ bool const nameIsAbsolute = isAbsolute();
+ save_abs_path_ = nameIsAbsolute;
+ if (!nameIsAbsolute)
+ FileName::set(makeAbsPath(name, buffer_path).absFilename());
zipped_valid_ = false;
}