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?
36 /// Do some work just once.
37 void init(int argc, char * argv[]);
39 /// Returns the name of the NULL device (/dev/null, null).
40 std::string const & nulldev();
42 /// Returns the name of the stdout device (/dev/stdout, /dev/tty, conout$).
43 std::string const & stdoutdev();
45 /// Returns the name of the stderr device (/dev/stderr, /dev/tty, conout$).
46 std::string const & stderrdev();
48 /// Tells whether \p channel is connected to a terminal or not.
49 bool is_terminal(io_channel channel);
51 /// Returns "/" on *nix, "C:/", etc on Windows.
52 std::string current_root();
57 /// Name of the python interpreter
58 std::string const python();
61 bool isFilesystemCaseSensitive();
63 /// Extract the path common to both @c p1 and @c p2. DBCS aware!
64 /// \p p1, \p p2 and the return value are encoded in utf8.
65 std::size_t common_path(docstring const & p1, docstring const & p2);
67 /// Converts a unix style path to host OS style.
68 /// \p p and the return value are encoded in utf8.
69 std::string external_path(std::string const & p);
71 /// Converts a host OS style path to unix style.
72 /// \p p and the return value are encoded in utf8.
73 std::string internal_path(std::string const & p);
75 /// Converts a unix style path list to host OS style.
76 /// \p p and the return value are encoded in utf8.
77 std::string external_path_list(std::string const & p);
79 /// Converts a host OS style path list to unix style.
80 /// \p p and the return value are encoded in utf8.
81 std::string internal_path_list(std::string const & p);
84 * Converts a unix style path into a form suitable for inclusion in a LaTeX
86 * \p p is encoded in utf8.
87 * Caution: This function handles only the OS specific part of that task.
88 * Never use it directly, use lyx::support::latex_path instead.
90 std::string latex_path(std::string const & p);
92 /// Checks if the format string is suitable on the OS
93 bool is_valid_strftime(std::string const & p);
95 /** Returns a string suitable to be passed to popen when
98 char const * popen_read_mode();
100 /** The character used to separate paths returned by the
101 * PATH environment variable.
103 char path_separator();
105 /** If @c use_windows_paths is true, LyX will output Windows-style paths to
106 * latex files rather than posix ones. Obviously, this option is used only
109 void windows_style_tex_paths(bool use_windows_paths);
111 enum auto_open_mode {
116 /** Check whether or not a file can be opened by a default viewer or editor.
117 * \param extension (without leading .)
118 * \param mode can be opened in VIEW or EDIT mode
119 * \returns whether or not the format can be opened according to \p mode
121 bool canAutoOpenFile(std::string const & ext, auto_open_mode const mode = VIEW);
123 /** View or edit a file with the default viewer or editor.
124 * \param filename file to open (encoded in utf8)
125 * \param mode open in VIEW or EDIT mode
126 * \returns whether or not the file is viewed (or edited) successfully.
128 bool autoOpenFile(std::string const & filename, auto_open_mode const mode = VIEW);
130 /** Resolves a path such that it does not contain '.', '..', or symbolic links.
131 * \warning the path must already be in the filesystem encoding.
132 * \returns the resolved path in utf8 encoding.
134 std::string real_path(std::string const & path);
137 } // namespace support