class_os.rst 132 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/OS.xml.
  6. .. _class_OS:
  7. OS
  8. ==
  9. **Inherits:** :ref:`Object<class_Object>`
  10. Provides access to common operating system functionalities.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. The **OS** class wraps the most common functionalities for communicating with the host operating system, such as the video driver, delays, environment variables, execution of binaries, command line, etc.
  15. \ **Note:** In Godot 4, **OS** functions related to window management, clipboard, and TTS were moved to the :ref:`DisplayServer<class_DisplayServer>` singleton (and the :ref:`Window<class_Window>` class). Functions related to time were removed and are only available in the :ref:`Time<class_Time>` class.
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - `Operating System Testing Demo <https://godotengine.org/asset-library/asset/2789>`__
  20. .. rst-class:: classref-reftable-group
  21. Properties
  22. ----------
  23. .. table::
  24. :widths: auto
  25. +-------------------------+---------------------------------------------------------------------------------------------------+-----------+
  26. | :ref:`bool<class_bool>` | :ref:`delta_smoothing<class_OS_property_delta_smoothing>` | ``true`` |
  27. +-------------------------+---------------------------------------------------------------------------------------------------+-----------+
  28. | :ref:`bool<class_bool>` | :ref:`low_processor_usage_mode<class_OS_property_low_processor_usage_mode>` | ``false`` |
  29. +-------------------------+---------------------------------------------------------------------------------------------------+-----------+
  30. | :ref:`int<class_int>` | :ref:`low_processor_usage_mode_sleep_usec<class_OS_property_low_processor_usage_mode_sleep_usec>` | ``6900`` |
  31. +-------------------------+---------------------------------------------------------------------------------------------------+-----------+
  32. .. rst-class:: classref-reftable-group
  33. Methods
  34. -------
  35. .. table::
  36. :widths: auto
  37. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | |void| | :ref:`alert<class_OS_method_alert>`\ (\ text\: :ref:`String<class_String>`, title\: :ref:`String<class_String>` = "Alert!"\ ) |
  39. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | |void| | :ref:`close_midi_inputs<class_OS_method_close_midi_inputs>`\ (\ ) |
  41. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | |void| | :ref:`crash<class_OS_method_crash>`\ (\ message\: :ref:`String<class_String>`\ ) |
  43. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`int<class_int>` | :ref:`create_instance<class_OS_method_create_instance>`\ (\ arguments\: :ref:`PackedStringArray<class_PackedStringArray>`\ ) |
  45. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`int<class_int>` | :ref:`create_process<class_OS_method_create_process>`\ (\ path\: :ref:`String<class_String>`, arguments\: :ref:`PackedStringArray<class_PackedStringArray>`, open_console\: :ref:`bool<class_bool>` = false\ ) |
  47. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | |void| | :ref:`delay_msec<class_OS_method_delay_msec>`\ (\ msec\: :ref:`int<class_int>`\ ) |const| |
  49. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | |void| | :ref:`delay_usec<class_OS_method_delay_usec>`\ (\ usec\: :ref:`int<class_int>`\ ) |const| |
  51. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`int<class_int>` | :ref:`execute<class_OS_method_execute>`\ (\ path\: :ref:`String<class_String>`, arguments\: :ref:`PackedStringArray<class_PackedStringArray>`, output\: :ref:`Array<class_Array>` = [], read_stderr\: :ref:`bool<class_bool>` = false, open_console\: :ref:`bool<class_bool>` = false\ ) |
  53. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`Dictionary<class_Dictionary>` | :ref:`execute_with_pipe<class_OS_method_execute_with_pipe>`\ (\ path\: :ref:`String<class_String>`, arguments\: :ref:`PackedStringArray<class_PackedStringArray>`, blocking\: :ref:`bool<class_bool>` = true\ ) |
  55. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`Key<enum_@GlobalScope_Key>` | :ref:`find_keycode_from_string<class_OS_method_find_keycode_from_string>`\ (\ string\: :ref:`String<class_String>`\ ) |const| |
  57. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`String<class_String>` | :ref:`get_cache_dir<class_OS_method_get_cache_dir>`\ (\ ) |const| |
  59. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_cmdline_args<class_OS_method_get_cmdline_args>`\ (\ ) |
  61. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_cmdline_user_args<class_OS_method_get_cmdline_user_args>`\ (\ ) |
  63. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`String<class_String>` | :ref:`get_config_dir<class_OS_method_get_config_dir>`\ (\ ) |const| |
  65. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_connected_midi_inputs<class_OS_method_get_connected_midi_inputs>`\ (\ ) |
  67. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`String<class_String>` | :ref:`get_data_dir<class_OS_method_get_data_dir>`\ (\ ) |const| |
  69. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`String<class_String>` | :ref:`get_distribution_name<class_OS_method_get_distribution_name>`\ (\ ) |const| |
  71. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`get_entropy<class_OS_method_get_entropy>`\ (\ size\: :ref:`int<class_int>`\ ) |
  73. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`String<class_String>` | :ref:`get_environment<class_OS_method_get_environment>`\ (\ variable\: :ref:`String<class_String>`\ ) |const| |
  75. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`String<class_String>` | :ref:`get_executable_path<class_OS_method_get_executable_path>`\ (\ ) |const| |
  77. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_granted_permissions<class_OS_method_get_granted_permissions>`\ (\ ) |const| |
  79. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`String<class_String>` | :ref:`get_keycode_string<class_OS_method_get_keycode_string>`\ (\ code\: :ref:`Key<enum_@GlobalScope_Key>`\ ) |const| |
  81. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`String<class_String>` | :ref:`get_locale<class_OS_method_get_locale>`\ (\ ) |const| |
  83. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`String<class_String>` | :ref:`get_locale_language<class_OS_method_get_locale_language>`\ (\ ) |const| |
  85. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`int<class_int>` | :ref:`get_main_thread_id<class_OS_method_get_main_thread_id>`\ (\ ) |const| |
  87. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`Dictionary<class_Dictionary>` | :ref:`get_memory_info<class_OS_method_get_memory_info>`\ (\ ) |const| |
  89. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | :ref:`String<class_String>` | :ref:`get_model_name<class_OS_method_get_model_name>`\ (\ ) |const| |
  91. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | :ref:`String<class_String>` | :ref:`get_name<class_OS_method_get_name>`\ (\ ) |const| |
  93. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`int<class_int>` | :ref:`get_process_exit_code<class_OS_method_get_process_exit_code>`\ (\ pid\: :ref:`int<class_int>`\ ) |const| |
  95. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`int<class_int>` | :ref:`get_process_id<class_OS_method_get_process_id>`\ (\ ) |const| |
  97. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`int<class_int>` | :ref:`get_processor_count<class_OS_method_get_processor_count>`\ (\ ) |const| |
  99. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`String<class_String>` | :ref:`get_processor_name<class_OS_method_get_processor_name>`\ (\ ) |const| |
  101. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_restart_on_exit_arguments<class_OS_method_get_restart_on_exit_arguments>`\ (\ ) |const| |
  103. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`int<class_int>` | :ref:`get_static_memory_peak_usage<class_OS_method_get_static_memory_peak_usage>`\ (\ ) |const| |
  105. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`int<class_int>` | :ref:`get_static_memory_usage<class_OS_method_get_static_memory_usage>`\ (\ ) |const| |
  107. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`StdHandleType<enum_OS_StdHandleType>` | :ref:`get_stderr_type<class_OS_method_get_stderr_type>`\ (\ ) |const| |
  109. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`StdHandleType<enum_OS_StdHandleType>` | :ref:`get_stdin_type<class_OS_method_get_stdin_type>`\ (\ ) |const| |
  111. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`StdHandleType<enum_OS_StdHandleType>` | :ref:`get_stdout_type<class_OS_method_get_stdout_type>`\ (\ ) |const| |
  113. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`String<class_String>` | :ref:`get_system_ca_certificates<class_OS_method_get_system_ca_certificates>`\ (\ ) |
  115. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | :ref:`String<class_String>` | :ref:`get_system_dir<class_OS_method_get_system_dir>`\ (\ dir\: :ref:`SystemDir<enum_OS_SystemDir>`, shared_storage\: :ref:`bool<class_bool>` = true\ ) |const| |
  117. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`String<class_String>` | :ref:`get_system_font_path<class_OS_method_get_system_font_path>`\ (\ font_name\: :ref:`String<class_String>`, weight\: :ref:`int<class_int>` = 400, stretch\: :ref:`int<class_int>` = 100, italic\: :ref:`bool<class_bool>` = false\ ) |const| |
  119. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_system_font_path_for_text<class_OS_method_get_system_font_path_for_text>`\ (\ font_name\: :ref:`String<class_String>`, text\: :ref:`String<class_String>`, locale\: :ref:`String<class_String>` = "", script\: :ref:`String<class_String>` = "", weight\: :ref:`int<class_int>` = 400, stretch\: :ref:`int<class_int>` = 100, italic\: :ref:`bool<class_bool>` = false\ ) |const| |
  121. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_system_fonts<class_OS_method_get_system_fonts>`\ (\ ) |const| |
  123. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | :ref:`int<class_int>` | :ref:`get_thread_caller_id<class_OS_method_get_thread_caller_id>`\ (\ ) |const| |
  125. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | :ref:`String<class_String>` | :ref:`get_unique_id<class_OS_method_get_unique_id>`\ (\ ) |const| |
  127. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | :ref:`String<class_String>` | :ref:`get_user_data_dir<class_OS_method_get_user_data_dir>`\ (\ ) |const| |
  129. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | :ref:`String<class_String>` | :ref:`get_version<class_OS_method_get_version>`\ (\ ) |const| |
  131. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_video_adapter_driver_info<class_OS_method_get_video_adapter_driver_info>`\ (\ ) |const| |
  133. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. | :ref:`bool<class_bool>` | :ref:`has_environment<class_OS_method_has_environment>`\ (\ variable\: :ref:`String<class_String>`\ ) |const| |
  135. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  136. | :ref:`bool<class_bool>` | :ref:`has_feature<class_OS_method_has_feature>`\ (\ tag_name\: :ref:`String<class_String>`\ ) |const| |
  137. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  138. | :ref:`bool<class_bool>` | :ref:`is_debug_build<class_OS_method_is_debug_build>`\ (\ ) |const| |
  139. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  140. | :ref:`bool<class_bool>` | :ref:`is_keycode_unicode<class_OS_method_is_keycode_unicode>`\ (\ code\: :ref:`int<class_int>`\ ) |const| |
  141. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  142. | :ref:`bool<class_bool>` | :ref:`is_process_running<class_OS_method_is_process_running>`\ (\ pid\: :ref:`int<class_int>`\ ) |const| |
  143. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  144. | :ref:`bool<class_bool>` | :ref:`is_restart_on_exit_set<class_OS_method_is_restart_on_exit_set>`\ (\ ) |const| |
  145. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  146. | :ref:`bool<class_bool>` | :ref:`is_sandboxed<class_OS_method_is_sandboxed>`\ (\ ) |const| |
  147. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  148. | :ref:`bool<class_bool>` | :ref:`is_stdout_verbose<class_OS_method_is_stdout_verbose>`\ (\ ) |const| |
  149. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  150. | :ref:`bool<class_bool>` | :ref:`is_userfs_persistent<class_OS_method_is_userfs_persistent>`\ (\ ) |const| |
  151. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  152. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`kill<class_OS_method_kill>`\ (\ pid\: :ref:`int<class_int>`\ ) |
  153. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  154. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`move_to_trash<class_OS_method_move_to_trash>`\ (\ path\: :ref:`String<class_String>`\ ) |const| |
  155. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  156. | |void| | :ref:`open_midi_inputs<class_OS_method_open_midi_inputs>`\ (\ ) |
  157. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  158. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`read_buffer_from_stdin<class_OS_method_read_buffer_from_stdin>`\ (\ buffer_size\: :ref:`int<class_int>`\ ) |
  159. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  160. | :ref:`String<class_String>` | :ref:`read_string_from_stdin<class_OS_method_read_string_from_stdin>`\ (\ buffer_size\: :ref:`int<class_int>`\ ) |
  161. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  162. | :ref:`bool<class_bool>` | :ref:`request_permission<class_OS_method_request_permission>`\ (\ name\: :ref:`String<class_String>`\ ) |
  163. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  164. | :ref:`bool<class_bool>` | :ref:`request_permissions<class_OS_method_request_permissions>`\ (\ ) |
  165. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  166. | |void| | :ref:`revoke_granted_permissions<class_OS_method_revoke_granted_permissions>`\ (\ ) |
  167. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  168. | |void| | :ref:`set_environment<class_OS_method_set_environment>`\ (\ variable\: :ref:`String<class_String>`, value\: :ref:`String<class_String>`\ ) |const| |
  169. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  170. | |void| | :ref:`set_restart_on_exit<class_OS_method_set_restart_on_exit>`\ (\ restart\: :ref:`bool<class_bool>`, arguments\: :ref:`PackedStringArray<class_PackedStringArray>` = PackedStringArray()\ ) |
  171. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  172. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`set_thread_name<class_OS_method_set_thread_name>`\ (\ name\: :ref:`String<class_String>`\ ) |
  173. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  174. | |void| | :ref:`set_use_file_access_save_and_swap<class_OS_method_set_use_file_access_save_and_swap>`\ (\ enabled\: :ref:`bool<class_bool>`\ ) |
  175. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  176. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`shell_open<class_OS_method_shell_open>`\ (\ uri\: :ref:`String<class_String>`\ ) |
  177. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  178. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`shell_show_in_file_manager<class_OS_method_shell_show_in_file_manager>`\ (\ file_or_dir_path\: :ref:`String<class_String>`, open_folder\: :ref:`bool<class_bool>` = true\ ) |
  179. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  180. | |void| | :ref:`unset_environment<class_OS_method_unset_environment>`\ (\ variable\: :ref:`String<class_String>`\ ) |const| |
  181. +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  182. .. rst-class:: classref-section-separator
  183. ----
  184. .. rst-class:: classref-descriptions-group
  185. Enumerations
  186. ------------
  187. .. _enum_OS_RenderingDriver:
  188. .. rst-class:: classref-enumeration
  189. enum **RenderingDriver**: :ref:`๐Ÿ”—<enum_OS_RenderingDriver>`
  190. .. _class_OS_constant_RENDERING_DRIVER_VULKAN:
  191. .. rst-class:: classref-enumeration-constant
  192. :ref:`RenderingDriver<enum_OS_RenderingDriver>` **RENDERING_DRIVER_VULKAN** = ``0``
  193. The Vulkan rendering driver. It requires Vulkan 1.0 support and automatically uses features from Vulkan 1.1 and 1.2 if available.
  194. .. _class_OS_constant_RENDERING_DRIVER_OPENGL3:
  195. .. rst-class:: classref-enumeration-constant
  196. :ref:`RenderingDriver<enum_OS_RenderingDriver>` **RENDERING_DRIVER_OPENGL3** = ``1``
  197. The OpenGL 3 rendering driver. It uses OpenGL 3.3 Core Profile on desktop platforms, OpenGL ES 3.0 on mobile devices, and WebGL 2.0 on Web.
  198. .. _class_OS_constant_RENDERING_DRIVER_D3D12:
  199. .. rst-class:: classref-enumeration-constant
  200. :ref:`RenderingDriver<enum_OS_RenderingDriver>` **RENDERING_DRIVER_D3D12** = ``2``
  201. The Direct3D 12 rendering driver.
  202. .. _class_OS_constant_RENDERING_DRIVER_METAL:
  203. .. rst-class:: classref-enumeration-constant
  204. :ref:`RenderingDriver<enum_OS_RenderingDriver>` **RENDERING_DRIVER_METAL** = ``3``
  205. The Metal rendering driver.
  206. .. rst-class:: classref-item-separator
  207. ----
  208. .. _enum_OS_SystemDir:
  209. .. rst-class:: classref-enumeration
  210. enum **SystemDir**: :ref:`๐Ÿ”—<enum_OS_SystemDir>`
  211. .. _class_OS_constant_SYSTEM_DIR_DESKTOP:
  212. .. rst-class:: classref-enumeration-constant
  213. :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_DESKTOP** = ``0``
  214. Refers to the Desktop directory path.
  215. .. _class_OS_constant_SYSTEM_DIR_DCIM:
  216. .. rst-class:: classref-enumeration-constant
  217. :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_DCIM** = ``1``
  218. Refers to the DCIM (Digital Camera Images) directory path.
  219. .. _class_OS_constant_SYSTEM_DIR_DOCUMENTS:
  220. .. rst-class:: classref-enumeration-constant
  221. :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_DOCUMENTS** = ``2``
  222. Refers to the Documents directory path.
  223. .. _class_OS_constant_SYSTEM_DIR_DOWNLOADS:
  224. .. rst-class:: classref-enumeration-constant
  225. :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_DOWNLOADS** = ``3``
  226. Refers to the Downloads directory path.
  227. .. _class_OS_constant_SYSTEM_DIR_MOVIES:
  228. .. rst-class:: classref-enumeration-constant
  229. :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_MOVIES** = ``4``
  230. Refers to the Movies (or Videos) directory path.
  231. .. _class_OS_constant_SYSTEM_DIR_MUSIC:
  232. .. rst-class:: classref-enumeration-constant
  233. :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_MUSIC** = ``5``
  234. Refers to the Music directory path.
  235. .. _class_OS_constant_SYSTEM_DIR_PICTURES:
  236. .. rst-class:: classref-enumeration-constant
  237. :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_PICTURES** = ``6``
  238. Refers to the Pictures directory path.
  239. .. _class_OS_constant_SYSTEM_DIR_RINGTONES:
  240. .. rst-class:: classref-enumeration-constant
  241. :ref:`SystemDir<enum_OS_SystemDir>` **SYSTEM_DIR_RINGTONES** = ``7``
  242. Refers to the Ringtones directory path.
  243. .. rst-class:: classref-item-separator
  244. ----
  245. .. _enum_OS_StdHandleType:
  246. .. rst-class:: classref-enumeration
  247. enum **StdHandleType**: :ref:`๐Ÿ”—<enum_OS_StdHandleType>`
  248. .. _class_OS_constant_STD_HANDLE_INVALID:
  249. .. rst-class:: classref-enumeration-constant
  250. :ref:`StdHandleType<enum_OS_StdHandleType>` **STD_HANDLE_INVALID** = ``0``
  251. Standard I/O device is invalid. No data can be received from or sent to these standard I/O devices.
  252. .. _class_OS_constant_STD_HANDLE_CONSOLE:
  253. .. rst-class:: classref-enumeration-constant
  254. :ref:`StdHandleType<enum_OS_StdHandleType>` **STD_HANDLE_CONSOLE** = ``1``
  255. Standard I/O device is a console. This typically occurs when Godot is run from a terminal with no redirection. This is also used for all standard I/O devices when running Godot from the editor, at least on desktop platforms.
  256. .. _class_OS_constant_STD_HANDLE_FILE:
  257. .. rst-class:: classref-enumeration-constant
  258. :ref:`StdHandleType<enum_OS_StdHandleType>` **STD_HANDLE_FILE** = ``2``
  259. Standard I/O device is a regular file. This typically occurs with redirection from a terminal, e.g. ``godot > stdout.txt``, ``godot < stdin.txt`` or ``godot > stdout_stderr.txt 2>&1``.
  260. .. _class_OS_constant_STD_HANDLE_PIPE:
  261. .. rst-class:: classref-enumeration-constant
  262. :ref:`StdHandleType<enum_OS_StdHandleType>` **STD_HANDLE_PIPE** = ``3``
  263. Standard I/O device is a FIFO/pipe. This typically occurs with pipe usage from a terminal, e.g. ``echo "Hello" | godot``.
  264. .. _class_OS_constant_STD_HANDLE_UNKNOWN:
  265. .. rst-class:: classref-enumeration-constant
  266. :ref:`StdHandleType<enum_OS_StdHandleType>` **STD_HANDLE_UNKNOWN** = ``4``
  267. Standard I/O device type is unknown.
  268. .. rst-class:: classref-section-separator
  269. ----
  270. .. rst-class:: classref-descriptions-group
  271. Property Descriptions
  272. ---------------------
  273. .. _class_OS_property_delta_smoothing:
  274. .. rst-class:: classref-property
  275. :ref:`bool<class_bool>` **delta_smoothing** = ``true`` :ref:`๐Ÿ”—<class_OS_property_delta_smoothing>`
  276. .. rst-class:: classref-property-setget
  277. - |void| **set_delta_smoothing**\ (\ value\: :ref:`bool<class_bool>`\ )
  278. - :ref:`bool<class_bool>` **is_delta_smoothing_enabled**\ (\ )
  279. If ``true``, the engine filters the time delta measured between each frame, and attempts to compensate for random variation. This only works on systems where V-Sync is active.
  280. \ **Note:** On start-up, this is the same as :ref:`ProjectSettings.application/run/delta_smoothing<class_ProjectSettings_property_application/run/delta_smoothing>`.
  281. .. rst-class:: classref-item-separator
  282. ----
  283. .. _class_OS_property_low_processor_usage_mode:
  284. .. rst-class:: classref-property
  285. :ref:`bool<class_bool>` **low_processor_usage_mode** = ``false`` :ref:`๐Ÿ”—<class_OS_property_low_processor_usage_mode>`
  286. .. rst-class:: classref-property-setget
  287. - |void| **set_low_processor_usage_mode**\ (\ value\: :ref:`bool<class_bool>`\ )
  288. - :ref:`bool<class_bool>` **is_in_low_processor_usage_mode**\ (\ )
  289. If ``true``, the engine optimizes for low processor usage by only refreshing the screen if needed. Can improve battery consumption on mobile.
  290. \ **Note:** On start-up, this is the same as :ref:`ProjectSettings.application/run/low_processor_mode<class_ProjectSettings_property_application/run/low_processor_mode>`.
  291. .. rst-class:: classref-item-separator
  292. ----
  293. .. _class_OS_property_low_processor_usage_mode_sleep_usec:
  294. .. rst-class:: classref-property
  295. :ref:`int<class_int>` **low_processor_usage_mode_sleep_usec** = ``6900`` :ref:`๐Ÿ”—<class_OS_property_low_processor_usage_mode_sleep_usec>`
  296. .. rst-class:: classref-property-setget
  297. - |void| **set_low_processor_usage_mode_sleep_usec**\ (\ value\: :ref:`int<class_int>`\ )
  298. - :ref:`int<class_int>` **get_low_processor_usage_mode_sleep_usec**\ (\ )
  299. The amount of sleeping between frames when the low-processor usage mode is enabled, in microseconds. Higher values will result in lower CPU usage. See also :ref:`low_processor_usage_mode<class_OS_property_low_processor_usage_mode>`.
  300. \ **Note:** On start-up, this is the same as :ref:`ProjectSettings.application/run/low_processor_mode_sleep_usec<class_ProjectSettings_property_application/run/low_processor_mode_sleep_usec>`.
  301. .. rst-class:: classref-section-separator
  302. ----
  303. .. rst-class:: classref-descriptions-group
  304. Method Descriptions
  305. -------------------
  306. .. _class_OS_method_alert:
  307. .. rst-class:: classref-method
  308. |void| **alert**\ (\ text\: :ref:`String<class_String>`, title\: :ref:`String<class_String>` = "Alert!"\ ) :ref:`๐Ÿ”—<class_OS_method_alert>`
  309. Displays a modal dialog box using the host platform's implementation. The engine execution is blocked until the dialog is closed.
  310. .. rst-class:: classref-item-separator
  311. ----
  312. .. _class_OS_method_close_midi_inputs:
  313. .. rst-class:: classref-method
  314. |void| **close_midi_inputs**\ (\ ) :ref:`๐Ÿ”—<class_OS_method_close_midi_inputs>`
  315. Shuts down the system MIDI driver. Godot will no longer receive :ref:`InputEventMIDI<class_InputEventMIDI>`. See also :ref:`open_midi_inputs<class_OS_method_open_midi_inputs>` and :ref:`get_connected_midi_inputs<class_OS_method_get_connected_midi_inputs>`.
  316. \ **Note:** This method is implemented on Linux, macOS, and Windows.
  317. .. rst-class:: classref-item-separator
  318. ----
  319. .. _class_OS_method_crash:
  320. .. rst-class:: classref-method
  321. |void| **crash**\ (\ message\: :ref:`String<class_String>`\ ) :ref:`๐Ÿ”—<class_OS_method_crash>`
  322. Crashes the engine (or the editor if called within a ``@tool`` script). See also :ref:`kill<class_OS_method_kill>`.
  323. \ **Note:** This method should *only* be used for testing the system's crash handler, not for any other purpose. For general error reporting, use (in order of preference) :ref:`@GDScript.assert<class_@GDScript_method_assert>`, :ref:`@GlobalScope.push_error<class_@GlobalScope_method_push_error>`, or :ref:`alert<class_OS_method_alert>`.
  324. .. rst-class:: classref-item-separator
  325. ----
  326. .. _class_OS_method_create_instance:
  327. .. rst-class:: classref-method
  328. :ref:`int<class_int>` **create_instance**\ (\ arguments\: :ref:`PackedStringArray<class_PackedStringArray>`\ ) :ref:`๐Ÿ”—<class_OS_method_create_instance>`
  329. Creates a new instance of Godot that runs independently. The ``arguments`` are used in the given order and separated by a space.
  330. If the process is successfully created, this method returns the new process' ID, which you can use to monitor the process (and potentially terminate it with :ref:`kill<class_OS_method_kill>`). If the process cannot be created, this method returns ``-1``.
  331. See :ref:`create_process<class_OS_method_create_process>` if you wish to run a different process.
  332. \ **Note:** This method is implemented on Android, Linux, macOS and Windows.
  333. .. rst-class:: classref-item-separator
  334. ----
  335. .. _class_OS_method_create_process:
  336. .. rst-class:: classref-method
  337. :ref:`int<class_int>` **create_process**\ (\ path\: :ref:`String<class_String>`, arguments\: :ref:`PackedStringArray<class_PackedStringArray>`, open_console\: :ref:`bool<class_bool>` = false\ ) :ref:`๐Ÿ”—<class_OS_method_create_process>`
  338. Creates a new process that runs independently of Godot. It will not terminate when Godot terminates. The path specified in ``path`` must exist and be an executable file or macOS ``.app`` bundle. The path is resolved based on the current platform. The ``arguments`` are used in the given order and separated by a space.
  339. On Windows, if ``open_console`` is ``true`` and the process is a console app, a new terminal window will be opened.
  340. If the process is successfully created, this method returns its process ID, which you can use to monitor the process (and potentially terminate it with :ref:`kill<class_OS_method_kill>`). Otherwise, this method returns ``-1``.
  341. \ **Example:** Run another instance of the project:
  342. .. tabs::
  343. .. code-tab:: gdscript
  344. var pid = OS.create_process(OS.get_executable_path(), [])
  345. .. code-tab:: csharp
  346. var pid = OS.CreateProcess(OS.GetExecutablePath(), new string[] {});
  347. See :ref:`execute<class_OS_method_execute>` if you wish to run an external command and retrieve the results.
  348. \ **Note:** This method is implemented on Android, Linux, macOS, and Windows.
  349. \ **Note:** On macOS, sandboxed applications are limited to run only embedded helper executables, specified during export or system .app bundle, system .app bundles will ignore arguments.
  350. .. rst-class:: classref-item-separator
  351. ----
  352. .. _class_OS_method_delay_msec:
  353. .. rst-class:: classref-method
  354. |void| **delay_msec**\ (\ msec\: :ref:`int<class_int>`\ ) |const| :ref:`๐Ÿ”—<class_OS_method_delay_msec>`
  355. Delays execution of the current thread by ``msec`` milliseconds. ``msec`` must be greater than or equal to ``0``. Otherwise, :ref:`delay_msec<class_OS_method_delay_msec>` does nothing and prints an error message.
  356. \ **Note:** :ref:`delay_msec<class_OS_method_delay_msec>` is a *blocking* way to delay code execution. To delay code execution in a non-blocking way, you may use :ref:`SceneTree.create_timer<class_SceneTree_method_create_timer>`. Awaiting with :ref:`SceneTreeTimer<class_SceneTreeTimer>` delays the execution of code placed below the ``await`` without affecting the rest of the project (or editor, for :ref:`EditorPlugin<class_EditorPlugin>`\ s and :ref:`EditorScript<class_EditorScript>`\ s).
  357. \ **Note:** When :ref:`delay_msec<class_OS_method_delay_msec>` is called on the main thread, it will freeze the project and will prevent it from redrawing and registering input until the delay has passed. When using :ref:`delay_msec<class_OS_method_delay_msec>` as part of an :ref:`EditorPlugin<class_EditorPlugin>` or :ref:`EditorScript<class_EditorScript>`, it will freeze the editor but won't freeze the project if it is currently running (since the project is an independent child process).
  358. .. rst-class:: classref-item-separator
  359. ----
  360. .. _class_OS_method_delay_usec:
  361. .. rst-class:: classref-method
  362. |void| **delay_usec**\ (\ usec\: :ref:`int<class_int>`\ ) |const| :ref:`๐Ÿ”—<class_OS_method_delay_usec>`
  363. Delays execution of the current thread by ``usec`` microseconds. ``usec`` must be greater than or equal to ``0``. Otherwise, :ref:`delay_usec<class_OS_method_delay_usec>` does nothing and prints an error message.
  364. \ **Note:** :ref:`delay_usec<class_OS_method_delay_usec>` is a *blocking* way to delay code execution. To delay code execution in a non-blocking way, you may use :ref:`SceneTree.create_timer<class_SceneTree_method_create_timer>`. Awaiting with a :ref:`SceneTreeTimer<class_SceneTreeTimer>` delays the execution of code placed below the ``await`` without affecting the rest of the project (or editor, for :ref:`EditorPlugin<class_EditorPlugin>`\ s and :ref:`EditorScript<class_EditorScript>`\ s).
  365. \ **Note:** When :ref:`delay_usec<class_OS_method_delay_usec>` is called on the main thread, it will freeze the project and will prevent it from redrawing and registering input until the delay has passed. When using :ref:`delay_usec<class_OS_method_delay_usec>` as part of an :ref:`EditorPlugin<class_EditorPlugin>` or :ref:`EditorScript<class_EditorScript>`, it will freeze the editor but won't freeze the project if it is currently running (since the project is an independent child process).
  366. .. rst-class:: classref-item-separator
  367. ----
  368. .. _class_OS_method_execute:
  369. .. rst-class:: classref-method
  370. :ref:`int<class_int>` **execute**\ (\ path\: :ref:`String<class_String>`, arguments\: :ref:`PackedStringArray<class_PackedStringArray>`, output\: :ref:`Array<class_Array>` = [], read_stderr\: :ref:`bool<class_bool>` = false, open_console\: :ref:`bool<class_bool>` = false\ ) :ref:`๐Ÿ”—<class_OS_method_execute>`
  371. Executes the given process in a *blocking* way. The file specified in ``path`` must exist and be executable. The system path resolution will be used. The ``arguments`` are used in the given order, separated by spaces, and wrapped in quotes.
  372. If an ``output`` array is provided, the complete shell output of the process is appended to ``output`` as a single :ref:`String<class_String>` element. If ``read_stderr`` is ``true``, the output to the standard error stream is also appended to the array.
  373. On Windows, if ``open_console`` is ``true`` and the process is a console app, a new terminal window is opened.
  374. This method returns the exit code of the command, or ``-1`` if the process fails to execute.
  375. \ **Note:** The main thread will be blocked until the executed command terminates. Use :ref:`Thread<class_Thread>` to create a separate thread that will not block the main thread, or use :ref:`create_process<class_OS_method_create_process>` to create a completely independent process.
  376. For example, to retrieve a list of the working directory's contents:
  377. .. tabs::
  378. .. code-tab:: gdscript
  379. var output = []
  380. var exit_code = OS.execute("ls", ["-l", "/tmp"], output)
  381. .. code-tab:: csharp
  382. var output = new Godot.Collections.Array();
  383. int exitCode = OS.Execute("ls", new string[] {"-l", "/tmp"}, output);
  384. If you wish to access a shell built-in or execute a composite command, a platform-specific shell can be invoked. For example:
  385. .. tabs::
  386. .. code-tab:: gdscript
  387. var output = []
  388. OS.execute("CMD.exe", ["/C", "cd %TEMP% && dir"], output)
  389. .. code-tab:: csharp
  390. var output = new Godot.Collections.Array();
  391. OS.Execute("CMD.exe", new string[] {"/C", "cd %TEMP% && dir"}, output);
  392. \ **Note:** This method is implemented on Android, Linux, macOS, and Windows.
  393. \ **Note:** To execute a Windows command interpreter built-in command, specify ``cmd.exe`` in ``path``, ``/c`` as the first argument, and the desired command as the second argument.
  394. \ **Note:** To execute a PowerShell built-in command, specify ``powershell.exe`` in ``path``, ``-Command`` as the first argument, and the desired command as the second argument.
  395. \ **Note:** To execute a Unix shell built-in command, specify shell executable name in ``path``, ``-c`` as the first argument, and the desired command as the second argument.
  396. \ **Note:** On macOS, sandboxed applications are limited to run only embedded helper executables, specified during export.
  397. \ **Note:** On Android, system commands such as ``dumpsys`` can only be run on a rooted device.
  398. .. rst-class:: classref-item-separator
  399. ----
  400. .. _class_OS_method_execute_with_pipe:
  401. .. rst-class:: classref-method
  402. :ref:`Dictionary<class_Dictionary>` **execute_with_pipe**\ (\ path\: :ref:`String<class_String>`, arguments\: :ref:`PackedStringArray<class_PackedStringArray>`, blocking\: :ref:`bool<class_bool>` = true\ ) :ref:`๐Ÿ”—<class_OS_method_execute_with_pipe>`
  403. Creates a new process that runs independently of Godot with redirected IO. It will not terminate when Godot terminates. The path specified in ``path`` must exist and be an executable file or macOS ``.app`` bundle. The path is resolved based on the current platform. The ``arguments`` are used in the given order and separated by a space.
  404. If ``blocking`` is ``false``, created pipes work in non-blocking mode, i.e. read and write operations will return immediately. Use :ref:`FileAccess.get_error<class_FileAccess_method_get_error>` to check if the last read/write operation was successful.
  405. If the process cannot be created, this method returns an empty :ref:`Dictionary<class_Dictionary>`. Otherwise, this method returns a :ref:`Dictionary<class_Dictionary>` with the following keys:
  406. - ``"stdio"`` - :ref:`FileAccess<class_FileAccess>` to access the process stdin and stdout pipes (read/write).
  407. - ``"stderr"`` - :ref:`FileAccess<class_FileAccess>` to access the process stderr pipe (read only).
  408. - ``"pid"`` - Process ID as an :ref:`int<class_int>`, which you can use to monitor the process (and potentially terminate it with :ref:`kill<class_OS_method_kill>`).
  409. \ **Note:** This method is implemented on Android, Linux, macOS, and Windows.
  410. \ **Note:** To execute a Windows command interpreter built-in command, specify ``cmd.exe`` in ``path``, ``/c`` as the first argument, and the desired command as the second argument.
  411. \ **Note:** To execute a PowerShell built-in command, specify ``powershell.exe`` in ``path``, ``-Command`` as the first argument, and the desired command as the second argument.
  412. \ **Note:** To execute a Unix shell built-in command, specify shell executable name in ``path``, ``-c`` as the first argument, and the desired command as the second argument.
  413. \ **Note:** On macOS, sandboxed applications are limited to run only embedded helper executables, specified during export or system .app bundle, system .app bundles will ignore arguments.
  414. .. rst-class:: classref-item-separator
  415. ----
  416. .. _class_OS_method_find_keycode_from_string:
  417. .. rst-class:: classref-method
  418. :ref:`Key<enum_@GlobalScope_Key>` **find_keycode_from_string**\ (\ string\: :ref:`String<class_String>`\ ) |const| :ref:`๐Ÿ”—<class_OS_method_find_keycode_from_string>`
  419. Finds the keycode for the given string. The returned values are equivalent to the :ref:`Key<enum_@GlobalScope_Key>` constants.
  420. .. tabs::
  421. .. code-tab:: gdscript
  422. print(OS.find_keycode_from_string("C")) # Prints 67 (KEY_C)
  423. print(OS.find_keycode_from_string("Escape")) # Prints 4194305 (KEY_ESCAPE)
  424. print(OS.find_keycode_from_string("Shift+Tab")) # Prints 37748738 (KEY_MASK_SHIFT | KEY_TAB)
  425. print(OS.find_keycode_from_string("Unknown")) # Prints 0 (KEY_NONE)
  426. .. code-tab:: csharp
  427. GD.Print(OS.FindKeycodeFromString("C")); // Prints C (Key.C)
  428. GD.Print(OS.FindKeycodeFromString("Escape")); // Prints Escape (Key.Escape)
  429. GD.Print(OS.FindKeycodeFromString("Shift+Tab")); // Prints 37748738 (KeyModifierMask.MaskShift | Key.Tab)
  430. GD.Print(OS.FindKeycodeFromString("Unknown")); // Prints None (Key.None)
  431. See also :ref:`get_keycode_string<class_OS_method_get_keycode_string>`.
  432. .. rst-class:: classref-item-separator
  433. ----
  434. .. _class_OS_method_get_cache_dir:
  435. .. rst-class:: classref-method
  436. :ref:`String<class_String>` **get_cache_dir**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_cache_dir>`
  437. Returns the *global* cache data directory according to the operating system's standards.
  438. On the Linux/BSD platform, this path can be overridden by setting the ``XDG_CACHE_HOME`` environment variable before starting the project. See :doc:`File paths in Godot projects <../tutorials/io/data_paths>` in the documentation for more information. See also :ref:`get_config_dir<class_OS_method_get_config_dir>` and :ref:`get_data_dir<class_OS_method_get_data_dir>`.
  439. Not to be confused with :ref:`get_user_data_dir<class_OS_method_get_user_data_dir>`, which returns the *project-specific* user data path.
  440. .. rst-class:: classref-item-separator
  441. ----
  442. .. _class_OS_method_get_cmdline_args:
  443. .. rst-class:: classref-method
  444. :ref:`PackedStringArray<class_PackedStringArray>` **get_cmdline_args**\ (\ ) :ref:`๐Ÿ”—<class_OS_method_get_cmdline_args>`
  445. Returns the command-line arguments passed to the engine.
  446. Command-line arguments can be written in any form, including both ``--key value`` and ``--key=value`` forms so they can be properly parsed, as long as custom command-line arguments do not conflict with engine arguments.
  447. You can also incorporate environment variables using the :ref:`get_environment<class_OS_method_get_environment>` method.
  448. You can set :ref:`ProjectSettings.editor/run/main_run_args<class_ProjectSettings_property_editor/run/main_run_args>` to define command-line arguments to be passed by the editor when running the project.
  449. \ **Example:** Parse command-line arguments into a :ref:`Dictionary<class_Dictionary>` using the ``--key=value`` form for arguments:
  450. .. tabs::
  451. .. code-tab:: gdscript
  452. var arguments = {}
  453. for argument in OS.get_cmdline_args():
  454. if argument.contains("="):
  455. var key_value = argument.split("=")
  456. arguments[key_value[0].trim_prefix("--")] = key_value[1]
  457. else:
  458. # Options without an argument will be present in the dictionary,
  459. # with the value set to an empty string.
  460. arguments[argument.trim_prefix("--")] = ""
  461. .. code-tab:: csharp
  462. var arguments = new Dictionary<string, string>();
  463. foreach (var argument in OS.GetCmdlineArgs())
  464. {
  465. if (argument.Contains('='))
  466. {
  467. string[] keyValue = argument.Split("=");
  468. arguments[keyValue[0].TrimPrefix("--")] = keyValue[1];
  469. }
  470. else
  471. {
  472. // Options without an argument will be present in the dictionary,
  473. // with the value set to an empty string.
  474. arguments[argument.TrimPrefix("--")] = "";
  475. }
  476. }
  477. \ **Note:** Passing custom user arguments directly is not recommended, as the engine may discard or modify them. Instead, pass the standard UNIX double dash (``--``) and then the custom arguments, which the engine will ignore by design. These can be read via :ref:`get_cmdline_user_args<class_OS_method_get_cmdline_user_args>`.
  478. .. rst-class:: classref-item-separator
  479. ----
  480. .. _class_OS_method_get_cmdline_user_args:
  481. .. rst-class:: classref-method
  482. :ref:`PackedStringArray<class_PackedStringArray>` **get_cmdline_user_args**\ (\ ) :ref:`๐Ÿ”—<class_OS_method_get_cmdline_user_args>`
  483. Returns the command-line user arguments passed to the engine. User arguments are ignored by the engine and reserved for the user. They are passed after the double dash ``--`` argument. ``++`` may be used when ``--`` is intercepted by another program (such as ``startx``).
  484. ::
  485. # Godot has been executed with the following command:
  486. # godot --fullscreen -- --level=2 --hardcore
  487. OS.get_cmdline_args() # Returns ["--fullscreen", "--level=2", "--hardcore"]
  488. OS.get_cmdline_user_args() # Returns ["--level=2", "--hardcore"]
  489. To get all passed arguments, use :ref:`get_cmdline_args<class_OS_method_get_cmdline_args>`.
  490. .. rst-class:: classref-item-separator
  491. ----
  492. .. _class_OS_method_get_config_dir:
  493. .. rst-class:: classref-method
  494. :ref:`String<class_String>` **get_config_dir**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_config_dir>`
  495. Returns the *global* user configuration directory according to the operating system's standards.
  496. On the Linux/BSD platform, this path can be overridden by setting the ``XDG_CONFIG_HOME`` environment variable before starting the project. See :doc:`File paths in Godot projects <../tutorials/io/data_paths>` in the documentation for more information. See also :ref:`get_cache_dir<class_OS_method_get_cache_dir>` and :ref:`get_data_dir<class_OS_method_get_data_dir>`.
  497. Not to be confused with :ref:`get_user_data_dir<class_OS_method_get_user_data_dir>`, which returns the *project-specific* user data path.
  498. .. rst-class:: classref-item-separator
  499. ----
  500. .. _class_OS_method_get_connected_midi_inputs:
  501. .. rst-class:: classref-method
  502. :ref:`PackedStringArray<class_PackedStringArray>` **get_connected_midi_inputs**\ (\ ) :ref:`๐Ÿ”—<class_OS_method_get_connected_midi_inputs>`
  503. Returns an array of connected MIDI device names, if they exist. Returns an empty array if the system MIDI driver has not previously been initialized with :ref:`open_midi_inputs<class_OS_method_open_midi_inputs>`. See also :ref:`close_midi_inputs<class_OS_method_close_midi_inputs>`.
  504. \ **Note:** This method is implemented on Linux, macOS, and Windows.
  505. .. rst-class:: classref-item-separator
  506. ----
  507. .. _class_OS_method_get_data_dir:
  508. .. rst-class:: classref-method
  509. :ref:`String<class_String>` **get_data_dir**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_data_dir>`
  510. Returns the *global* user data directory according to the operating system's standards.
  511. On the Linux/BSD platform, this path can be overridden by setting the ``XDG_DATA_HOME`` environment variable before starting the project. See :doc:`File paths in Godot projects <../tutorials/io/data_paths>` in the documentation for more information. See also :ref:`get_cache_dir<class_OS_method_get_cache_dir>` and :ref:`get_config_dir<class_OS_method_get_config_dir>`.
  512. Not to be confused with :ref:`get_user_data_dir<class_OS_method_get_user_data_dir>`, which returns the *project-specific* user data path.
  513. .. rst-class:: classref-item-separator
  514. ----
  515. .. _class_OS_method_get_distribution_name:
  516. .. rst-class:: classref-method
  517. :ref:`String<class_String>` **get_distribution_name**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_distribution_name>`
  518. Returns the name of the distribution for Linux and BSD platforms (e.g. "Ubuntu", "Manjaro", "OpenBSD", etc.).
  519. Returns the same value as :ref:`get_name<class_OS_method_get_name>` for stock Android ROMs, but attempts to return the custom ROM name for popular Android derivatives such as "LineageOS".
  520. Returns the same value as :ref:`get_name<class_OS_method_get_name>` for other platforms.
  521. \ **Note:** This method is not supported on the Web platform. It returns an empty string.
  522. .. rst-class:: classref-item-separator
  523. ----
  524. .. _class_OS_method_get_entropy:
  525. .. rst-class:: classref-method
  526. :ref:`PackedByteArray<class_PackedByteArray>` **get_entropy**\ (\ size\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_OS_method_get_entropy>`
  527. Generates a :ref:`PackedByteArray<class_PackedByteArray>` of cryptographically secure random bytes with given ``size``.
  528. \ **Note:** Generating large quantities of bytes using this method can result in locking and entropy of lower quality on most platforms. Using :ref:`Crypto.generate_random_bytes<class_Crypto_method_generate_random_bytes>` is preferred in most cases.
  529. .. rst-class:: classref-item-separator
  530. ----
  531. .. _class_OS_method_get_environment:
  532. .. rst-class:: classref-method
  533. :ref:`String<class_String>` **get_environment**\ (\ variable\: :ref:`String<class_String>`\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_environment>`
  534. Returns the value of the given environment variable, or an empty string if ``variable`` doesn't exist.
  535. \ **Note:** Double-check the casing of ``variable``. Environment variable names are case-sensitive on all platforms except Windows.
  536. \ **Note:** On macOS, applications do not have access to shell environment variables.
  537. .. rst-class:: classref-item-separator
  538. ----
  539. .. _class_OS_method_get_executable_path:
  540. .. rst-class:: classref-method
  541. :ref:`String<class_String>` **get_executable_path**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_executable_path>`
  542. Returns the file path to the current engine executable.
  543. \ **Note:** On macOS, if you want to launch another instance of Godot, always use :ref:`create_instance<class_OS_method_create_instance>` instead of relying on the executable path.
  544. .. rst-class:: classref-item-separator
  545. ----
  546. .. _class_OS_method_get_granted_permissions:
  547. .. rst-class:: classref-method
  548. :ref:`PackedStringArray<class_PackedStringArray>` **get_granted_permissions**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_granted_permissions>`
  549. On Android devices: Returns the list of dangerous permissions that have been granted.
  550. On macOS: Returns the list of user selected folders accessible to the application (sandboxed applications only). Use the native file dialog to request folder access permission.
  551. .. rst-class:: classref-item-separator
  552. ----
  553. .. _class_OS_method_get_keycode_string:
  554. .. rst-class:: classref-method
  555. :ref:`String<class_String>` **get_keycode_string**\ (\ code\: :ref:`Key<enum_@GlobalScope_Key>`\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_keycode_string>`
  556. Returns the given keycode as a :ref:`String<class_String>`.
  557. .. tabs::
  558. .. code-tab:: gdscript
  559. print(OS.get_keycode_string(KEY_C)) # Prints "C"
  560. print(OS.get_keycode_string(KEY_ESCAPE)) # Prints "Escape"
  561. print(OS.get_keycode_string(KEY_MASK_SHIFT | KEY_TAB)) # Prints "Shift+Tab"
  562. .. code-tab:: csharp
  563. GD.Print(OS.GetKeycodeString(Key.C)); // Prints "C"
  564. GD.Print(OS.GetKeycodeString(Key.Escape)); // Prints "Escape"
  565. GD.Print(OS.GetKeycodeString((Key)KeyModifierMask.MaskShift | Key.Tab)); // Prints "Shift+Tab"
  566. See also :ref:`find_keycode_from_string<class_OS_method_find_keycode_from_string>`, :ref:`InputEventKey.keycode<class_InputEventKey_property_keycode>`, and :ref:`InputEventKey.get_keycode_with_modifiers<class_InputEventKey_method_get_keycode_with_modifiers>`.
  567. .. rst-class:: classref-item-separator
  568. ----
  569. .. _class_OS_method_get_locale:
  570. .. rst-class:: classref-method
  571. :ref:`String<class_String>` **get_locale**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_locale>`
  572. Returns the host OS locale as a :ref:`String<class_String>` of the form ``language_Script_COUNTRY_VARIANT@extra``. Every substring after ``language`` is optional and may not exist.
  573. - ``language`` - 2 or 3-letter `language code <https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes>`__, in lower case.
  574. - ``Script`` - 4-letter `script code <https://en.wikipedia.org/wiki/ISO_15924>`__, in title case.
  575. - ``COUNTRY`` - 2 or 3-letter `country code <https://en.wikipedia.org/wiki/ISO_3166-1>`__, in upper case.
  576. - ``VARIANT`` - language variant, region and sort order. The variant can have any number of underscored keywords.
  577. - ``extra`` - semicolon separated list of additional key words. This may include currency, calendar, sort order and numbering system information.
  578. If you want only the language code and not the fully specified locale from the OS, you can use :ref:`get_locale_language<class_OS_method_get_locale_language>`.
  579. .. rst-class:: classref-item-separator
  580. ----
  581. .. _class_OS_method_get_locale_language:
  582. .. rst-class:: classref-method
  583. :ref:`String<class_String>` **get_locale_language**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_locale_language>`
  584. Returns the host OS locale's 2 or 3-letter `language code <https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes>`__ as a string which should be consistent on all platforms. This is equivalent to extracting the ``language`` part of the :ref:`get_locale<class_OS_method_get_locale>` string.
  585. This can be used to narrow down fully specified locale strings to only the "common" language code, when you don't need the additional information about country code or variants. For example, for a French Canadian user with ``fr_CA`` locale, this would return ``fr``.
  586. .. rst-class:: classref-item-separator
  587. ----
  588. .. _class_OS_method_get_main_thread_id:
  589. .. rst-class:: classref-method
  590. :ref:`int<class_int>` **get_main_thread_id**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_main_thread_id>`
  591. Returns the ID of the main thread. See :ref:`get_thread_caller_id<class_OS_method_get_thread_caller_id>`.
  592. \ **Note:** Thread IDs are not deterministic and may be reused across application restarts.
  593. .. rst-class:: classref-item-separator
  594. ----
  595. .. _class_OS_method_get_memory_info:
  596. .. rst-class:: classref-method
  597. :ref:`Dictionary<class_Dictionary>` **get_memory_info**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_memory_info>`
  598. Returns a :ref:`Dictionary<class_Dictionary>` containing information about the current memory with the following entries:
  599. - ``"physical"`` - total amount of usable physical memory in bytes. This value can be slightly less than the actual physical memory amount, since it does not include memory reserved by the kernel and devices.
  600. - ``"free"`` - amount of physical memory, that can be immediately allocated without disk access or other costly operations, in bytes. The process might be able to allocate more physical memory, but this action will require moving inactive pages to disk, which can be expensive.
  601. - ``"available"`` - amount of memory that can be allocated without extending the swap file(s), in bytes. This value includes both physical memory and swap.
  602. - ``"stack"`` - size of the current thread stack in bytes.
  603. \ **Note:** Each entry's value may be ``-1`` if it is unknown.
  604. .. rst-class:: classref-item-separator
  605. ----
  606. .. _class_OS_method_get_model_name:
  607. .. rst-class:: classref-method
  608. :ref:`String<class_String>` **get_model_name**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_model_name>`
  609. Returns the model name of the current device.
  610. \ **Note:** This method is implemented on Android, iOS, macOS, and Windows. Returns ``"GenericDevice"`` on unsupported platforms.
  611. .. rst-class:: classref-item-separator
  612. ----
  613. .. _class_OS_method_get_name:
  614. .. rst-class:: classref-method
  615. :ref:`String<class_String>` **get_name**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_name>`
  616. Returns the name of the host platform.
  617. - On Windows, this is ``"Windows"``.
  618. - On macOS, this is ``"macOS"``.
  619. - On Linux-based operating systems, this is ``"Linux"``.
  620. - On BSD-based operating systems, this is ``"FreeBSD"``, ``"NetBSD"``, ``"OpenBSD"``, or ``"BSD"`` as a fallback.
  621. - On Android, this is ``"Android"``.
  622. - On iOS, this is ``"iOS"``.
  623. - On Web, this is ``"Web"``.
  624. \ **Note:** Custom builds of the engine may support additional platforms, such as consoles, possibly returning other names.
  625. .. tabs::
  626. .. code-tab:: gdscript
  627. match OS.get_name():
  628. "Windows":
  629. print("Welcome to Windows!")
  630. "macOS":
  631. print("Welcome to macOS!")
  632. "Linux", "FreeBSD", "NetBSD", "OpenBSD", "BSD":
  633. print("Welcome to Linux/BSD!")
  634. "Android":
  635. print("Welcome to Android!")
  636. "iOS":
  637. print("Welcome to iOS!")
  638. "Web":
  639. print("Welcome to the Web!")
  640. .. code-tab:: csharp
  641. switch (OS.GetName())
  642. {
  643. case "Windows":
  644. GD.Print("Welcome to Windows");
  645. break;
  646. case "macOS":
  647. GD.Print("Welcome to macOS!");
  648. break;
  649. case "Linux":
  650. case "FreeBSD":
  651. case "NetBSD":
  652. case "OpenBSD":
  653. case "BSD":
  654. GD.Print("Welcome to Linux/BSD!");
  655. break;
  656. case "Android":
  657. GD.Print("Welcome to Android!");
  658. break;
  659. case "iOS":
  660. GD.Print("Welcome to iOS!");
  661. break;
  662. case "Web":
  663. GD.Print("Welcome to the Web!");
  664. break;
  665. }
  666. \ **Note:** On Web platforms, it is still possible to determine the host platform's OS with feature tags. See :ref:`has_feature<class_OS_method_has_feature>`.
  667. .. rst-class:: classref-item-separator
  668. ----
  669. .. _class_OS_method_get_process_exit_code:
  670. .. rst-class:: classref-method
  671. :ref:`int<class_int>` **get_process_exit_code**\ (\ pid\: :ref:`int<class_int>`\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_process_exit_code>`
  672. Returns the exit code of a spawned process once it has finished running (see :ref:`is_process_running<class_OS_method_is_process_running>`).
  673. Returns ``-1`` if the ``pid`` is not a PID of a spawned child process, the process is still running, or the method is not implemented for the current platform.
  674. \ **Note:** Returns ``-1`` if the ``pid`` is a macOS bundled app process.
  675. \ **Note:** This method is implemented on Android, Linux, macOS and Windows.
  676. .. rst-class:: classref-item-separator
  677. ----
  678. .. _class_OS_method_get_process_id:
  679. .. rst-class:: classref-method
  680. :ref:`int<class_int>` **get_process_id**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_process_id>`
  681. Returns the number used by the host machine to uniquely identify this application.
  682. \ **Note:** This method is implemented on Android, iOS, Linux, macOS, and Windows.
  683. .. rst-class:: classref-item-separator
  684. ----
  685. .. _class_OS_method_get_processor_count:
  686. .. rst-class:: classref-method
  687. :ref:`int<class_int>` **get_processor_count**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_processor_count>`
  688. Returns the number of *logical* CPU cores available on the host machine. On CPUs with HyperThreading enabled, this number will be greater than the number of *physical* CPU cores.
  689. .. rst-class:: classref-item-separator
  690. ----
  691. .. _class_OS_method_get_processor_name:
  692. .. rst-class:: classref-method
  693. :ref:`String<class_String>` **get_processor_name**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_processor_name>`
  694. Returns the full name of the CPU model on the host machine (e.g. ``"Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz"``).
  695. \ **Note:** This method is only implemented on Windows, macOS, Linux and iOS. On Android and Web, :ref:`get_processor_name<class_OS_method_get_processor_name>` returns an empty string.
  696. .. rst-class:: classref-item-separator
  697. ----
  698. .. _class_OS_method_get_restart_on_exit_arguments:
  699. .. rst-class:: classref-method
  700. :ref:`PackedStringArray<class_PackedStringArray>` **get_restart_on_exit_arguments**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_restart_on_exit_arguments>`
  701. Returns the list of command line arguments that will be used when the project automatically restarts using :ref:`set_restart_on_exit<class_OS_method_set_restart_on_exit>`. See also :ref:`is_restart_on_exit_set<class_OS_method_is_restart_on_exit_set>`.
  702. .. rst-class:: classref-item-separator
  703. ----
  704. .. _class_OS_method_get_static_memory_peak_usage:
  705. .. rst-class:: classref-method
  706. :ref:`int<class_int>` **get_static_memory_peak_usage**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_static_memory_peak_usage>`
  707. Returns the maximum amount of static memory used. Only works in debug builds.
  708. .. rst-class:: classref-item-separator
  709. ----
  710. .. _class_OS_method_get_static_memory_usage:
  711. .. rst-class:: classref-method
  712. :ref:`int<class_int>` **get_static_memory_usage**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_static_memory_usage>`
  713. Returns the amount of static memory being used by the program in bytes. Only works in debug builds.
  714. .. rst-class:: classref-item-separator
  715. ----
  716. .. _class_OS_method_get_stderr_type:
  717. .. rst-class:: classref-method
  718. :ref:`StdHandleType<enum_OS_StdHandleType>` **get_stderr_type**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_stderr_type>`
  719. Returns type of the standard error device.
  720. .. rst-class:: classref-item-separator
  721. ----
  722. .. _class_OS_method_get_stdin_type:
  723. .. rst-class:: classref-method
  724. :ref:`StdHandleType<enum_OS_StdHandleType>` **get_stdin_type**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_stdin_type>`
  725. Returns type of the standard input device.
  726. .. rst-class:: classref-item-separator
  727. ----
  728. .. _class_OS_method_get_stdout_type:
  729. .. rst-class:: classref-method
  730. :ref:`StdHandleType<enum_OS_StdHandleType>` **get_stdout_type**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_stdout_type>`
  731. Returns type of the standard output device.
  732. .. rst-class:: classref-item-separator
  733. ----
  734. .. _class_OS_method_get_system_ca_certificates:
  735. .. rst-class:: classref-method
  736. :ref:`String<class_String>` **get_system_ca_certificates**\ (\ ) :ref:`๐Ÿ”—<class_OS_method_get_system_ca_certificates>`
  737. Returns the list of certification authorities trusted by the operating system as a string of concatenated certificates in PEM format.
  738. .. rst-class:: classref-item-separator
  739. ----
  740. .. _class_OS_method_get_system_dir:
  741. .. rst-class:: classref-method
  742. :ref:`String<class_String>` **get_system_dir**\ (\ dir\: :ref:`SystemDir<enum_OS_SystemDir>`, shared_storage\: :ref:`bool<class_bool>` = true\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_system_dir>`
  743. Returns the path to commonly used folders across different platforms, as defined by ``dir``. See the :ref:`SystemDir<enum_OS_SystemDir>` constants for available locations.
  744. \ **Note:** This method is implemented on Android, Linux, macOS and Windows.
  745. \ **Note:** Shared storage is implemented on Android and allows to differentiate between app specific and shared directories, if ``shared_storage`` is ``true``. Shared directories have additional restrictions on Android.
  746. .. rst-class:: classref-item-separator
  747. ----
  748. .. _class_OS_method_get_system_font_path:
  749. .. rst-class:: classref-method
  750. :ref:`String<class_String>` **get_system_font_path**\ (\ font_name\: :ref:`String<class_String>`, weight\: :ref:`int<class_int>` = 400, stretch\: :ref:`int<class_int>` = 100, italic\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_system_font_path>`
  751. Returns the path to the system font file with ``font_name`` and style. Returns an empty string if no matching fonts found.
  752. The following aliases can be used to request default fonts: "sans-serif", "serif", "monospace", "cursive", and "fantasy".
  753. \ **Note:** Returned font might have different style if the requested style is not available.
  754. \ **Note:** This method is implemented on Android, iOS, Linux, macOS and Windows.
  755. .. rst-class:: classref-item-separator
  756. ----
  757. .. _class_OS_method_get_system_font_path_for_text:
  758. .. rst-class:: classref-method
  759. :ref:`PackedStringArray<class_PackedStringArray>` **get_system_font_path_for_text**\ (\ font_name\: :ref:`String<class_String>`, text\: :ref:`String<class_String>`, locale\: :ref:`String<class_String>` = "", script\: :ref:`String<class_String>` = "", weight\: :ref:`int<class_int>` = 400, stretch\: :ref:`int<class_int>` = 100, italic\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_system_font_path_for_text>`
  760. Returns an array of the system substitute font file paths, which are similar to the font with ``font_name`` and style for the specified text, locale, and script. Returns an empty array if no matching fonts found.
  761. The following aliases can be used to request default fonts: "sans-serif", "serif", "monospace", "cursive", and "fantasy".
  762. \ **Note:** Depending on OS, it's not guaranteed that any of the returned fonts will be suitable for rendering specified text. Fonts should be loaded and checked in the order they are returned, and the first suitable one used.
  763. \ **Note:** Returned fonts might have different style if the requested style is not available or belong to a different font family.
  764. \ **Note:** This method is implemented on Android, iOS, Linux, macOS and Windows.
  765. .. rst-class:: classref-item-separator
  766. ----
  767. .. _class_OS_method_get_system_fonts:
  768. .. rst-class:: classref-method
  769. :ref:`PackedStringArray<class_PackedStringArray>` **get_system_fonts**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_system_fonts>`
  770. Returns the list of font family names available.
  771. \ **Note:** This method is implemented on Android, iOS, Linux, macOS and Windows.
  772. .. rst-class:: classref-item-separator
  773. ----
  774. .. _class_OS_method_get_thread_caller_id:
  775. .. rst-class:: classref-method
  776. :ref:`int<class_int>` **get_thread_caller_id**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_thread_caller_id>`
  777. Returns the ID of the current thread. This can be used in logs to ease debugging of multi-threaded applications.
  778. \ **Note:** Thread IDs are not deterministic and may be reused across application restarts.
  779. .. rst-class:: classref-item-separator
  780. ----
  781. .. _class_OS_method_get_unique_id:
  782. .. rst-class:: classref-method
  783. :ref:`String<class_String>` **get_unique_id**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_unique_id>`
  784. Returns a string that is unique to the device.
  785. \ **Note:** This string may change without notice if the user reinstalls their operating system, upgrades it, or modifies their hardware. This means it should generally not be used to encrypt persistent data, as the data saved before an unexpected ID change would become inaccessible. The returned string may also be falsified using external programs, so do not rely on the string returned by this method for security purposes.
  786. \ **Note:** On Web, returns an empty string and generates an error, as this method cannot be implemented for security reasons.
  787. .. rst-class:: classref-item-separator
  788. ----
  789. .. _class_OS_method_get_user_data_dir:
  790. .. rst-class:: classref-method
  791. :ref:`String<class_String>` **get_user_data_dir**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_user_data_dir>`
  792. Returns the absolute directory path where user data is written (the ``user://`` directory in Godot). The path depends on the project name and :ref:`ProjectSettings.application/config/use_custom_user_dir<class_ProjectSettings_property_application/config/use_custom_user_dir>`.
  793. - On Windows, this is ``%AppData%\Godot\app_userdata\[project_name]``, or ``%AppData%\[custom_name]`` if ``use_custom_user_dir`` is set. ``%AppData%`` expands to ``%UserProfile%\AppData\Roaming``.
  794. - On macOS, this is ``~/Library/Application Support/Godot/app_userdata/[project_name]``, or ``~/Library/Application Support/[custom_name]`` if ``use_custom_user_dir`` is set.
  795. - On Linux and BSD, this is ``~/.local/share/godot/app_userdata/[project_name]``, or ``~/.local/share/[custom_name]`` if ``use_custom_user_dir`` is set.
  796. - On Android and iOS, this is a sandboxed directory in either internal or external storage, depending on the user's configuration.
  797. - On Web, this is a virtual directory managed by the browser.
  798. If the project name is empty, ``[project_name]`` falls back to ``[unnamed project]``.
  799. Not to be confused with :ref:`get_data_dir<class_OS_method_get_data_dir>`, which returns the *global* (non-project-specific) user home directory.
  800. .. rst-class:: classref-item-separator
  801. ----
  802. .. _class_OS_method_get_version:
  803. .. rst-class:: classref-method
  804. :ref:`String<class_String>` **get_version**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_version>`
  805. Returns the exact production and build version of the operating system. This is different from the branded version used in marketing. This helps to distinguish between different releases of operating systems, including minor versions, and insider and custom builds.
  806. - For Windows, the major and minor version are returned, as well as the build number. For example, the returned string may look like ``10.0.9926`` for a build of Windows 10, and it may look like ``6.1.7601`` for a build of Windows 7 SP1.
  807. - For rolling distributions, such as Arch Linux, an empty string is returned.
  808. - For macOS and iOS, the major and minor version are returned, as well as the patch number.
  809. - For Android, the SDK version and the incremental build number are returned. If it's a custom ROM, it attempts to return its version instead.
  810. \ **Note:** This method is not supported on the Web platform. It returns an empty string.
  811. .. rst-class:: classref-item-separator
  812. ----
  813. .. _class_OS_method_get_video_adapter_driver_info:
  814. .. rst-class:: classref-method
  815. :ref:`PackedStringArray<class_PackedStringArray>` **get_video_adapter_driver_info**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_get_video_adapter_driver_info>`
  816. Returns the video adapter driver name and version for the user's currently active graphics card, as a :ref:`PackedStringArray<class_PackedStringArray>`. See also :ref:`RenderingServer.get_video_adapter_api_version<class_RenderingServer_method_get_video_adapter_api_version>`.
  817. The first element holds the driver name, such as ``nvidia``, ``amdgpu``, etc.
  818. The second element holds the driver version. For example, on the ``nvidia`` driver on a Linux/BSD platform, the version is in the format ``510.85.02``. For Windows, the driver's format is ``31.0.15.1659``.
  819. \ **Note:** This method is only supported on Linux/BSD and Windows when not running in headless mode. On other platforms, it returns an empty array.
  820. .. rst-class:: classref-item-separator
  821. ----
  822. .. _class_OS_method_has_environment:
  823. .. rst-class:: classref-method
  824. :ref:`bool<class_bool>` **has_environment**\ (\ variable\: :ref:`String<class_String>`\ ) |const| :ref:`๐Ÿ”—<class_OS_method_has_environment>`
  825. Returns ``true`` if the environment variable with the name ``variable`` exists.
  826. \ **Note:** Double-check the casing of ``variable``. Environment variable names are case-sensitive on all platforms except Windows.
  827. .. rst-class:: classref-item-separator
  828. ----
  829. .. _class_OS_method_has_feature:
  830. .. rst-class:: classref-method
  831. :ref:`bool<class_bool>` **has_feature**\ (\ tag_name\: :ref:`String<class_String>`\ ) |const| :ref:`๐Ÿ”—<class_OS_method_has_feature>`
  832. Returns ``true`` if the feature for the given feature tag is supported in the currently running instance, depending on the platform, build, etc. Can be used to check whether you're currently running a debug build, on a certain platform or arch, etc. Refer to the :doc:`Feature Tags <../tutorials/export/feature_tags>` documentation for more details.
  833. \ **Note:** Tag names are case-sensitive.
  834. \ **Note:** On the Web platform, one of the following additional tags is defined to indicate the host platform: ``web_android``, ``web_ios``, ``web_linuxbsd``, ``web_macos``, or ``web_windows``.
  835. .. rst-class:: classref-item-separator
  836. ----
  837. .. _class_OS_method_is_debug_build:
  838. .. rst-class:: classref-method
  839. :ref:`bool<class_bool>` **is_debug_build**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_is_debug_build>`
  840. Returns ``true`` if the Godot binary used to run the project is a *debug* export template, or when running in the editor.
  841. Returns ``false`` if the Godot binary used to run the project is a *release* export template.
  842. \ **Note:** To check whether the Godot binary used to run the project is an export template (debug or release), use ``OS.has_feature("template")`` instead.
  843. .. rst-class:: classref-item-separator
  844. ----
  845. .. _class_OS_method_is_keycode_unicode:
  846. .. rst-class:: classref-method
  847. :ref:`bool<class_bool>` **is_keycode_unicode**\ (\ code\: :ref:`int<class_int>`\ ) |const| :ref:`๐Ÿ”—<class_OS_method_is_keycode_unicode>`
  848. Returns ``true`` if the input keycode corresponds to a Unicode character. For a list of codes, see the :ref:`Key<enum_@GlobalScope_Key>` constants.
  849. .. tabs::
  850. .. code-tab:: gdscript
  851. print(OS.is_keycode_unicode(KEY_G)) # Prints true
  852. print(OS.is_keycode_unicode(KEY_KP_4)) # Prints true
  853. print(OS.is_keycode_unicode(KEY_TAB)) # Prints false
  854. print(OS.is_keycode_unicode(KEY_ESCAPE)) # Prints false
  855. .. code-tab:: csharp
  856. GD.Print(OS.IsKeycodeUnicode((long)Key.G)); // Prints true
  857. GD.Print(OS.IsKeycodeUnicode((long)Key.Kp4)); // Prints true
  858. GD.Print(OS.IsKeycodeUnicode((long)Key.Tab)); // Prints false
  859. GD.Print(OS.IsKeycodeUnicode((long)Key.Escape)); // Prints false
  860. .. rst-class:: classref-item-separator
  861. ----
  862. .. _class_OS_method_is_process_running:
  863. .. rst-class:: classref-method
  864. :ref:`bool<class_bool>` **is_process_running**\ (\ pid\: :ref:`int<class_int>`\ ) |const| :ref:`๐Ÿ”—<class_OS_method_is_process_running>`
  865. Returns ``true`` if the child process ID (``pid``) is still running or ``false`` if it has terminated. ``pid`` must be a valid ID generated from :ref:`create_process<class_OS_method_create_process>`.
  866. \ **Note:** This method is implemented on Android, iOS, Linux, macOS, and Windows.
  867. .. rst-class:: classref-item-separator
  868. ----
  869. .. _class_OS_method_is_restart_on_exit_set:
  870. .. rst-class:: classref-method
  871. :ref:`bool<class_bool>` **is_restart_on_exit_set**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_is_restart_on_exit_set>`
  872. Returns ``true`` if the project will automatically restart when it exits for any reason, ``false`` otherwise. See also :ref:`set_restart_on_exit<class_OS_method_set_restart_on_exit>` and :ref:`get_restart_on_exit_arguments<class_OS_method_get_restart_on_exit_arguments>`.
  873. .. rst-class:: classref-item-separator
  874. ----
  875. .. _class_OS_method_is_sandboxed:
  876. .. rst-class:: classref-method
  877. :ref:`bool<class_bool>` **is_sandboxed**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_is_sandboxed>`
  878. Returns ``true`` if the application is running in the sandbox.
  879. \ **Note:** This method is only implemented on macOS and Linux.
  880. .. rst-class:: classref-item-separator
  881. ----
  882. .. _class_OS_method_is_stdout_verbose:
  883. .. rst-class:: classref-method
  884. :ref:`bool<class_bool>` **is_stdout_verbose**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_is_stdout_verbose>`
  885. Returns ``true`` if the engine was executed with the ``--verbose`` or ``-v`` command line argument, or if :ref:`ProjectSettings.debug/settings/stdout/verbose_stdout<class_ProjectSettings_property_debug/settings/stdout/verbose_stdout>` is ``true``. See also :ref:`@GlobalScope.print_verbose<class_@GlobalScope_method_print_verbose>`.
  886. .. rst-class:: classref-item-separator
  887. ----
  888. .. _class_OS_method_is_userfs_persistent:
  889. .. rst-class:: classref-method
  890. :ref:`bool<class_bool>` **is_userfs_persistent**\ (\ ) |const| :ref:`๐Ÿ”—<class_OS_method_is_userfs_persistent>`
  891. Returns ``true`` if the ``user://`` file system is persistent, that is, its state is the same after a player quits and starts the game again. Relevant to the Web platform, where this persistence may be unavailable.
  892. .. rst-class:: classref-item-separator
  893. ----
  894. .. _class_OS_method_kill:
  895. .. rst-class:: classref-method
  896. :ref:`Error<enum_@GlobalScope_Error>` **kill**\ (\ pid\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_OS_method_kill>`
  897. Kill (terminate) the process identified by the given process ID (``pid``), such as the ID returned by :ref:`execute<class_OS_method_execute>` in non-blocking mode. See also :ref:`crash<class_OS_method_crash>`.
  898. \ **Note:** This method can also be used to kill processes that were not spawned by the engine.
  899. \ **Note:** This method is implemented on Android, iOS, Linux, macOS and Windows.
  900. .. rst-class:: classref-item-separator
  901. ----
  902. .. _class_OS_method_move_to_trash:
  903. .. rst-class:: classref-method
  904. :ref:`Error<enum_@GlobalScope_Error>` **move_to_trash**\ (\ path\: :ref:`String<class_String>`\ ) |const| :ref:`๐Ÿ”—<class_OS_method_move_to_trash>`
  905. Moves the file or directory at the given ``path`` to the system's recycle bin. See also :ref:`DirAccess.remove<class_DirAccess_method_remove>`.
  906. The method takes only global paths, so you may need to use :ref:`ProjectSettings.globalize_path<class_ProjectSettings_method_globalize_path>`. Do not use it for files in ``res://`` as it will not work in exported projects.
  907. Returns :ref:`@GlobalScope.FAILED<class_@GlobalScope_constant_FAILED>` if the file or directory cannot be found, or the system does not support this method.
  908. .. tabs::
  909. .. code-tab:: gdscript
  910. var file_to_remove = "user://slot1.save"
  911. OS.move_to_trash(ProjectSettings.globalize_path(file_to_remove))
  912. .. code-tab:: csharp
  913. var fileToRemove = "user://slot1.save";
  914. OS.MoveToTrash(ProjectSettings.GlobalizePath(fileToRemove));
  915. \ **Note:** This method is implemented on Android, Linux, macOS and Windows.
  916. \ **Note:** If the user has disabled the recycle bin on their system, the file will be permanently deleted instead.
  917. .. rst-class:: classref-item-separator
  918. ----
  919. .. _class_OS_method_open_midi_inputs:
  920. .. rst-class:: classref-method
  921. |void| **open_midi_inputs**\ (\ ) :ref:`๐Ÿ”—<class_OS_method_open_midi_inputs>`
  922. Initializes the singleton for the system MIDI driver, allowing Godot to receive :ref:`InputEventMIDI<class_InputEventMIDI>`. See also :ref:`get_connected_midi_inputs<class_OS_method_get_connected_midi_inputs>` and :ref:`close_midi_inputs<class_OS_method_close_midi_inputs>`.
  923. \ **Note:** This method is implemented on Linux, macOS, and Windows.
  924. .. rst-class:: classref-item-separator
  925. ----
  926. .. _class_OS_method_read_buffer_from_stdin:
  927. .. rst-class:: classref-method
  928. :ref:`PackedByteArray<class_PackedByteArray>` **read_buffer_from_stdin**\ (\ buffer_size\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_OS_method_read_buffer_from_stdin>`
  929. Reads a user input as raw data from the standard input. This operation can be *blocking*, which causes the window to freeze if :ref:`read_string_from_stdin<class_OS_method_read_string_from_stdin>` is called on the main thread.
  930. - If standard input is console, this method will block until the program receives a line break in standard input (usually by the user pressing :kbd:`Enter`).
  931. - If standard input is pipe, this method will block until a specific amount of data is read or pipe is closed.
  932. - If standard input is a file, this method will read a specific amount of data (or less if end-of-file is reached) and return immediately.
  933. \ **Note:** This method is implemented on Linux, macOS, and Windows.
  934. \ **Note:** On exported Windows builds, run the console wrapper executable to access the terminal. If standard input is console, calling this method without console wrapped will freeze permanently. If standard input is pipe or file, it can be used without console wrapper. If you need a single executable with full console support, use a custom build compiled with the ``windows_subsystem=console`` flag.
  935. .. rst-class:: classref-item-separator
  936. ----
  937. .. _class_OS_method_read_string_from_stdin:
  938. .. rst-class:: classref-method
  939. :ref:`String<class_String>` **read_string_from_stdin**\ (\ buffer_size\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_OS_method_read_string_from_stdin>`
  940. Reads a user input as a UTF-8 encoded string from the standard input. This operation can be *blocking*, which causes the window to freeze if :ref:`read_string_from_stdin<class_OS_method_read_string_from_stdin>` is called on the main thread.
  941. - If standard input is console, this method will block until the program receives a line break in standard input (usually by the user pressing :kbd:`Enter`).
  942. - If standard input is pipe, this method will block until a specific amount of data is read or pipe is closed.
  943. - If standard input is a file, this method will read a specific amount of data (or less if end-of-file is reached) and return immediately.
  944. \ **Note:** This method is implemented on Linux, macOS, and Windows.
  945. \ **Note:** On exported Windows builds, run the console wrapper executable to access the terminal. If standard input is console, calling this method without console wrapped will freeze permanently. If standard input is pipe or file, it can be used without console wrapper. If you need a single executable with full console support, use a custom build compiled with the ``windows_subsystem=console`` flag.
  946. .. rst-class:: classref-item-separator
  947. ----
  948. .. _class_OS_method_request_permission:
  949. .. rst-class:: classref-method
  950. :ref:`bool<class_bool>` **request_permission**\ (\ name\: :ref:`String<class_String>`\ ) :ref:`๐Ÿ”—<class_OS_method_request_permission>`
  951. Requests permission from the OS for the given ``name``. Returns ``true`` if the permission has been successfully granted.
  952. \ **Note:** This method is currently only implemented on Android, to specifically request permission for ``"RECORD_AUDIO"`` by ``AudioDriverOpenSL``.
  953. .. rst-class:: classref-item-separator
  954. ----
  955. .. _class_OS_method_request_permissions:
  956. .. rst-class:: classref-method
  957. :ref:`bool<class_bool>` **request_permissions**\ (\ ) :ref:`๐Ÿ”—<class_OS_method_request_permissions>`
  958. Requests *dangerous* permissions from the OS. Returns ``true`` if permissions have been successfully granted.
  959. \ **Note:** This method is only implemented on Android. Normal permissions are automatically granted at install time in Android applications.
  960. .. rst-class:: classref-item-separator
  961. ----
  962. .. _class_OS_method_revoke_granted_permissions:
  963. .. rst-class:: classref-method
  964. |void| **revoke_granted_permissions**\ (\ ) :ref:`๐Ÿ”—<class_OS_method_revoke_granted_permissions>`
  965. On macOS (sandboxed applications only), this function clears list of user selected folders accessible to the application.
  966. .. rst-class:: classref-item-separator
  967. ----
  968. .. _class_OS_method_set_environment:
  969. .. rst-class:: classref-method
  970. |void| **set_environment**\ (\ variable\: :ref:`String<class_String>`, value\: :ref:`String<class_String>`\ ) |const| :ref:`๐Ÿ”—<class_OS_method_set_environment>`
  971. Sets the value of the environment variable ``variable`` to ``value``. The environment variable will be set for the Godot process and any process executed with :ref:`execute<class_OS_method_execute>` after running :ref:`set_environment<class_OS_method_set_environment>`. The environment variable will *not* persist to processes run after the Godot process was terminated.
  972. \ **Note:** Environment variable names are case-sensitive on all platforms except Windows. The ``variable`` name cannot be empty or include the ``=`` character. On Windows, there is a 32767 characters limit for the combined length of ``variable``, ``value``, and the ``=`` and null terminator characters that will be registered in the environment block.
  973. .. rst-class:: classref-item-separator
  974. ----
  975. .. _class_OS_method_set_restart_on_exit:
  976. .. rst-class:: classref-method
  977. |void| **set_restart_on_exit**\ (\ restart\: :ref:`bool<class_bool>`, arguments\: :ref:`PackedStringArray<class_PackedStringArray>` = PackedStringArray()\ ) :ref:`๐Ÿ”—<class_OS_method_set_restart_on_exit>`
  978. If ``restart`` is ``true``, restarts the project automatically when it is exited with :ref:`SceneTree.quit<class_SceneTree_method_quit>` or :ref:`Node.NOTIFICATION_WM_CLOSE_REQUEST<class_Node_constant_NOTIFICATION_WM_CLOSE_REQUEST>`. Command-line ``arguments`` can be supplied. To restart the project with the same command line arguments as originally used to run the project, pass :ref:`get_cmdline_args<class_OS_method_get_cmdline_args>` as the value for ``arguments``.
  979. This method can be used to apply setting changes that require a restart. See also :ref:`is_restart_on_exit_set<class_OS_method_is_restart_on_exit_set>` and :ref:`get_restart_on_exit_arguments<class_OS_method_get_restart_on_exit_arguments>`.
  980. \ **Note:** This method is only effective on desktop platforms, and only when the project isn't started from the editor. It will have no effect on mobile and Web platforms, or when the project is started from the editor.
  981. \ **Note:** If the project process crashes or is *killed* by the user (by sending ``SIGKILL`` instead of the usual ``SIGTERM``), the project won't restart automatically.
  982. .. rst-class:: classref-item-separator
  983. ----
  984. .. _class_OS_method_set_thread_name:
  985. .. rst-class:: classref-method
  986. :ref:`Error<enum_@GlobalScope_Error>` **set_thread_name**\ (\ name\: :ref:`String<class_String>`\ ) :ref:`๐Ÿ”—<class_OS_method_set_thread_name>`
  987. Assigns the given name to the current thread. Returns :ref:`@GlobalScope.ERR_UNAVAILABLE<class_@GlobalScope_constant_ERR_UNAVAILABLE>` if unavailable on the current platform.
  988. .. rst-class:: classref-item-separator
  989. ----
  990. .. _class_OS_method_set_use_file_access_save_and_swap:
  991. .. rst-class:: classref-method
  992. |void| **set_use_file_access_save_and_swap**\ (\ enabled\: :ref:`bool<class_bool>`\ ) :ref:`๐Ÿ”—<class_OS_method_set_use_file_access_save_and_swap>`
  993. If ``enabled`` is ``true``, when opening a file for writing, a temporary file is used in its place. When closed, it is automatically applied to the target file.
  994. This can useful when files may be opened by other applications, such as antiviruses, text editors, or even the Godot editor itself.
  995. .. rst-class:: classref-item-separator
  996. ----
  997. .. _class_OS_method_shell_open:
  998. .. rst-class:: classref-method
  999. :ref:`Error<enum_@GlobalScope_Error>` **shell_open**\ (\ uri\: :ref:`String<class_String>`\ ) :ref:`๐Ÿ”—<class_OS_method_shell_open>`
  1000. Requests the OS to open a resource identified by ``uri`` with the most appropriate program. For example:
  1001. - ``OS.shell_open("C:\\Users\name\Downloads")`` on Windows opens the file explorer at the user's Downloads folder.
  1002. - ``OS.shell_open("https://godotengine.org")`` opens the default web browser on the official Godot website.
  1003. - ``OS.shell_open("mailto:example@example.com")`` opens the default email client with the "To" field set to ``example@example.com``. See `RFC 2368 - The [code]mailto[/code] URL scheme <https://datatracker.ietf.org/doc/html/rfc2368>`__ for a list of fields that can be added.
  1004. Use :ref:`ProjectSettings.globalize_path<class_ProjectSettings_method_globalize_path>` to convert a ``res://`` or ``user://`` project path into a system path for use with this method.
  1005. \ **Note:** Use :ref:`String.uri_encode<class_String_method_uri_encode>` to encode characters within URLs in a URL-safe, portable way. This is especially required for line breaks. Otherwise, :ref:`shell_open<class_OS_method_shell_open>` may not work correctly in a project exported to the Web platform.
  1006. \ **Note:** This method is implemented on Android, iOS, Web, Linux, macOS and Windows.
  1007. .. rst-class:: classref-item-separator
  1008. ----
  1009. .. _class_OS_method_shell_show_in_file_manager:
  1010. .. rst-class:: classref-method
  1011. :ref:`Error<enum_@GlobalScope_Error>` **shell_show_in_file_manager**\ (\ file_or_dir_path\: :ref:`String<class_String>`, open_folder\: :ref:`bool<class_bool>` = true\ ) :ref:`๐Ÿ”—<class_OS_method_shell_show_in_file_manager>`
  1012. Requests the OS to open the file manager, navigate to the given ``file_or_dir_path`` and select the target file or folder.
  1013. If ``open_folder`` is ``true`` and ``file_or_dir_path`` is a valid directory path, the OS will open the file manager and navigate to the target folder without selecting anything.
  1014. Use :ref:`ProjectSettings.globalize_path<class_ProjectSettings_method_globalize_path>` to convert a ``res://`` or ``user://`` project path into a system path to use with this method.
  1015. \ **Note:** This method is currently only implemented on Windows and macOS. On other platforms, it will fallback to :ref:`shell_open<class_OS_method_shell_open>` with a directory path of ``file_or_dir_path`` prefixed with ``file://``.
  1016. .. rst-class:: classref-item-separator
  1017. ----
  1018. .. _class_OS_method_unset_environment:
  1019. .. rst-class:: classref-method
  1020. |void| **unset_environment**\ (\ variable\: :ref:`String<class_String>`\ ) |const| :ref:`๐Ÿ”—<class_OS_method_unset_environment>`
  1021. Removes the given environment variable from the current environment, if it exists. The ``variable`` name cannot be empty or include the ``=`` character. The environment variable will be removed for the Godot process and any process executed with :ref:`execute<class_OS_method_execute>` after running :ref:`unset_environment<class_OS_method_unset_environment>`. The removal of the environment variable will *not* persist to processes run after the Godot process was terminated.
  1022. \ **Note:** Environment variable names are case-sensitive on all platforms except Windows.
  1023. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  1024. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  1025. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  1026. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  1027. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  1028. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  1029. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  1030. .. |void| replace:: :abbr:`void (No return value.)`