]> git.lyx.org Git - features.git/blob - src/support/filename.h
Replace LString.h with support/std_string.h,
[features.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 "support/std_string.h"
16
17
18 namespace lyx {
19 namespace support {
20
21
22 class FileName {
23 public:
24         FileName();
25         /** \param 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(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(string const & filename, 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         string const absFilename() const { return name_; }
42         /// \param buffer_path if empty, uses `pwd`
43         string const relFilename(string const & buffer_path = string()) const;
44         /// \param buf_path if empty, uses `pwd`
45         string const outputFilename(string const & buf_path = 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          */
50         string const mangledFilename() const;
51
52         /// \return true if the file is compressed.
53         bool isZipped() const;
54         /// \return the absolute file name without its .gz, .z, .Z extension
55         string const unzippedFilename() const;
56
57 private:
58         string name_;
59         bool save_abs_path_;
60 };
61
62
63 bool operator==(FileName const &, FileName const &);
64 bool operator!=(FileName const &, FileName const &);
65
66
67 } // namespace support
68 } // namespace lyx
69
70 #endif