1 | /**************************************************************************/ |
2 | /* os_unix.h */ |
3 | /**************************************************************************/ |
4 | /* This file is part of: */ |
5 | /* GODOT ENGINE */ |
6 | /* https://godotengine.org */ |
7 | /**************************************************************************/ |
8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
10 | /* */ |
11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
12 | /* a copy of this software and associated documentation files (the */ |
13 | /* "Software"), to deal in the Software without restriction, including */ |
14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
17 | /* the following conditions: */ |
18 | /* */ |
19 | /* The above copyright notice and this permission notice shall be */ |
20 | /* included in all copies or substantial portions of the Software. */ |
21 | /* */ |
22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
29 | /**************************************************************************/ |
30 | |
31 | #ifndef OS_UNIX_H |
32 | #define OS_UNIX_H |
33 | |
34 | #ifdef UNIX_ENABLED |
35 | |
36 | #include "core/os/os.h" |
37 | #include "drivers/unix/ip_unix.h" |
38 | |
39 | class OS_Unix : public OS { |
40 | protected: |
41 | // UNIX only handles the core functions. |
42 | // inheriting platforms under unix (eg. X11) should handle the rest |
43 | |
44 | virtual void initialize_core(); |
45 | virtual int unix_initialize_audio(int p_audio_driver); |
46 | |
47 | virtual void finalize_core() override; |
48 | |
49 | public: |
50 | OS_Unix(); |
51 | |
52 | virtual Vector<String> get_video_adapter_driver_info() const override; |
53 | |
54 | virtual String get_stdin_string() override; |
55 | |
56 | virtual Error get_entropy(uint8_t *r_buffer, int p_bytes) override; |
57 | |
58 | virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false, String *r_resolved_path = nullptr) override; |
59 | virtual Error close_dynamic_library(void *p_library_handle) override; |
60 | virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false) override; |
61 | |
62 | virtual Error set_cwd(const String &p_cwd) override; |
63 | |
64 | virtual String get_name() const override; |
65 | virtual String get_distribution_name() const override; |
66 | virtual String get_version() const override; |
67 | |
68 | virtual DateTime get_datetime(bool p_utc) const override; |
69 | virtual TimeZoneInfo get_time_zone_info() const override; |
70 | |
71 | virtual double get_unix_time() const override; |
72 | |
73 | virtual void delay_usec(uint32_t p_usec) const override; |
74 | virtual uint64_t get_ticks_usec() const override; |
75 | |
76 | virtual Dictionary get_memory_info() const override; |
77 | |
78 | virtual Error execute(const String &p_path, const List<String> &p_arguments, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr, bool p_open_console = false) override; |
79 | virtual Error create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id = nullptr, bool p_open_console = false) override; |
80 | virtual Error kill(const ProcessID &p_pid) override; |
81 | virtual int get_process_id() const override; |
82 | virtual bool is_process_running(const ProcessID &p_pid) const override; |
83 | |
84 | virtual bool has_environment(const String &p_var) const override; |
85 | virtual String get_environment(const String &p_var) const override; |
86 | virtual void set_environment(const String &p_var, const String &p_value) const override; |
87 | virtual void unset_environment(const String &p_var) const override; |
88 | |
89 | virtual String get_locale() const override; |
90 | |
91 | virtual void initialize_debugging() override; |
92 | |
93 | virtual String get_executable_path() const override; |
94 | virtual String get_user_data_dir() const override; |
95 | }; |
96 | |
97 | class UnixTerminalLogger : public StdLogger { |
98 | public: |
99 | virtual void log_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, bool p_editor_notify = false, ErrorType p_type = ERR_ERROR) override; |
100 | virtual ~UnixTerminalLogger(); |
101 | }; |
102 | |
103 | #endif // UNIX_ENABLED |
104 | |
105 | #endif // OS_UNIX_H |
106 | |