]> git.lyx.org Git - lyx.git/blob - src/support/filename.h
If I ever see another licence blurb again, it'll be too soon...
[lyx.git] / src / support / filename.h
1 // -*- C++ -*-
2 /**
3  * \file filename.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef FILENAME_H
13 #define FILENAME_H
14
15 #include "LString.h"
16
17
18 namespace lyx {
19 namespace support {
20
21
22 class FileName {
23 public:
24         FileName();
25
26         /** \param filename the file in question. May have either a relative
27             or an absolute path.
28             \param buffer_path if \c filename has a relative path, generate
29             the absolute path using this.
30          */
31         void set(string const & filename, string const & buffer_path);
32
33         void erase();
34         bool empty() const { return name_.empty(); }
35
36         bool saveAbsPath() const { return save_abs_path_; }
37         string const absFilename() const { return name_; }
38         /// \param buffer_path if empty, uses `pwd`
39         string const relFilename(string const & buffer_path = string()) const;
40         /// \param buf_path if empty, uses `pwd`
41         string const outputFilename(string const & buf_path = string()) const;
42
43 private:
44         string name_;
45         bool save_abs_path_;
46 };
47
48
49 bool operator==(FileName const &, FileName const &);
50 bool operator!=(FileName const &, FileName const &);
51
52
53 } // namespace support
54 } // namespace lyx
55
56 #endif