4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Ruurd A. Reitsma
9 * Full author contact details are available in file CREDITS.
11 * wrap OS-specific stuff
17 #include "support/strfwd.h"
26 UNIX, // Do we have to distinguish sh and csh?
40 /// Do some work just once.
41 void init(int argc, char * argv[]);
43 /// Returns the i-th program argument in utf8 encoding.
44 std::string utf8_argv(int i);
46 /// Removes from the internal copy \p num program arguments starting from \p i.
47 void remove_internal_args(int i, int num);
49 /// Returns the name of the NULL device (/dev/null, null).
50 std::string const & nulldev();
52 /// Returns "/" on *nix, "C:/", etc on Windows.
53 std::string current_root();
58 /// Returns no. of minutes allowed for a command to complete.
61 /// Name of the python interpreter
62 std::string const python();
65 bool isFilesystemCaseSensitive();
67 /// Extract the path common to both @c p1 and @c p2. DBCS aware!
68 /// \p p1 and \p p2 are encoded in ucs4, \returns the index to the end of
69 /// the last matching path component (the index may be pointing after the
70 /// end of @c p1 or @c p2 if their last char is not the path separator).
71 std::size_t common_path(docstring const & p1, docstring const & p2);
73 /// Converts a unix style path to host OS style.
74 /// \p p and the return value are encoded in utf8.
75 std::string external_path(std::string const & p);
77 /// Converts a host OS style path to unix style.
78 /// \p p and the return value are encoded in utf8.
79 std::string internal_path(std::string const & p);
81 /// Converts a host OS style path to a unicode safe unix style.
82 /// On Windows, this is achieved by using the short form of the path,
83 /// which can be safely passed to standard I/O functions expecting narrow
84 /// char paths even when the path contains non-ascii chars.
85 /// As the short form is only available for existing files, if the file is
86 /// to be accessed for writing, \param how should be set to CREATE.
87 /// \p p and the return value are encoded in utf8.
88 std::string safe_internal_path(std::string const & p, file_access how = EXISTING);
90 /// Converts a unix style path list to host OS style.
91 /// \p p and the return value are encoded in utf8.
92 std::string external_path_list(std::string const & p);
94 /// Converts a host OS style path list to unix style.
95 /// \p p and the return value are encoded in utf8.
96 std::string internal_path_list(std::string const & p);
99 * Converts a unix style path into a form suitable for inclusion in a LaTeX
101 * \p p is encoded in utf8.
102 * Caution: This function handles only the OS specific part of that task.
103 * Never use it directly, use lyx::support::latex_path instead.
105 std::string latex_path(std::string const & p);
108 * Converts a platform style path list into a form suitable for the TeX engine.
109 * \p p is encoded in utf8.
111 std::string latex_path_list(std::string const & p);
113 /// Checks if the format string is suitable on the OS
114 bool is_valid_strftime(std::string const & p);
116 /** Returns a string suitable to be passed to popen when
119 char const * popen_read_mode();
126 /** The character used to separate paths for platform environment variables
127 * (such as PATH) or for the TeX engine.
129 char path_separator(path_type type = PLATFORM);
131 /** If @c use_windows_paths is true, LyX will output Windows-style paths to
132 * latex files rather than posix ones. Obviously, this option is used only
135 void windows_style_tex_paths(bool use_windows_paths);
137 enum auto_open_mode {
142 /** Check whether or not a file can be opened by a default viewer or editor.
143 * \param extension (without leading .)
144 * \param mode can be opened in VIEW or EDIT mode
145 * \returns whether or not the format can be opened according to \p mode
147 bool canAutoOpenFile(std::string const & ext, auto_open_mode const mode);
149 /** View or edit a file with the default viewer or editor.
150 * \param filename file to open (encoded in utf8)
151 * \param mode open in VIEW or EDIT mode
152 * \returns whether or not the file is viewed (or edited) successfully.
154 bool autoOpenFile(std::string const & filename, auto_open_mode const mode,
155 std::string const & path = empty_string());
157 /** Resolves a path such that it does not contain '.', '..', or symbolic links.
158 * \p path and the return value are encoded in utf8.
160 std::string real_path(std::string const & path);
162 /** Checks whether \param path starts with \param pre, accounting for case
163 * insensitive file systems.
165 bool path_prefix_is(std::string const & path, std::string const & pre);
167 /** Checks whether \param path starts with \param pre, accounting for case
168 * insensitive file systems. If true, the file system is case insensitive,
169 * and \param how == CASE_ADJUSTED, the case of the matching prefix in
170 * @c path is made equal to that of @c pre.
172 bool path_prefix_is(std::string & path, std::string const & pre, path_case how = CASE_UNCHANGED);
175 } // namespace support