4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS.
11 * A store of the paths to the various different directoies used
12 * by LyX. These paths differ markedly from one OS to another,
13 * following the local Windows, MacOS X or Posix conventions.
18 #include "support/FileName.h"
27 /** When run in-place <build-dir>/src/lyx is one level up from
28 * the <build-dir> whilst <build-dir>/src/tex2lyx/tex2lyx is
31 enum exe_build_dir_to_top_build_dir {
32 top_build_dir_is_one_level_up,
33 top_build_dir_is_two_levels_up
37 /** Initialise package() with the command line data.
38 * This data is exactly as it was passed in the argv[] array.
40 * @param command_line_arg0 argv[0], the name of the LyX executable
41 * as passed on the command line.
43 * @param command_line_system_support_dir, the LyX system dir,
44 * as specified on the command line with "-sysdir <path to dir>".
46 * @param command_line_user_support_dir, the LyX user dir,
47 * as specified on the command line with "-userdir <path to dir>".
49 void init_package(std::string const & command_line_arg0,
50 std::string const & command_line_system_support_dir,
51 std::string const & command_line_user_support_dir,
52 exe_build_dir_to_top_build_dir);
54 /** Accessor to the global data.
55 * Asserts that init_package() has been called first.
57 Package const & package();
61 /// Default constructor does not lead to the paths being set.
64 /** Called by init_package, above.
65 * All paths will be initialized.
67 Package(std::string const & command_line_arg0,
68 std::string const & command_line_system_support_dir,
69 std::string const & command_line_user_support_dir,
70 exe_build_dir_to_top_build_dir);
72 /** The directory containing the LyX executable.
74 FileName const & binary_dir() const;
76 /** The top of the LyX source code tree.
78 static FileName const & top_srcdir();
80 /** The path to the system-level support files
81 * we're actually going to use.
83 FileName const & system_support() const;
85 /** The path to the autogenerated support files
86 * when running in-place.
88 FileName const & build_support() const;
90 /** The path to the user-level support files.
92 FileName const & user_support() const;
94 /** The user_support directory was set explicitly using either
95 * the -userdir command line switch or
96 * the LYX_USERDIR_15x environment variable.
98 bool explicit_user_support() const;
100 /** The path to the locale directory.
102 FileName const & locale_dir() const;
104 /** The default document directory.
105 * Can be reset by LyXRC.
107 FileName & document_dir() const;
109 /** The path to the system temporary directory.
112 FileName const & system_temp_dir() const;
114 /** The path to the temporary directory used by LyX.
115 * (Eg /tmp/lyx_tmpdir800nBI1z9 on *nix.)
116 * Can be reset by LyXRC.
118 FileName & temp_dir() const;
120 /** Used when setting the user_support directory.
121 * Used also when expanding "~/" or contracting to "~/". (filetools.cpp)
122 * Used in emergencyWrite (BufferList.cpp) as one possible location
124 * This may be empty (e. g. when run under a CGI environment)
126 FileName const & home_dir() const;
128 /** Command to run the configure script.
129 * Caution: This is "ready-to-run", i.e. in the locale encoding, not
132 std::string const & configure_command() const;
135 FileName binary_dir_;
136 FileName system_support_dir_;
137 FileName build_support_dir_;
138 FileName user_support_dir_;
139 FileName locale_dir_;
140 mutable FileName document_dir_;
141 mutable FileName temp_dir_;
142 FileName system_temp_dir_;
144 std::string configure_command_;
145 bool explicit_user_support_dir_;
150 Package::Package() {}
153 FileName const & Package::binary_dir() const
159 FileName const & Package::system_support() const
161 return system_support_dir_;
165 FileName const & Package::build_support() const
167 return build_support_dir_;
171 FileName const & Package::user_support() const
173 return user_support_dir_;
177 bool Package::explicit_user_support() const
179 return explicit_user_support_dir_;
183 FileName const & Package::locale_dir() const
189 FileName & Package::document_dir() const
191 return document_dir_;
195 FileName & Package::temp_dir() const
201 FileName const & Package::system_temp_dir() const
203 return system_temp_dir_;
207 FileName const & Package::home_dir() const
213 std::string const & Package::configure_command() const
215 return configure_command_;
218 } // namespace support
221 #endif // LYX_PACHAGE_H