]> git.lyx.org Git - lyx.git/blob - src/support/os.h
zipunzip.cpp: Replace makedir etc with versions in support::FileName, fix a bug in...
[lyx.git] / src / support / os.h
1 // -*- C++ -*-
2 /**
3  * \file os.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Ruurd A. Reitsma
8  *
9  * Full author contact details are available in file CREDITS.
10  *
11  * wrap OS-specific stuff
12  */
13
14 #ifndef OS_H
15 #define OS_H
16
17 #include "support/strfwd.h"
18 #include <cstddef>
19
20
21 namespace lyx {
22 namespace support {
23 namespace os {
24
25 enum shell_type {
26         UNIX,   // Do we have to distinguish sh and csh?
27         CMD_EXE
28 };
29
30 /// Do some work just once.
31 void init(int argc, char * argv[]);
32
33 /// Returns the name of the NULL device (/dev/null, null).
34 std::string const & nulldev();
35
36 /// Returns "/" on *nix, "C:/", etc on Windows.
37 std::string current_root();
38
39 ///
40 shell_type shell();
41
42 /// Name of the python interpreter
43 std::string const python();
44
45 /// Extract the path common to both @c p1 and @c p2. DBCS aware!
46 /// \p p1, \p p2 and the return value are encoded in utf8.
47 std::size_t common_path(docstring const & p1, docstring const & p2);
48
49 /// Converts a unix style path to host OS style.
50 /// \p p and the return value are encoded in utf8.
51 std::string external_path(std::string const & p);
52
53 /// Converts a host OS style path to unix style.
54 /// \p p and the return value are encoded in utf8.
55 std::string internal_path(std::string const & p);
56
57 /// Converts a unix style path list to host OS style.
58 /// \p p and the return value are encoded in utf8.
59 std::string external_path_list(std::string const & p);
60
61 /// Converts a host OS style path list to unix style.
62 /// \p p and the return value are encoded in utf8.
63 std::string internal_path_list(std::string const & p);
64
65 /**
66  * Converts a unix style path into a form suitable for inclusion in a LaTeX
67  * document.
68  * \p p is encoded in utf8.
69  * Caution: This function handles only the OS specific part of that task.
70  * Never use it directly, use lyx::support::latex_path instead.
71  */
72 std::string latex_path(std::string const & p);
73
74 /** Returns a string suitable to be passed to popen when
75  *  reading a file.
76  */
77 char const * popen_read_mode();
78
79 /** The character used to separate paths returned by the
80  *  PATH environment variable.
81  */
82 char path_separator();
83
84 /** If @c use_windows_paths is true, LyX will output Windows-style paths to
85  *  latex files rather than posix ones. Obviously, this option is used only
86  *  under Windows.
87  */
88 void windows_style_tex_paths(bool use_windows_paths);
89
90 enum auto_open_mode {
91         VIEW,
92         EDIT
93 };
94
95 /** Check whether or not a file can be opened by a default viewer or editor.
96  *  \param extension (without leading .)
97  *  \param mode can be opened in VIEW or EDIT mode
98  *  \returns whether or not the format can be opened according to \p mode
99  */
100 bool canAutoOpenFile(std::string const & ext, auto_open_mode const mode = VIEW);
101
102 /** View or edit a file with the default viewer or editor.
103  *  \param filename file to open (encoded in utf8)
104  *  \param mode open in VIEW or EDIT mode
105  *  \returns whether or not the file is viewed (or edited) successfully.
106  */
107 bool autoOpenFile(std::string const & filename, auto_open_mode const mode = VIEW);
108
109 } // namespace os
110 } // namespace support
111 } // namespace lyx
112
113 #endif