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.
19 #include "support/FileName.h"
28 /** When run in-place <build-dir>/src/lyx is one level up from
29 * the <build-dir> whilst <build-dir>/src/tex2lyx/tex2lyx is
32 enum exe_build_dir_to_top_build_dir {
33 top_build_dir_is_one_level_up,
34 top_build_dir_is_two_levels_up
38 /** Initialise package() with the command line data.
39 * This data is exactly as it was passed in the argv[] array.
41 * @param command_line_arg0 argv[0], the name of the LyX executable
42 * as passed on the command line.
44 * @param command_line_system_support_dir, the LyX system dir,
45 * as specified on the command line with "-sysdir <path to dir>".
47 * @param command_line_user_support_dir, the LyX user dir,
48 * as specified on the command line with "-userdir <path to dir>".
50 void init_package(std::string const & command_line_arg0,
51 std::string const & command_line_system_support_dir,
52 std::string const & command_line_user_support_dir,
53 exe_build_dir_to_top_build_dir);
55 /** Accessor to the global data.
56 * Asserts that init_package() has been called first.
58 Package const & package();
62 /// Default constructor does not lead to the paths being set.
65 /** Called by init_package, above.
66 * All paths will be initialized.
68 Package(std::string const & command_line_arg0,
69 std::string const & command_line_system_support_dir,
70 std::string const & command_line_user_support_dir,
71 exe_build_dir_to_top_build_dir);
73 /** The directory containing the main executable (LyX or tex2lyx).
75 FileName const & binary_dir() const { return binary_dir_; }
77 /** The absolute path to the LyX executable.
79 FileName const & lyx_binary() const { return lyx_binary_; }
81 /** The absolute path to the LyX package directory.
82 * This is one level up from the binary dir.
84 FileName const & lyx_dir() const { return lyx_dir_; }
86 /** The top of the LyX source code tree.
88 static FileName const & top_srcdir();
90 /** The path to the system-level support files
91 * we're actually going to use.
93 FileName const & system_support() const { return system_support_dir_; }
95 /** The path to the autogenerated support files
96 * when running in-place.
98 FileName const & build_support() const { return build_support_dir_; }
100 /** The path to the user-level support files.
102 FileName const & user_support() const { return user_support_dir_; }
104 /** The user_support directory was set explicitly using either
105 * the -userdir command line switch or
106 * the LYX_USERDIR_${major}${minor}x environment variable.
108 bool explicit_user_support() const { return explicit_user_support_dir_; }
110 /** The path to the locale directory.
112 FileName const & locale_dir() const { return locale_dir_; }
114 /** The default document directory.
115 * Can be reset by LyXRC.
117 FileName & document_dir() const { return document_dir_; }
119 /** The path to the system temporary directory.
122 FileName const & system_temp_dir() const { return system_temp_dir_; }
125 /** The path to the temporary directory used by %LyX.
126 * (Eg /tmp/lyx_tmpdir800nBI1z9 on *nix.)
127 * Can be reset by LyXRC.
129 FileName const & temp_dir() const { return temp_dir_; }
130 void set_temp_dir(FileName const & temp_dir) const;
133 /** Used when setting the user_support directory.
134 * Used also when expanding "~/" or contracting to "~/". (filetools.cpp)
135 * Used in emergencyWrite (BufferList.cpp) as one possible location
137 * This may be empty (e. g. when run under a CGI environment)
139 FileName const & home_dir() const { return home_dir_; }
141 /** Command to run the configure script.
142 * Caution: This is "ready-to-run", i.e. in the locale encoding, not
145 std::string const & configure_command() const { return configure_command_; }
148 FileName binary_dir_;
149 FileName lyx_binary_;
151 FileName system_support_dir_;
152 FileName build_support_dir_;
153 FileName user_support_dir_;
154 FileName locale_dir_;
155 mutable FileName document_dir_;
156 mutable FileName temp_dir_;
157 FileName system_temp_dir_;
159 std::string configure_command_;
160 bool explicit_user_support_dir_;
163 } // namespace support