]> git.lyx.org Git - lyx.git/blob - src/support/filename.h
Remove executable status info from typeIndicator.
[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 <string>
16
17
18 namespace lyx {
19 namespace support {
20
21
22 class FileName {
23 public:
24         FileName();
25         /** \param abs_filename the file in question. Must have an absolute path.
26          *  \param save_abs_path how is the file to be output to file?
27          */
28         FileName(std::string const & abs_filename, bool save_abs_path = true);
29
30         /** \param filename the file in question. May have either a relative
31          *  or an absolute path.
32          *  \param buffer_path if \c filename has a relative path, generate
33          *  the absolute path using this.
34          */
35         void set(std::string const & filename, std::string const & buffer_path);
36
37         void erase();
38         bool empty() const { return name_.empty(); }
39
40         bool saveAbsPath() const { return save_abs_path_; }
41         std::string const absFilename() const { return name_; }
42         /// \param buffer_path if empty, uses `pwd`
43         std::string const relFilename(std::string const & buffer_path = std::string()) const;
44         /// \param buf_path if empty, uses `pwd`
45         std::string const outputFilename(std::string const & buf_path = std::string()) const;
46         /** \return a mangled version of the absolute file name,
47          *  suitable for use in the temp dir when, for example, converting
48          *  an image file to another format.
49          *  It is guaranteed that
50          *  - two different filenames have different mangled names
51          *  - two FileName instances with the same filename have identical
52          *    mangled names
53          */
54         std::string const mangledFilename() const;
55
56         /// \return true if the file is compressed.
57         bool isZipped() const;
58         /// \return the absolute file name without its .gz, .z, .Z extension
59         std::string const unzippedFilename() const;
60
61 private:
62         std::string name_;
63         bool save_abs_path_;
64 };
65
66
67 bool operator==(FileName const &, FileName const &);
68 bool operator!=(FileName const &, FileName const &);
69
70
71 } // namespace support
72 } // namespace lyx
73
74 #endif