.. _stdlib_fio: ========================= File input output library ========================= .. das:module:: fio The FIO module implements file input/output and filesystem operations. It provides functions for reading and writing files (``fopen``, ``fread``, ``fwrite``), directory management (``mkdir``, ``dir``), path manipulation (``join_path``, ``basename``, ``dirname``), and file metadata queries (``stat``, ``file_time``). All functions and symbols are in "fio" module, use require to get access to it. .. code-block:: das require daslib/fio Example: .. code-block:: das require daslib/fio [export] def main() { let fname = "_test_fio_tmp.txt" fopen(fname, "wb") $(f) { fwrite(f, "hello, daslang!") } fopen(fname, "rb") $(f) { let content = fread(f) print("{content}\n") } remove(fname) } // output: // hello, daslang! ++++++++++++ Type aliases ++++++++++++ .. _alias-file: .. das:attribute:: file = FILE const? typedef file = fio_core::FILE const? aka file .. _alias-fs_result_bool: .. das:attribute:: variant fs_result_bool variant aka fs_result_bool .. _alias-fs_result_int64: .. das:attribute:: variant fs_result_int64 variant aka fs_result_int64 .. _alias-fs_result_string: .. das:attribute:: variant fs_result_string variant aka fs_result_string +++++++++ Constants +++++++++ .. _global-fio-seek_set: .. das:attribute:: seek_set = 0 Constant for fseek that positions the file pointer relative to the beginning of the file by the given offset. .. _global-fio-seek_cur: .. das:attribute:: seek_cur = 1 Constant for fseek that positions the file pointer relative to its current position by the given offset. .. _global-fio-seek_end: .. das:attribute:: seek_end = 2 Constant for fseek that positions the file pointer relative to the end of the file by the given offset. .. _global-fio-popen_timed_out: .. das:attribute:: popen_timed_out = 2147483393 Sentinel exit code returned by `popen_timeout` when the process was killed due to exceeding the timeout. .. _global-fio-df_magic: .. das:attribute:: df_magic = 0x12345678 df_magic:uint const ++++++++++ Structures ++++++++++ .. _struct-fio-df_header: .. das:attribute:: df_header struct df_header ++++++++++++++++++ Handled structures ++++++++++++++++++ .. _handle-fio-DiskSpaceInfo: .. das:attribute:: DiskSpaceInfo Disk space information for a filesystem. :Fields: * **capacity** : uint64 - Total storage capacity in bytes. * **free** : uint64 - Amount of free space in bytes. * **available** : uint64 - Amount of space available to non-privileged users in bytes. .. _handle-fio-FStat: .. das:attribute:: FStat .. _function-fio__dot__rq_size_FStat: .. das:function:: FStat.size() : uint64 Returns the size of the file in bytes. .. _function-fio__dot__rq_atime_FStat: .. das:function:: FStat.atime() : clock Returns the last access time of the file as a clock value. .. _function-fio__dot__rq_ctime_FStat: .. das:function:: FStat.ctime() : clock Returns the creation time of the file as a clock value. .. _function-fio__dot__rq_mtime_FStat: .. das:function:: FStat.mtime() : clock Returns the last modification time of the file as a clock value. .. _function-fio__dot__rq_is_reg_FStat: .. das:function:: FStat.is_reg() : bool Returns true if the file status indicates a regular file. .. _function-fio__dot__rq_is_dir_FStat: .. das:function:: FStat.is_dir() : bool Returns true if the file status indicates a directory. :Properties: * **size** : uint64 * **atime** : :ref:`clock ` * **ctime** : :ref:`clock ` * **mtime** : :ref:`clock ` * **is_reg** : bool * **is_dir** : bool :Fields: * **is_valid** : bool - `stat` and `fstat` return file information in this structure. +++++++++++++ Handled types +++++++++++++ .. _handle-fio-FILE: .. das:attribute:: FILE Opaque handle wrapping the platform-specific C FILE type used by all low-level file I/O functions. +++++++++++++++++ File manipulation +++++++++++++++++ * :ref:`copy_file (src: string; dst: string; overwrite: bool; error: string&) : bool ` * :ref:`copy_file_result (src: string; dst: string; overwrite: bool) : fs_result_bool ` * :ref:`equivalent (a: string; b: string; error: string&) : bool ` * :ref:`equivalent_result (a: string; b: string) : fs_result_bool ` * :ref:`fclose (file: FILE const?) ` * :ref:`feof (file: FILE const?) : bool ` * :ref:`fexist (path: string) : bool ` * :ref:`fflush (file: FILE const?) ` * :ref:`fgets (file: FILE const?) : string ` * :ref:`file_size (path: string; error: string&) : int64 ` * :ref:`file_size_result (path: string) : fs_result_int64 ` * :ref:`fload (file: file; size: int; blk: block\<(data:array\):void\>) ` * :ref:`fload (f: file; var buf: auto(BufType)) : auto ` * :ref:`fmap (file: FILE const?; block: block\<(array\#):void\>) ` * :ref:`fopen (name: string; mode: string; blk: block\<(f:file):void\>) : auto ` * :ref:`fopen (name: string; mode: string) : FILE const? ` * :ref:`fprint (file: FILE const?; text: string) ` * :ref:`fread (file: FILE const?) : string ` * :ref:`fread (f: file; buf: auto(BufType)) : auto ` * :ref:`fread (f: file; buf: array\) : auto ` * :ref:`fread (f: file; blk: block\<(data:string#):auto\>) : auto ` * :ref:`fread (path: string) : string ` * :ref:`fsave (f: file; buf: auto(BufType)) : auto ` * :ref:`fseek (file: FILE const?; offset: int64; mode: int) : int64 ` * :ref:`fstat (file: FILE const?; stat: FStat) : bool ` * :ref:`fstat (f: file) : FStat ` * :ref:`fstderr () : FILE const? ` * :ref:`fstdin () : FILE const? ` * :ref:`fstdout () : FILE const? ` * :ref:`ftell (file: FILE const?) : int64 ` * :ref:`fwrite (f: file; buf: array\) : auto ` * :ref:`fwrite (file: FILE const?; text: string) ` * :ref:`fwrite (f: file; buf: auto(BufType)) : auto ` * :ref:`fwrite (path: string; text: string) : bool ` * :ref:`getchar () : int ` * :ref:`is_symlink (path: string; error: string&) : bool ` * :ref:`is_symlink_result (path: string) : fs_result_bool ` * :ref:`remove (name: string; error: string&) : bool ` * :ref:`remove (name: string) : bool ` * :ref:`remove_result (path: string) : fs_result_bool ` * :ref:`rename (old_name: string; new_name: string; error: string&) : bool ` * :ref:`rename (old_name: string; new_name: string) : bool ` * :ref:`rename_result (old_name: string; new_name: string) : fs_result_bool ` * :ref:`set_mtime (path: string; time: clock; error: string&) : bool ` * :ref:`set_mtime_result (path: string; time: Time) : fs_result_bool ` * :ref:`stat (path: string) : FStat ` * :ref:`stat (file: string; stat: FStat) : bool ` .. _function-fio_copy_file_string_string_bool_string_ref_: .. das:function:: copy_file(src: string; dst: string; overwrite: bool; error: string&) : bool Copies a file from src to dst. Reports errors via the error out-parameter. If overwrite is false, fails when dst already exists. :Arguments: * **src** : string implicit * **dst** : string implicit * **overwrite** : bool * **error** : string\ & implicit .. _function-fio_copy_file_result_string_string_bool: .. das:function:: copy_file_result(src: string; dst: string; overwrite: bool) : fs_result_bool def copy_file_result (src: string; dst: string; overwrite: bool) : fs_result_bool :Arguments: * **src** : string * **dst** : string * **overwrite** : bool .. _function-fio_equivalent_string_string_string_ref_: .. das:function:: equivalent(a: string; b: string; error: string&) : bool Returns true if two paths refer to the same file or directory. Reports errors via the error out-parameter. :Arguments: * **a** : string implicit * **b** : string implicit * **error** : string\ & implicit .. _function-fio_equivalent_result_string_string: .. das:function:: equivalent_result(a: string; b: string) : fs_result_bool def equivalent_result (a: string; b: string) : fs_result_bool :Arguments: * **a** : string * **b** : string .. _function-fio_fclose_FILE_const_q_: .. das:function:: fclose(file: FILE const?) Closes the given FILE pointer and releases its associated resources, equivalent to C fclose. :Arguments: * **file** : :ref:`FILE `? implicit .. _function-fio_feof_FILE_const_q_: .. das:function:: feof(file: FILE const?) : bool Returns true if the end-of-file indicator has been set on the given FILE pointer, equivalent to C feof. :Arguments: * **file** : :ref:`FILE `? implicit .. _function-fio_fexist_string: .. das:function:: fexist(path: string) : bool Returns true if a file or directory exists at the given path. :Arguments: * **path** : string implicit .. _function-fio_fflush_FILE_const_q_: .. das:function:: fflush(file: FILE const?) Flushes any buffered output data for the given FILE pointer to the underlying file, equivalent to C fflush. :Arguments: * **file** : :ref:`FILE `? implicit .. _function-fio_fgets_FILE_const_q_: .. das:function:: fgets(file: FILE const?) : string Reads and returns the next line as a string from the given FILE pointer, equivalent to C fgets. :Arguments: * **file** : :ref:`FILE `? implicit .. _function-fio_file_size_string_string_ref_: .. das:function:: file_size(path: string; error: string&) : int64 Returns the size of a file in bytes. Reports errors via the error out-parameter. :Arguments: * **path** : string implicit * **error** : string\ & implicit .. _function-fio_file_size_result_string: .. das:function:: file_size_result(path: string) : fs_result_int64 def file_size_result (path: string) : fs_result_int64 :Arguments: * **path** : string fload ^^^^^ .. _function-fio_fload_file_int_block_ls_data_c_array_ls_uint8_gr__c_void_gr_: .. das:function:: fload(file: file; size: int; blk: block<(data:array):void>) def fload (file: file; size: int; blk: block<(data:array):void>) :Arguments: * **file** : :ref:`file ` * **size** : int * **blk** : block<(data:array):void> .. _function-fio_fload_file_autoBufType_0x46: .. das:function:: fload(f: file; buf: auto(BufType)) : auto ---- .. _function-fio_fmap_FILE_const_q__block_ls_array_ls_uint8_gr__hh__c_void_gr_: .. das:function:: fmap(file: FILE const?; block: block<(array#):void>) Memory-maps the contents of the given FILE pointer and provides the data as an array of uint8 inside the block. :Arguments: * **file** : :ref:`FILE `? implicit * **block** : block<(array\ #):void> implicit fopen ^^^^^ .. _function-fio_fopen_string_string_block_ls_f_c_file_c_void_gr_: .. das:function:: fopen(name: string; mode: string; blk: block<(f:file):void>) : auto def fopen (name: string; mode: string; blk: block<(f:file):void>) : auto :Arguments: * **name** : string * **mode** : string * **blk** : block<(f: :ref:`file `):void> .. _function-fio_fopen_string_string: .. das:function:: fopen(name: string; mode: string) : FILE const? ---- .. _function-fio_fprint_FILE_const_q__string: .. das:function:: fprint(file: FILE const?; text: string) Writes the given text string to the specified FILE pointer, equivalent to print but targeting a file. :Arguments: * **file** : :ref:`FILE `? implicit * **text** : string implicit fread ^^^^^ .. _function-fio_fread_FILE_const_q_: .. das:function:: fread(file: FILE const?) : string Reads the entire contents of an open file and returns it as a string. :Arguments: * **file** : :ref:`FILE `? implicit .. _function-fio_fread_file_autoBufType_0x6e: .. das:function:: fread(f: file; buf: auto(BufType)) : auto .. _function-fio_fread_file_array_ls_autoBufType_gr_: .. das:function:: fread(f: file; buf: array) : auto .. _function-fio_fread_file_block_ls_data_c_string_hh__c_auto_gr_: .. das:function:: fread(f: file; blk: block<(data:string#):auto>) : auto .. _function-fio_fread_string: .. das:function:: fread(path: string) : string ---- .. _function-fio_fsave_file_autoBufType_0x5a: .. das:function:: fsave(f: file; buf: auto(BufType)) : auto def fsave (f: file; buf: auto(BufType)) : auto :Arguments: * **f** : :ref:`file ` * **buf** : auto(BufType) .. _function-fio_fseek_FILE_const_q__int64_int: .. das:function:: fseek(file: FILE const?; offset: int64; mode: int) : int64 Repositions the file pointer of the given FILE to the specified offset relative to the mode (seek_set, seek_cur, or seek_end) and returns the new position. :Arguments: * **file** : :ref:`FILE `? implicit * **offset** : int64 * **mode** : int fstat ^^^^^ .. _function-fio_fstat_FILE_const_q__FStat: .. das:function:: fstat(file: FILE const?; stat: FStat) : bool Retrieves file metadata such as size and timestamps into an FStat structure from a file handle, equivalent to C fstat. :Arguments: * **file** : :ref:`FILE `? implicit * **stat** : :ref:`FStat ` implicit .. _function-fio_fstat_file: .. das:function:: fstat(f: file) : FStat ---- .. _function-fio_fstderr: .. das:function:: fstderr() : FILE const? Returns the FILE pointer corresponding to the standard error stream. .. _function-fio_fstdin: .. das:function:: fstdin() : FILE const? Returns the FILE pointer corresponding to the standard input stream. .. _function-fio_fstdout: .. das:function:: fstdout() : FILE const? Returns the FILE pointer corresponding to the standard output stream. .. _function-fio_ftell_FILE_const_q_: .. das:function:: ftell(file: FILE const?) : int64 Returns the current byte offset of the file pointer for the given FILE, equivalent to C ftell. :Arguments: * **file** : :ref:`FILE `? implicit fwrite ^^^^^^ .. _function-fio_fwrite_file_array_ls_autoBufType_gr_: .. das:function:: fwrite(f: file; buf: array) : auto def fwrite (f: file; buf: array) : auto :Arguments: * **f** : :ref:`file ` * **buf** : array implicit .. _function-fio_fwrite_FILE_const_q__string: .. das:function:: fwrite(file: FILE const?; text: string) .. _function-fio_fwrite_file_autoBufType_0x7e: .. das:function:: fwrite(f: file; buf: auto(BufType)) : auto .. _function-fio_fwrite_string_string: .. das:function:: fwrite(path: string; text: string) : bool ---- .. _function-fio_getchar: .. das:function:: getchar() : int Reads and returns the next character from standard input as an integer, equivalent to C getchar. .. _function-fio_is_symlink_string_string_ref_: .. das:function:: is_symlink(path: string; error: string&) : bool Returns true if the path is a symbolic link. Reports errors via the error out-parameter. :Arguments: * **path** : string implicit * **error** : string\ & implicit .. _function-fio_is_symlink_result_string: .. das:function:: is_symlink_result(path: string) : fs_result_bool def is_symlink_result (path: string) : fs_result_bool :Arguments: * **path** : string remove ^^^^^^ .. _function-fio_remove_string_string_ref_: .. das:function:: remove(name: string; error: string&) : bool Removes a file at the specified path. Reports errors via the error out-parameter. :Arguments: * **name** : string implicit * **error** : string\ & implicit .. _function-fio_remove_string: .. das:function:: remove(name: string) : bool ---- .. _function-fio_remove_result_string: .. das:function:: remove_result(path: string) : fs_result_bool def remove_result (path: string) : fs_result_bool :Arguments: * **path** : string rename ^^^^^^ .. _function-fio_rename_string_string_string_ref_: .. das:function:: rename(old_name: string; new_name: string; error: string&) : bool Renames or moves a file or directory from src to dst. Reports errors via the error out-parameter. :Arguments: * **old_name** : string implicit * **new_name** : string implicit * **error** : string\ & implicit .. _function-fio_rename_string_string: .. das:function:: rename(old_name: string; new_name: string) : bool ---- .. _function-fio_rename_result_string_string: .. das:function:: rename_result(old_name: string; new_name: string) : fs_result_bool def rename_result (old_name: string; new_name: string) : fs_result_bool :Arguments: * **old_name** : string * **new_name** : string .. _function-fio_set_mtime_string_clock_string_ref_: .. das:function:: set_mtime(path: string; time: clock; error: string&) : bool Sets the last modification time of a file or directory. Reports errors via the error out-parameter. :Arguments: * **path** : string implicit * **time** : :ref:`clock ` * **error** : string\ & implicit .. _function-fio_set_mtime_result_string_Time: .. das:function:: set_mtime_result(path: string; time: Time) : fs_result_bool def set_mtime_result (path: string; time: Time) : fs_result_bool :Arguments: * **path** : string * **time** : Time stat ^^^^ .. _function-fio_stat_string: .. das:function:: stat(path: string) : FStat def stat (path: string) : FStat :Arguments: * **path** : string .. _function-fio_stat_string_FStat: .. das:function:: stat(file: string; stat: FStat) : bool +++++++++++++++++ Path manipulation +++++++++++++++++ * :ref:`base_name (name: string) : string ` * :ref:`dir_name (name: string) : string ` * :ref:`extension (path: string) : string ` * :ref:`get_full_file_name (path: string) : string ` * :ref:`is_absolute (path: string) : bool ` * :ref:`normalize (path: string) : string ` * :ref:`parent (path: string) : string ` * :ref:`path_join (a: string; b: string) : string ` * :ref:`relative (path: string; base: string; error: string&) : string ` * :ref:`relative_result (path: string; base: string) : fs_result_string ` * :ref:`replace_extension (path: string; new_ext: string) : string ` * :ref:`stem (path: string) : string ` .. _function-fio_base_name_string: .. das:function:: base_name(name: string) : string Extracts and returns the final component of a file path, equivalent to POSIX basename. :Arguments: * **name** : string implicit .. _function-fio_dir_name_string: .. das:function:: dir_name(name: string) : string Extracts and returns the directory component of a file path, equivalent to POSIX dirname. :Arguments: * **name** : string implicit .. _function-fio_extension_string: .. das:function:: extension(path: string) : string Returns the file extension including the dot (e.g. ".txt"), or empty string if no extension. :Arguments: * **path** : string implicit .. _function-fio_get_full_file_name_string: .. das:function:: get_full_file_name(path: string) : string Returns the fully resolved and normalized absolute path for the given file path string. :Arguments: * **path** : string implicit .. _function-fio_is_absolute_string: .. das:function:: is_absolute(path: string) : bool Returns true if the path is an absolute path (rooted). :Arguments: * **path** : string implicit .. _function-fio_normalize_string: .. das:function:: normalize(path: string) : string Returns the lexically normalized path with redundant separators, "." and ".." resolved. :Arguments: * **path** : string implicit .. _function-fio_parent_string: .. das:function:: parent(path: string) : string Returns the parent directory of the path, or empty string if at root level. :Arguments: * **path** : string implicit .. _function-fio_path_join_string_string: .. das:function:: path_join(a: string; b: string) : string Joins two path components with the platform-native separator. :Arguments: * **a** : string implicit * **b** : string implicit .. _function-fio_relative_string_string_string_ref_: .. das:function:: relative(path: string; base: string; error: string&) : string Returns a relative path from base to path. Reports errors via the error out-parameter. :Arguments: * **path** : string implicit * **base** : string implicit * **error** : string\ & implicit .. _function-fio_relative_result_string_string: .. das:function:: relative_result(path: string; base: string) : fs_result_string def relative_result (path: string; base: string) : fs_result_string :Arguments: * **path** : string * **base** : string .. _function-fio_replace_extension_string_string: .. das:function:: replace_extension(path: string; new_ext: string) : string Returns a new path with the file extension replaced by new_ext (include the dot, e.g. ".md"). :Arguments: * **path** : string implicit * **new_ext** : string implicit .. _function-fio_stem_string: .. das:function:: stem(path: string) : string Returns the filename without its extension (e.g. "file" from "file.txt"). :Arguments: * **path** : string implicit ++++++++++++++++++++++ Directory manipulation ++++++++++++++++++++++ * :ref:`chdir (path: string) : bool ` * :ref:`dir (path: string; blk: block\<(filename:string):void\>) : auto ` * :ref:`dir_rec (path: string; blk: block\<(filename:string;is_dir:bool):void\>; var error: string&) : auto ` * :ref:`dir_rec (path: string; blk: block\<(filename:string;is_dir:bool):void\>) : auto ` * :ref:`getcwd () : string ` * :ref:`mkdir (path: string; error: string&) : bool ` * :ref:`mkdir (path: string) : bool ` * :ref:`mkdir_rec (path: string) : bool ` * :ref:`mkdir_rec (path: string; var error: string&) : bool ` * :ref:`mkdir_result (path: string) : fs_result_bool ` * :ref:`rmdir (path: string; error: string&) : bool ` * :ref:`rmdir (path: string) : bool ` * :ref:`rmdir_rec (path: string; error: string&) : bool ` * :ref:`rmdir_rec (path: string) : bool ` * :ref:`rmdir_rec_result (path: string) : fs_result_bool ` * :ref:`rmdir_result (path: string) : fs_result_bool ` .. _function-fio_chdir_string: .. das:function:: chdir(path: string) : bool Changes the current working directory to the specified path and returns true on success. :Arguments: * **path** : string implicit .. _function-fio_dir_string_block_ls_filename_c_string_c_void_gr_: .. das:function:: dir(path: string; blk: block<(filename:string):void>) : auto def dir (path: string; blk: block<(filename:string):void>) : auto :Arguments: * **path** : string * **blk** : block<(filename:string):void> dir_rec ^^^^^^^ .. _function-fio_dir_rec_string_block_ls_filename_c_string;is_dir_c_bool_c_void_gr__string_ref_: .. das:function:: dir_rec(path: string; blk: block<(filename:string;is_dir:bool):void>; error: string&) : auto def dir_rec (path: string; blk: block<(filename:string;is_dir:bool):void>; var error: string&) : auto :Arguments: * **path** : string * **blk** : block<(filename:string;is_dir:bool):void> * **error** : string\ & .. _function-fio_dir_rec_string_block_ls_filename_c_string;is_dir_c_bool_c_void_gr_: .. das:function:: dir_rec(path: string; blk: block<(filename:string;is_dir:bool):void>) : auto ---- .. _function-fio_getcwd: .. das:function:: getcwd() : string Returns the absolute path of the current working directory as a string. mkdir ^^^^^ .. _function-fio_mkdir_string_string_ref_: .. das:function:: mkdir(path: string; error: string&) : bool Creates a single directory at the specified path. Reports errors via the error out-parameter. :Arguments: * **path** : string implicit * **error** : string\ & implicit .. _function-fio_mkdir_string: .. das:function:: mkdir(path: string) : bool ---- mkdir_rec ^^^^^^^^^ .. _function-fio_mkdir_rec_string: .. das:function:: mkdir_rec(path: string) : bool def mkdir_rec (path: string) : bool :Arguments: * **path** : string .. _function-fio_mkdir_rec_string_string_ref_: .. das:function:: mkdir_rec(path: string; error: string&) : bool ---- .. _function-fio_mkdir_result_string: .. das:function:: mkdir_result(path: string) : fs_result_bool def mkdir_result (path: string) : fs_result_bool :Arguments: * **path** : string rmdir ^^^^^ .. _function-fio_rmdir_string_string_ref_: .. das:function:: rmdir(path: string; error: string&) : bool Removes an empty directory at the specified path. Reports errors via the error out-parameter. :Arguments: * **path** : string implicit * **error** : string\ & implicit .. _function-fio_rmdir_string: .. das:function:: rmdir(path: string) : bool ---- rmdir_rec ^^^^^^^^^ .. _function-fio_rmdir_rec_string_string_ref_: .. das:function:: rmdir_rec(path: string; error: string&) : bool Recursively removes a directory and all its contents. Reports errors via the error out-parameter. :Arguments: * **path** : string implicit * **error** : string\ & implicit .. _function-fio_rmdir_rec_string: .. das:function:: rmdir_rec(path: string) : bool ---- .. _function-fio_rmdir_rec_result_string: .. das:function:: rmdir_rec_result(path: string) : fs_result_bool def rmdir_rec_result (path: string) : fs_result_bool :Arguments: * **path** : string .. _function-fio_rmdir_result_string: .. das:function:: rmdir_result(path: string) : fs_result_bool def rmdir_result (path: string) : fs_result_bool :Arguments: * **path** : string ++++++++++++++++++ Filesystem queries ++++++++++++++++++ * :ref:`create_temp_directory (prefix: string; error: string&) : string ` * :ref:`create_temp_directory_result (prefix: string) : fs_result_string ` * :ref:`create_temp_file (prefix: string; ext: string; error: string&) : string ` * :ref:`create_temp_file_result (prefix: string; ext: string) : fs_result_string ` * :ref:`disk_space (path: string) : DiskSpaceInfo ` * :ref:`disk_space (path: string; var error: string&) : DiskSpaceInfo ` * :ref:`temp_directory (error: string&) : string ` * :ref:`temp_directory_result () : fs_result_string ` .. _function-fio_create_temp_directory_string_string_ref_: .. das:function:: create_temp_directory(prefix: string; error: string&) : string Creates a uniquely-named temporary directory with the given prefix. Reports errors via the error out-parameter. :Arguments: * **prefix** : string implicit * **error** : string\ & implicit .. _function-fio_create_temp_directory_result_string: .. das:function:: create_temp_directory_result(prefix: string) : fs_result_string def create_temp_directory_result (prefix: string) : fs_result_string :Arguments: * **prefix** : string .. _function-fio_create_temp_file_string_string_string_ref_: .. das:function:: create_temp_file(prefix: string; ext: string; error: string&) : string Creates a uniquely-named temporary file with the given prefix. Reports errors via the error out-parameter. :Arguments: * **prefix** : string implicit * **ext** : string implicit * **error** : string\ & implicit .. _function-fio_create_temp_file_result_string_string: .. das:function:: create_temp_file_result(prefix: string; ext: string) : fs_result_string def create_temp_file_result (prefix: string; ext: string) : fs_result_string :Arguments: * **prefix** : string * **ext** : string disk_space ^^^^^^^^^^ .. _function-fio_disk_space_string: .. das:function:: disk_space(path: string) : DiskSpaceInfo def disk_space (path: string) : DiskSpaceInfo :Arguments: * **path** : string .. _function-fio_disk_space_string_string_ref_: .. das:function:: disk_space(path: string; error: string&) : DiskSpaceInfo ---- .. _function-fio_temp_directory_string_ref_: .. das:function:: temp_directory(error: string&) : string Returns the path to the system temporary directory. Reports errors via the error out-parameter. :Arguments: * **error** : string\ & implicit .. _function-fio_temp_directory_result: .. das:function:: temp_directory_result() : fs_result_string def temp_directory_result () : fs_result_string ++++++++++++++++++++ OS specific routines ++++++++++++++++++++ * :ref:`exit (exitCode: int) ` * :ref:`get_env_variable (var: string) : string ` * :ref:`has_env_variable (var: string) : bool ` * :ref:`popen (command: string; scope: block\<(FILE const?):void\>) : int ` * :ref:`popen_binary (command: string; scope: block\<(FILE const?):void\>) : int ` * :ref:`popen_timeout (command: string; timeout: float; scope: block\<(FILE const?):void\>) : int ` * :ref:`sanitize_command_line (var: string) : string ` * :ref:`sleep (msec: uint) ` * :ref:`system (command: string) : int ` .. _function-fio_exit_int: .. das:function:: exit(exitCode: int) .. warning:: This is unsafe operation. Terminates the program immediately with the specified integer exit code, equivalent to C exit. :Arguments: * **exitCode** : int .. _function-fio_get_env_variable_string: .. das:function:: get_env_variable(var: string) : string Returns the string value of the environment variable with the given name, or an empty string if undefined. :Arguments: * **var** : string implicit .. _function-fio_has_env_variable_string: .. das:function:: has_env_variable(var: string) : bool Returns true if an environment variable with the given name is defined in the current process environment. :Arguments: * **var** : string implicit .. _function-fio_popen_string_block_ls_FILE_const_q__c_void_gr_: .. das:function:: popen(command: string; scope: block<(FILE const?):void>) : int .. warning:: This is unsafe operation. Opens a pipe to the given shell command, provides the resulting FILE pointer to the block, and returns the process exit code. :Arguments: * **command** : string implicit * **scope** : block<( :ref:`FILE `?):void> implicit .. _function-fio_popen_binary_string_block_ls_FILE_const_q__c_void_gr_: .. das:function:: popen_binary(command: string; scope: block<(FILE const?):void>) : int .. warning:: This is unsafe operation. Opens a pipe to the given shell command in binary mode, provides the resulting FILE pointer to the block, and returns the process exit code. :Arguments: * **command** : string implicit * **scope** : block<( :ref:`FILE `?):void> implicit .. _function-fio_popen_timeout_string_float_block_ls_FILE_const_q__c_void_gr_: .. das:function:: popen_timeout(command: string; timeout: float; scope: block<(FILE const?):void>) : int .. warning:: This is unsafe operation. Opens a process for reading, kills the entire process tree if it exceeds `timeout` seconds. Returns exit code on normal completion, or `popen_timed_out` if the timeout was exceeded. If `timeout` is 0 or negative, behaves identically to `popen`. :Arguments: * **command** : string implicit * **timeout** : float * **scope** : block<( :ref:`FILE `?):void> implicit .. _function-fio_sanitize_command_line_string: .. das:function:: sanitize_command_line(var: string) : string Escapes and sanitizes a command-line argument string to prevent shell injection. :Arguments: * **var** : string implicit .. _function-fio_sleep_uint: .. das:function:: sleep(msec: uint) Suspends execution of the current thread for the specified number of milliseconds. :Arguments: * **msec** : uint .. _function-fio_system_string: .. das:function:: system(command: string) : int .. warning:: This is unsafe operation. Runs a shell command via the C runtime ``system()`` function. Returns the process exit code. Unlike ``popen``, this does not capture output — it is fire-and-forget, suitable for launching detached processes (e.g. ``start`` on Windows, ``&`` on Unix). :Arguments: * **command** : string implicit +++++++++++++++ Dynamic modules +++++++++++++++ * :ref:`register_dynamic_module (path: string; name: string) : void? ` * :ref:`register_dynamic_module (path: string; name: string; on_error: int) : void? ` * :ref:`register_native_path (mod_name: string; src: string; dst: string) ` register_dynamic_module ^^^^^^^^^^^^^^^^^^^^^^^ .. _function-fio_register_dynamic_module_string_string: .. das:function:: register_dynamic_module(path: string; name: string) : void? Loads a shared library from the given path and registers it as a daslang module under the specified name, making it available for require. :Arguments: * **path** : string implicit * **name** : string implicit .. _function-fio_register_dynamic_module_string_string_int: .. das:function:: register_dynamic_module(path: string; name: string; on_error: int) : void? ---- .. _function-fio_register_native_path_string_string_string: .. das:function:: register_native_path(mod_name: string; src: string; dst: string) Registers a path prefix mapping for a module, redirecting file resolution from the src prefix to the dst prefix. :Arguments: * **mod_name** : string implicit * **src** : string implicit * **dst** : string implicit