#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"
}
+bool FileName::isAbsolute() const
+{
+ return d->fi.isAbsolute();
+}
+
+
string FileName::absFilename() const
{
return fromqstr(d->fi.absoluteFilePath());
{
LYXERR(Debug::FILES, "isDirWriteable: " << *this);
- FileName const tmpfl = FileName::tempName(*this, "lyxwritetest");
+ FileName const tmpfl = FileName::tempName(absFilename() + "/lyxwritetest");
if (tmpfl.empty())
return false;
}
-FileName FileName::tempName(FileName const & dir, string const & mask)
+FileName FileName::tempName(string const & mask)
{
- string const tmpdir = dir.empty() ?
- package().temp_dir().absFilename() : dir.absFilename();
- string tmpfl = to_filesystem8bit(from_utf8(addName(tmpdir, mask)));
+ FileName tmp_name(mask);
+ string tmpfl;
+ if (tmp_name.d->fi.isAbsolute())
+ tmpfl = mask;
+ else
+ tmpfl = package().temp_dir().absFilename() + "/" + mask;
+
#if defined (HAVE_GETPID)
tmpfl += convert<string>(getpid());
#elif defined (HAVE__GETPID)
}
+FileName FileName::getcwd()
+{
+ return FileName(".");
+}
+
+
time_t FileName::lastModified() const
{
return d->fi.lastModified().toTime_t();
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)
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);
+ if (!isAbsolute())
+ FileName::set(makeAbsPath(name, buffer_path).absFilename());
zipped_valid_ = false;
}