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?
41 /// Do some work just once.
42 void init(int argc, char * argv[]);
44 /// Returns the name of the NULL device (/dev/null, null).
45 std::string const & nulldev();
47 /// Tells whether \p channel is connected to a terminal or not.
48 bool is_terminal(io_channel channel);
50 /// Returns "/" on *nix, "C:/", etc on Windows.
51 std::string current_root();
56 /// Name of the python interpreter
57 std::string const python();
60 bool isFilesystemCaseSensitive();
62 /// Extract the path common to both @c p1 and @c p2. DBCS aware!
63 /// \p p1 and \p p2 are encoded in ucs4, \returns the index to the end of
64 /// the last matching path component (the index may be pointing after the
65 /// end of @c p1 or @c p2 if their last char is not the path separator).
66 std::size_t common_path(docstring const & p1, docstring const & p2);
68 /// Converts a unix style path to host OS style.
69 /// \p p and the return value are encoded in utf8.
70 std::string external_path(std::string const & p);
72 /// Converts a host OS style path to unix style.
73 /// \p p and the return value are encoded in utf8.
74 std::string internal_path(std::string const & p);
76 /// Converts a unix style path list to host OS style.
77 /// \p p and the return value are encoded in utf8.
78 std::string external_path_list(std::string const & p);
80 /// Converts a host OS style path list to unix style.
81 /// \p p and the return value are encoded in utf8.
82 std::string internal_path_list(std::string const & p);
85 * Converts a unix style path into a form suitable for inclusion in a LaTeX
87 * \p p is encoded in utf8.
88 * Caution: This function handles only the OS specific part of that task.
89 * Never use it directly, use lyx::support::latex_path instead.
91 std::string latex_path(std::string const & p);
93 /// Checks if the format string is suitable on the OS
94 bool is_valid_strftime(std::string const & p);
96 /** Returns a string suitable to be passed to popen when
99 char const * popen_read_mode();
101 /** The character used to separate paths returned by the
102 * PATH environment variable.
104 char path_separator();
106 /** If @c use_windows_paths is true, LyX will output Windows-style paths to
107 * latex files rather than posix ones. Obviously, this option is used only
110 void windows_style_tex_paths(bool use_windows_paths);
112 enum auto_open_mode {
117 /** Check whether or not a file can be opened by a default viewer or editor.
118 * \param extension (without leading .)
119 * \param mode can be opened in VIEW or EDIT mode
120 * \returns whether or not the format can be opened according to \p mode
122 bool canAutoOpenFile(std::string const & ext, auto_open_mode const mode = VIEW);
124 /** View or edit a file with the default viewer or editor.
125 * \param filename file to open (encoded in utf8)
126 * \param mode open in VIEW or EDIT mode
127 * \returns whether or not the file is viewed (or edited) successfully.
129 bool autoOpenFile(std::string const & filename, auto_open_mode const mode = VIEW);
131 /** Resolves a path such that it does not contain '.', '..', or symbolic links.
132 * \warning the path must already be in the filesystem encoding.
133 * \returns the resolved path in utf8 encoding.
135 std::string real_path(std::string const & path);
137 /** Checks whether \param path starts with \param pre, accounting for case
138 * insensitive file systems.
140 bool path_prefix_is(std::string const & path, std::string const & pre);
142 /** Checks whether \param path starts with \param pre, accounting for case
143 * insensitive file systems. If true, the file system is case insensitive,
144 * and \param how == CASE_ADJUSTED, the case of the matching prefix in
145 * @c path is made equal to that of @c pre.
147 bool path_prefix_is(std::string & path, std::string const & pre, path_case how = CASE_UNCHANGED);
150 } // namespace support