]> git.lyx.org Git - lyx.git/blobdiff - src/support/filename.C
hopefully fix tex2lyx linking.
[lyx.git] / src / support / filename.C
index ff6bd985233e47596fa083ab9c8f40ccd5bdbc14..63c15df3fec9f87b9a2a04174bb877a42fa8a59a 100644 (file)
@@ -31,45 +31,68 @@ namespace support {
 
 
 FileName::FileName()
-       : save_abs_path_(true)
 {}
 
 
-FileName::FileName(string const & abs_filename, bool save_abs)
-       : name_(abs_filename), save_abs_path_(save_abs)
+FileName::FileName(string const & abs_filename)
+       : name_(abs_filename)
 {
        BOOST_ASSERT(absolutePath(name_));
 }
 
 
-void FileName::set(string const & name, string const & buffer_path)
+bool operator==(FileName const & lhs, FileName const & rhs)
+{
+       return lhs.absFilename() == rhs.absFilename();
+}
+
+
+bool operator!=(FileName const & lhs, FileName const & rhs)
+{
+       return lhs.absFilename() != rhs.absFilename();
+}
+
+
+DocFileName::DocFileName()
+       : save_abs_path_(true)
+{}
+
+
+DocFileName::DocFileName(string const & abs_filename, bool save_abs)
+       : FileName(abs_filename), save_abs_path_(save_abs), zipped_valid_(false)
+{}
+
+
+void DocFileName::set(string const & name, string const & buffer_path)
 {
        save_abs_path_ = absolutePath(name);
        name_ = save_abs_path_ ? name : makeAbsPath(name, buffer_path);
+       zipped_valid_ = false;
 }
 
 
-void FileName::erase()
+void DocFileName::erase()
 {
        name_.erase();
+       zipped_valid_ = false;
 }
 
 
-string const FileName::relFilename(string const & path) const
+string const DocFileName::relFilename(string const & path) const
 {
        return makeRelPath(name_, path);
 }
 
 
-string const FileName::outputFilename(string const & path) const
+string const DocFileName::outputFilename(string const & path) const
 {
        return save_abs_path_ ? name_ : makeRelPath(name_, path);
 }
 
 
-string const FileName::mangledFilename(std::string const & dir) const
+string const DocFileName::mangledFilename(std::string const & dir) const
 {
-       // We need to make sure that every FileName instance for a given
+       // We need to make sure that every DocFileName instance for a given
        // filename returns the same mangled name.
        typedef map<string, string> MangledMap;
        static MangledMap mangledNames;
@@ -123,26 +146,30 @@ string const FileName::mangledFilename(std::string const & dir) const
 }
 
 
-bool FileName::isZipped() const
+bool DocFileName::isZipped() const
 {
-       return zippedFile(name_);
+       if (!zipped_valid_) {
+               zipped_ = zippedFile(name_);
+               zipped_valid_ = true;
+       }
+       return zipped_;
 }
 
 
-string const FileName::unzippedFilename() const
+string const DocFileName::unzippedFilename() const
 {
        return unzippedFileName(name_);
 }
 
 
-bool operator==(FileName const & lhs, FileName const & rhs)
+bool operator==(DocFileName const & lhs, DocFileName const & rhs)
 {
        return lhs.absFilename() == rhs.absFilename() &&
                lhs.saveAbsPath() == rhs.saveAbsPath();
 }
 
 
-bool operator!=(FileName const & lhs, FileName const & rhs)
+bool operator!=(DocFileName const & lhs, DocFileName const & rhs)
 {
        return !(lhs == rhs);
 }