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.
15 #include "support/filetools.h"
25 : save_abs_path_(true)
29 FileName::FileName(string const & abs_filename, bool save_abs)
30 : name_(abs_filename), save_abs_path_(save_abs)
32 Assert(AbsolutePath(name_));
36 void FileName::set(string const & name, string const & buffer_path)
38 save_abs_path_ = AbsolutePath(name);
39 name_ = save_abs_path_ ? name : MakeAbsPath(name, buffer_path);
43 void FileName::erase()
49 string const FileName::relFilename(string const & path) const
51 return MakeRelPath(name_, path);
55 string const FileName::outputFilename(string const & path) const
57 return save_abs_path_ ? name_ : MakeRelPath(name_, path);
61 string const FileName::mangledFilename() const
63 string mname = os::slashify_path(name_);
64 // Remove the extension.
65 mname = ChangeExtension(name_, string());
66 // Replace '/' in the file name with '_'
67 mname = subst(mname, "/", "_");
68 // Replace '.' in the file name with '_'
69 mname = subst(mname, ".", "_");
70 // Add the extension back on
71 return ChangeExtension(mname, GetExtension(name_));
75 bool FileName::isZipped() const
77 return zippedFile(name_);
81 string const FileName::unzippedFilename() const
83 return unzippedFileName(name_);
87 bool operator==(FileName const & lhs, FileName const & rhs)
89 return lhs.absFilename() == rhs.absFilename() &&
90 lhs.saveAbsPath() == rhs.saveAbsPath();
94 bool operator!=(FileName const & lhs, FileName const & rhs)
99 } // namespace support