3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * This file is part of LyX, the document processor.
9 * Licence details can be found in the file COPYING.
17 #include "filetools.h"
27 : save_abs_path_(true)
31 FileName::FileName(string const & abs_filename, bool save_abs)
32 : name_(abs_filename), save_abs_path_(save_abs)
34 Assert(AbsolutePath(name_));
38 void FileName::set(string const & name, string const & buffer_path)
40 save_abs_path_ = AbsolutePath(name);
41 name_ = save_abs_path_ ? name : MakeAbsPath(name, buffer_path);
45 void FileName::erase()
51 string const FileName::relFilename(string const & path) const
53 return MakeRelPath(name_, path);
57 string const FileName::outputFilename(string const & path) const
59 return save_abs_path_ ? name_ : MakeRelPath(name_, path);
63 string const FileName::mangledFilename() const
65 string mname = os::slashify_path(name_);
66 // Remove the extension.
67 mname = ChangeExtension(name_, string());
68 // Replace '/' in the file name with '_'
69 mname = subst(mname, "/", "_");
70 // Replace '.' in the file name with '_'
71 mname = subst(mname, ".", "_");
72 // Add the extension back on
73 return ChangeExtension(mname, GetExtension(name_));
77 bool FileName::isZipped() const
79 return zippedFile(name_);
83 string const FileName::unzippedFilename() const
85 return unzippedFileName(name_);
89 bool operator==(FileName const & lhs, FileName const & rhs)
91 return lhs.absFilename() == rhs.absFilename() &&
92 lhs.saveAbsPath() == rhs.saveAbsPath();
96 bool operator!=(FileName const & lhs, FileName const & rhs)
101 } // namespace support