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?
30 /// Do some work just once.
31 void init(int argc, char * argv[]);
33 /// Returns the name of the NULL device (/dev/null, null).
34 std::string const & nulldev();
36 /// Returns "/" on *nix, "C:/", etc on Windows.
37 std::string current_root();
42 /// Name of the python interpreter
43 std::string const python();
46 bool isFilesystemCaseSensitive();
48 /// Extract the path common to both @c p1 and @c p2. DBCS aware!
49 /// \p p1, \p p2 and the return value are encoded in utf8.
50 std::size_t common_path(docstring const & p1, docstring const & p2);
52 /// Converts a unix style path to host OS style.
53 /// \p p and the return value are encoded in utf8.
54 std::string external_path(std::string const & p);
56 /// Converts a host OS style path to unix style.
57 /// \p p and the return value are encoded in utf8.
58 std::string internal_path(std::string const & p);
60 /// Converts a unix style path list to host OS style.
61 /// \p p and the return value are encoded in utf8.
62 std::string external_path_list(std::string const & p);
64 /// Converts a host OS style path list to unix style.
65 /// \p p and the return value are encoded in utf8.
66 std::string internal_path_list(std::string const & p);
69 * Converts a unix style path into a form suitable for inclusion in a LaTeX
71 * \p p is encoded in utf8.
72 * Caution: This function handles only the OS specific part of that task.
73 * Never use it directly, use lyx::support::latex_path instead.
75 std::string latex_path(std::string const & p);
77 /// Checks if the format string is suitable on the OS
78 bool is_valid_strftime(std::string const & p);
80 /** Returns a string suitable to be passed to popen when
83 char const * popen_read_mode();
85 /** The character used to separate paths returned by the
86 * PATH environment variable.
88 char path_separator();
90 /** If @c use_windows_paths is true, LyX will output Windows-style paths to
91 * latex files rather than posix ones. Obviously, this option is used only
94 void windows_style_tex_paths(bool use_windows_paths);
101 /** Check whether or not a file can be opened by a default viewer or editor.
102 * \param extension (without leading .)
103 * \param mode can be opened in VIEW or EDIT mode
104 * \returns whether or not the format can be opened according to \p mode
106 bool canAutoOpenFile(std::string const & ext, auto_open_mode const mode = VIEW);
108 /** View or edit a file with the default viewer or editor.
109 * \param filename file to open (encoded in utf8)
110 * \param mode open in VIEW or EDIT mode
111 * \returns whether or not the file is viewed (or edited) successfully.
113 bool autoOpenFile(std::string const & filename, auto_open_mode const mode = VIEW);
115 /** Check whether two filenames point to the same file.
116 * \warning the filenames must already be in the filesystem encoding.
118 bool isSameFile(std::string const & fileone, std::string const & filetwo);
120 /** Resolves a path such that it does not contain '.', '..', or symbolic links.
121 * \warning the path must already be in the filesystem encoding.
122 * \returns the resolved path in utf8 encoding.
124 std::string real_path(std::string const & path);
127 } // namespace support