File
Eina » Tools

This group discusses the functions to handle files and directories. More...

## Data Structures

struct | _Eina_File_Direct_Info
| The structure to store information of a path. More...
struct | _Eina_Stat
| The structure to store some file statistics. More...
struct | _Eina_File_Line
| The structure to store information of a line. More...
struct | _Eina_File
| This is the underlying data structure that represents a file in Eina. More...
struct | _Eina_File_Map
| This represents a memory mapped region of a file. More...
struct | _Eina_Lines_Iterator
| This represents a line iterator a file. More...

## Macros

#define | EINA_PATH_MAX 8192
| Definition for the constant defined as the highest value for PATH_MAX.
#define | EINA_PATH_SEP_C '/'
| The constant defined the path separator as the character '\' on Windows and '/' otherwise.
#define | EINA_PATH_SEP_S "/"
| The constant defined the path separator as the string "\" on Windows and "/" otherwise.
#define | EINA_FILE_DIR_LIST_CB(function)
| The macro to cast to an Eina_File_Dir_List_Cb.
#define | EINA_LOG_COLOR_DEFAULT EINA_COLOR_CYAN
| Set the color for Eina log entries.
#define | ERR(...)
| Macro for logging Eina errors.
#define | WRN(...)
| Macro for logging Eina warnings.
#define | INF(...)
| Macro for logging Eina info messages.
#define | DBG(...)
| Macro for logging Eina debug messages.

## Typedefs

typedef struct _Eina_File_Direct_Info | Eina_File_Direct_Info
| A type for _Eina_File_Direct_Info.
typedef struct _Eina_Stat | Eina_Stat
| A type for _Eina_Stat.
typedef struct _Eina_File_Line | Eina_File_Line
| A type for _Eina_File_Line.
typedef void(* | Eina_File_Dir_List_Cb) (const char *name, const char *path, void *data)
| Type for a callback to be called when iterating over the files of a directory.
typedef struct _Eina_File | Eina_File
| A file handle.
typedef Eina_Bool(* | Eina_File_Copy_Progress) (void *data, unsigned long long done, unsigned long long total)
| Type for a callback to report file copy progress.
typedef unsigned int | Eina_Statgen
| Stat Generation count state with it being 0 when disabled or some other value that is comparable (== or !=) to a stored value and if it is not equal, then do the actual stat i/o work.
typedef struct _Eina_File_Map | Eina_File_Map
| Type definition for an Eina File Map.
typedef struct _Eina_Lines_Iterator | Eina_Lines_Iterator
| Type definition for an Eina Lines Iterator.

## Enumerations

enum | Eina_File_Type { EINA_FILE_UNKNOWN , EINA_FILE_FIFO , EINA_FILE_CHR , EINA_FILE_DIR , EINA_FILE_BLK , EINA_FILE_REG , EINA_FILE_LNK , EINA_FILE_SOCK , EINA_FILE_WHT }
| Type for enumeration of a file type. More...
enum | Eina_File_Populate { EINA_FILE_RANDOM , EINA_FILE_SEQUENTIAL , EINA_FILE_WILLNEED , EINA_FILE_POPULATE , EINA_FILE_DONTNEED , EINA_FILE_REMOVE }
| Type for enumeration of a file access type. More...
enum | Eina_File_Access_Mode { EINA_FILE_ACCESS_MODE_EXIST = 0 , EINA_FILE_ACCESS_MODE_EXEC = 1 << 0 , EINA_FILE_ACCESS_MODE_WRITE = 1 << 1 , EINA_FILE_ACCESS_MODE_READ = 1 << 2 }
| Type for enumeration of a file access mode. More...
enum | Eina_File_Copy_Flags { EINA_FILE_COPY_DATA = 0 , EINA_FILE_COPY_PERMISSION = (1 << 0) , EINA_FILE_COPY_XATTR = (1 << 1) }
| Enumeration for a flag what to copy from file.

## Functions

EINA_API Eina_Bool | eina_file_path_relative (const char *path)
| Determines if a path is relative or absolute.
EINA_API Eina_Bool | eina_file_dir_list (const char *dir, Eina_Bool recursive, Eina_File_Dir_List_Cb cb, void *data)
| Lists all the files on the directory by calling the function for every file found.
EINA_API Eina_Array * | eina_file_split (char *path)
| Splits a path according to the delimiter of the filesystem.
EINA_API Eina_Iterator * | eina_file_ls (const char *dir)
| Gets an iterator to list the content of a directory.
EINA_API Eina_Iterator * | eina_file_stat_ls (const char *dir)
| Gets an iterator to list the content of a directory, with direct information.
EINA_API int | eina_file_statat (void *container, Eina_File_Direct_Info *info, Eina_Stat *buf)
| Uses information provided by Eina_Iterator of eina_file_stat_ls() or eina_file_direct_ls() to call stat in the most efficient way on your system.
EINA_API void | eina_file_close_from (int fd, int *except_fd)
| Close all file descriptors that are open at or above the given fd.
EINA_API int | eina_file_mkstemp (const char *templatename, Eina_Tmpstr **path)
| Generates and creates a uniquely named temporary file from a template name.
EINA_API Eina_Bool | eina_file_mkdtemp (const char *templatename, Eina_Tmpstr **path)
| Generates and creates a uniquely named temporary directory from a template name.
EINA_API Eina_Iterator * | eina_file_direct_ls (const char *dir)
| Gets an iterator to list the content of a directory, with direct information.
EINA_API char * | eina_file_path_sanitize (const char *path)
| Sanitizes the file path.
EINA_API Eina_Bool | eina_file_copy (const char *src, const char *dst, Eina_File_Copy_Flags flags, Eina_File_Copy_Progress cb, const void *cb_data)
| Copies one file to another using the fastest possible way and report progress.
EINA_API Eina_File * | eina_file_open (const char *name, Eina_Bool shared)
| Gets a read-only handler to a file.
EINA_API Eina_File * | eina_file_virtualize (const char *virtual_name, const void *data, unsigned long long length, Eina_Bool copy)
| Creates a virtual file from a memory pointer.
EINA_API Eina_Bool | eina_file_virtual (Eina_File *file)
| Tells if a file is a real file or only exists in memory.
EINA_API Eina_Bool | eina_file_refresh (Eina_File *file)
| Refreshes file information.
EINA_API Eina_File * | eina_file_dup (const Eina_File *file)
| Duplicates a read-only handler of a previously open file.
EINA_API void | eina_file_close (Eina_File *file)
| Unrefs the file handler.
EINA_API size_t | eina_file_size_get (const Eina_File *file)
| Gets the file size at open time.
EINA_API time_t | eina_file_mtime_get (const Eina_File *file)
| Gets the last modification time of an open file.
EINA_API const char * | eina_file_filename_get (const Eina_File *file)
| Gets the filename of an open file.
EINA_API Eina_Iterator * | eina_file_xattr_get (Eina_File *file)
| Gets the extended attribute of an open file.
EINA_API Eina_Iterator * | eina_file_xattr_value_get (Eina_File *file)
| Gets the extended attribute of an open file.
EINA_API void * | eina_file_map_all (Eina_File *file, Eina_File_Populate rule)
| Maps all the files to a buffer.
EINA_API void * | eina_file_map_new (Eina_File *file, Eina_File_Populate rule, unsigned long int offset, unsigned long int length)
| Maps a part of the file.
EINA_API void | eina_file_map_free (Eina_File *file, void *map)
| Unrefs and unmaps memory if possible.
EINA_API void | eina_file_map_populate (Eina_File *file, Eina_File_Populate rule, const void *map, unsigned long int offset, unsigned long int length)
| Asks the OS to populate or otherwise pages of memory in file mapping.
EINA_API Eina_Iterator * | eina_file_map_lines (Eina_File *file)
| Maps line by line in the memory efficiently using an Eina_Iterator.
EINA_API Eina_Bool | eina_file_map_faulted (Eina_File *file, void *map)
| Tells whether there has been an IO error during the life of a mmaped file.
static size_t | eina_file_path_join_len (char *dst, size_t size, const char *a, size_t a_len, const char *b, size_t b_len)
| Joins two paths of known length.
static size_t | eina_file_path_join (char *dst, size_t size, const char *a, const char *b)
| Joins two paths of known length.
EINA_API Eina_Bool | eina_file_unlink (const char *pathname)
| Unlinks file.
EINA_API Eina_Bool | eina_file_close_on_exec (int fd, Eina_Bool on)
| Make sure a file descriptor will be closed on exec.
EINA_API void | eina_file_statgen_next (void)
| Force the stat generation counter to tick over so any following i/o does real i/o and stat calls.
EINA_API Eina_Statgen | eina_file_statgen_get (void)
| Get the current stat generation counter value.
EINA_API void | eina_file_statgen_enable (void)
| Enable stat generation count optimiziing to only stat/do file i/o between generation counts changing.
EINA_API void | eina_file_statgen_disable (void)
| Disable stat generation count optimiziing to only stat/do file i/o between generation counts changing.
EINA_API Eina_Bool | eina_file_access (const char *path, Eina_File_Access_Mode mode)
| Determine the accessibility of a file or path.
Eina_Tmpstr * | eina_file_current_directory_get (const char *path, size_t len)
| Gets the current directory and optionally appends a path to it.
char * | eina_file_cleanup (Eina_Tmpstr *path)
| Cleans up Eina after a file is no longer needed.
void | eina_file_clean_close (Eina_File *file)
| Closes and cleans up after an Eina file.
void | eina_file_real_close (Eina_File *file)
| Closes a file from the OS perspective.
void | eina_file_flush (Eina_File *file, unsigned long int length)
| Resets the internal housekeeping structures after a file has changed.
void | eina_file_common_map_free (Eina_File *file, void *map, void(*free_func)(Eina_File_Map *map))
| Removes a mapped region from the file and frees the resources.
void * | eina_file_virtual_map_all (Eina_File *file)
| Map the entire contents of a virtual file to a buffer.
void * | eina_file_virtual_map_new (Eina_File *file, unsigned long int offset, unsigned long int length)
| Map a part of a virtual file to a buffer.
void | eina_file_virtual_map_free (Eina_File *file, void *map)
| Unref and unmap memory if possible.
unsigned int | eina_file_map_key_length (const void *key)
| Get the length of a map key.
int | eina_file_map_key_cmp (const unsigned long long int *key1, int key1_length, const unsigned long long int *key2, int key2_length)
| Compares two map keys.
int | eina_file_map_key_hash (const unsigned long long int *key, int key_length)
| Creates a hash from a map key.

## Variables

Eina_Hash * | _eina_file_cache
| A pointer to the global Eina file cache.
Eina_Lock | _eina_file_lock_cache
| The global file lock cache.
int | _eina_file_log_dom
| The global Eina log file domain.

## Detailed Description

This group discusses the functions to handle files and directories.

Functions to handle files and directories.

These functions make it easier to do a number of file and directory operations such as getting the list of files in a directory, splitting paths, and finding out file size and type.

Warning
  All functions in this group are blocking, which means they may take a long time to return; use them carefully.

See an example here.

This module performs internal housekeeping and utility tasks for Eina_File. It also provides the underlying data types for things like file handles, file maps and file iterators.

## Macro Definition Documentation

## EINA_PATH_SEP_C

#define EINA_PATH_SEP_C '/'

The constant defined the path separator as the character '\' on Windows and '/' otherwise.

Since
  1.16

Referenced by eina_module_symbol_path_get(), and eina_prefix_new().

## EINA_PATH_SEP_S

#define EINA_PATH_SEP_S "/"

The constant defined the path separator as the string "\" on Windows and "/" otherwise.

Since
  1.16

Referenced by eina_prefix_new().

## EINA_FILE_DIR_LIST_CB

#define EINA_FILE_DIR_LIST_CB | ( |  | function | ) |

Value:
((Eina_File_Dir_List_Cb)function)
Eina_File_Dir_List_Cb
void(* Eina_File_Dir_List_Cb)(const char *name, const char *path, void *data)
Type for a callback to be called when iterating over the files of a directory.
Definition eina_file.h:112

The macro to cast to an Eina_File_Dir_List_Cb.

This macro casts `function` to Eina_File_Dir_List_Cb.

Parameters

  [in] | function | The function to cast

## ERR

#define ERR | ( |  | ... | ) |

Value:
EINA_LOG_DOM_ERR(_eina_file_log_dom, __VA_ARGS__)
_eina_file_log_dom
int _eina_file_log_dom
The global Eina log file domain.
EINA_LOG_DOM_ERR
#define EINA_LOG_DOM_ERR(DOM, fmt,...)
Logs a message with level ERROR on the specified domain and format.
Definition eina_log.h:336

Macro for logging Eina errors.

Examples
  client.c, test_camera.c, test_camera_track.c, test_collision_detection.c, test_delete.c, and test_velocity.c.

Referenced by _ecore_con_server_proxy_apply(), ecore_buffer_consumer_buffer_dequeue(), ecore_buffer_init(), ecore_buffer_new(), ecore_buffer_provider_buffer_acquire(), ecore_buffer_provider_buffer_enqueue(), ecore_buffer_provider_new(), ecore_buffer_tbm_surface_get(), ecore_con_client_send(), ecore_con_local_path_new(), ecore_con_server_add(), ecore_con_server_connect(), ecore_con_server_send(), ecore_con_shutdown(), ecore_con_ssl_client_upgrade(), ecore_con_ssl_server_upgrade(), ecore_con_url_http_version_set(), ecore_drm2_device_open(), ecore_drm2_fb_create(), ecore_drm2_output_gamma_set(), ecore_drm2_output_mode_set(), ecore_drm2_shutdown(), ecore_drm_device_open(), ecore_drm_device_software_setup(), ecore_drm_evdev_key_remap_set(), ecore_drm_fb_dirty(), ecore_drm_inputs_device_axis_size_set(), ecore_drm_output_gamma_set(), ecore_drm_output_mode_set(), ecore_drm_output_possible_crtc_get(), ecore_drm_outputs_create(), ecore_drm_shutdown(), ecore_drm_tty_acquire(), ecore_drm_tty_open(), ecore_drm_tty_release(), ecore_evas_buffer_allocfunc_new(), ecore_evas_cursor_device_get(), ecore_evas_cursor_device_unset(), ecore_evas_drag_offset_set(), ecore_evas_object_dissociate(), ecore_evas_object_image_new(), ecore_evas_pointer_device_xy_get(), ecore_evas_selection_set(), ecore_evas_wayland_egl_new(), ecore_evas_wayland_shm_new(), ecore_exe_send(), ecore_file_download_full(), ecore_getopt_callback_ecore_evas_list_engines(), ecore_init(), ecore_ipc_client_send(), ecore_ipc_server_add(), ecore_ipc_server_connect(), ecore_ipc_server_flush(), ecore_ipc_server_send(), ecore_job_add(), ecore_main_fd_handler_active_set(), ecore_main_loop_glib_integrate(), ecore_pipe_full_add(), ecore_pipe_write(), ecore_poller_add(), ecore_poller_poll_interval_set(), ecore_shutdown(), ecore_thread_main_loop_begin(), ecore_thread_main_loop_end(), ecore_timer_add(), ecore_timer_del(), ecore_timer_loop_add(), ecore_win32_clipboard_get(), ecore_win32_clipboard_set(), ecore_win32_init(), ecore_win32_screen_depth_get(), ecore_win32_window_borderless_set(), ecore_win32_window_focus(), ecore_win32_window_focus_get(), ecore_win32_window_fullscreen_set(), ecore_win32_window_geometry_get(), ecore_win32_window_lower(), ecore_win32_window_move(), ecore_win32_window_move_resize(), ecore_win32_window_raise(), ecore_win32_window_resize(), ecore_win32_window_show(), ecore_win32_window_size_get(), ecore_win32_window_state_request_send(), ecore_win32_window_title_set(), ecore_wl2_display_create(), ecore_wl2_dnd_drag_types_set(), ecore_wl2_dnd_selection_set(), ecore_wl2_init(), ecore_wl2_offer_receive(), ecore_wl2_subsurface_new(), ecore_wl2_subsurface_opaque_region_set(), ecore_wl2_window_move(), ecore_wl2_window_resize(), ecore_wl_display_iterate(), ecore_wl_init(), ecore_wl_sync(), ecore_wl_window_new(), edje_box_layout_register(), edje_edit_clean_save_as(), edje_edit_font_add(), edje_edit_font_del(), edje_edit_image_del(), edje_edit_sound_samplebuffer_get(), edje_edit_sound_samplesource_get(), edje_edit_state_add(), edje_edit_state_external_param_get(), edje_edit_state_external_param_set(), edje_edit_vector_del(), edje_edit_without_source_save(), edje_external_type_array_register(), edje_external_type_register(), edje_file_data_get(), edje_init(), edje_object_part_swallow(), edje_object_part_swallow_get(), edje_object_part_text_get(), edje_shutdown(), eet_identity_certificate_print(), eet_identity_print(), eet_node_struct_append(), eet_shutdown(), eeze_disk_mount(), eeze_mount_tabs_watch(), efl_net_connman_init(), efl_net_connman_technology_type_from_str(), efl_quicklaunch_prepare(), efreet_menu_async_get(), efreet_menu_async_parse(), efreet_menu_kde_legacy_init(), efreet_trash_delete_uri(), eina_array_step_set(), eina_cow_add(), eina_cow_done(), eina_cow_write(), eina_file_close_on_exec(), eina_future_as_value(), eina_inarray_step_set(), eina_init(), eina_magic_string_set(), eina_module_load(), eina_module_new(), eina_shutdown(), eina_simple_xml_attribute_new(), eina_simple_xml_node_cdata_free(), eina_simple_xml_node_comment_free(), eina_simple_xml_node_data_free(), eina_simple_xml_node_doctype_child_free(), eina_simple_xml_node_doctype_free(), eina_simple_xml_node_processing_free(), eina_simple_xml_node_root_free(), eina_simple_xml_node_tag_free(), eina_simple_xml_node_tag_new(), eina_thread_queue_new(), eina_thread_queue_send_done(), eio_init(), eio_monitor_stringshared_add(), eio_shutdown(), eldbus_connection_get(), eldbus_message_iter_dict_iterate(), eldbus_message_method_call_new(), eldbus_shutdown(), eldbus_signal_handler_match_extra_vset(), elm_access_highlight_next_set(), elm_bg_option_get(), elm_cnp_selection_set(), elm_config_all_flush(), elm_drag_action_set(), elm_fileselector_path_get(), elm_fileselector_path_set(), elm_fileselector_selected_get(), elm_fileselector_selected_paths_get(), elm_fileselector_selected_set(), elm_image_memfile_set(), elm_object_focus_next(), elm_prefs_data_save(), elm_prefs_data_value_get(), elm_prefs_data_value_set(), elm_prefs_item_iface_register(), elm_prefs_page_iface_register(), elm_quicklaunch_fork(), elm_quicklaunch_prepare(), elm_slider_min_max_set(), elm_slider_step_set(), elm_transit_add(), elm_transit_effect_add(), elm_transit_effect_blend_add(), elm_transit_effect_color_add(), elm_transit_effect_fade_add(), elm_transit_effect_flip_add(), elm_transit_effect_image_animation_add(), elm_transit_effect_resizable_flip_add(), elm_transit_effect_resizing_add(), elm_transit_effect_rotation_add(), elm_transit_effect_translation_add(), elm_transit_effect_wipe_add(), elm_transit_effect_zoom_add(), elm_win_fake_canvas_set(), elm_win_resize_object_add(), elm_win_resize_object_del(), elua_init(), elua_state_new(), emotion_object_meta_info_get(), emotion_shutdown(), ethumb_client_connect(), ethumb_client_generate(), ethumb_dup(), ethumb_frame_set(), ethumb_generate(), ethumb_init(), ethumb_new(), evas_device_parent_set(), evas_gl_context_destroy(), evas_gl_context_version_create(), evas_gl_current_context_get(), evas_gl_current_surface_get(), evas_gl_make_current(), evas_gl_native_surface_get(), evas_gl_new(), evas_gl_pbuffer_surface_create(), evas_gl_surface_create(), evas_gl_surface_destroy(), evas_map_new(), evas_map_util_points_populate_from_geometry(), evas_map_util_points_populate_from_object(), evas_map_util_points_populate_from_object_full(), evas_object_del(), evas_object_image_data_convert(), evas_object_image_pixels_import(), evas_output_viewport_set(), evas_post_event_callback_push(), evas_textblock_text_markup_to_utf8(), evas_vg_container_add(), and evas_vg_shape_add().

## WRN

#define WRN | ( |  | ... | ) |

Value:
EINA_LOG_DOM_WARN(_eina_file_log_dom, __VA_ARGS__)
EINA_LOG_DOM_WARN
#define EINA_LOG_DOM_WARN(DOM, fmt,...)
Logs a message with level WARN on the specified domain and format.
Definition eina_log.h:357

Macro for logging Eina warnings.

Referenced by ecore_con_ssl_server_verify(), ecore_con_ssl_server_verify_basic(), ecore_con_url_ftp_upload(), ecore_con_url_get(), ecore_con_url_head(), ecore_con_url_post(), ecore_drm2_device_open(), ecore_drm2_fb_dirty(), ecore_drm2_output_rotation_set(), ecore_drm_device_pointer_left_handed_set(), ecore_drm_output_possible_crtc_get(), ecore_evas_new(), ecore_ipc_server_add(), ecore_ipc_server_connect(), ecore_wl2_window_commit(), ecore_x_window_keygrab_set(), ecore_x_window_keygrab_unset(), edje_edit_font_del(), edje_edit_image_del(), edje_edit_image_set_del(), edje_edit_part_item_del(), edje_edit_sound_sample_add(), edje_edit_sound_sample_del(), edje_edit_sound_tone_add(), edje_edit_sound_tone_del(), edje_edit_vector_del(), efl_net_connman_control_find_technology_by_type(), efl_quicklaunch_prepare(), efreet_desktop_string_list_parse(), efreet_menu_parse(), eina_file_open(), eina_prefix_new(), eio_monitor_stringshared_add(), elm_drag_start(), elm_prefs_data_new(), elm_prefs_file_set(), elm_quicklaunch_fork(), elm_quicklaunch_prepare(), elm_transit_chain_transit_add(), elm_transit_chain_transit_del(), elm_transit_effect_add(), elm_transit_object_add(), elm_transit_objects_final_state_keep_set(), elput_input_pointer_accel_profile_set(), elput_input_pointer_accel_speed_set(), elput_input_pointer_left_handed_set(), elput_input_touch_tap_to_click_enabled_set(), evas_object_image_alpha_mask_set(), and evas_object_image_fill_spread_set().

## INF

#define INF | ( |  | ... | ) |

Value:
EINA_LOG_DOM_INFO(_eina_file_log_dom, __VA_ARGS__)
EINA_LOG_DOM_INFO
#define EINA_LOG_DOM_INFO(DOM, fmt,...)
Logs a message with level INFO on the specified domain and format.
Definition eina_log.h:343

Macro for logging Eina info messages.

Examples
  test_camera_track.c, test_collision_detection.c, test_delete.c, test_no_gravity.c, and test_sleeping_threshold.c.

Referenced by ecore_evas_drag_cancel(), ecore_evas_drag_offset_set(), ecore_evas_drag_start(), ecore_evas_new(), ecore_evas_selection_exists(), ecore_evas_selection_get(), ecore_evas_selection_set(), ecore_init(), ecore_win32_clipboard_clear(), ecore_win32_clipboard_get(), ecore_win32_clipboard_set(), ecore_win32_cursor_free(), ecore_win32_cursor_new(), ecore_win32_cursor_shaped_new(), ecore_win32_cursor_size_get(), ecore_win32_cursor_x11_shaped_get(), ecore_win32_screen_depth_get(), ecore_win32_shutdown(), ecore_win32_window_activate(), ecore_win32_window_borderless_set(), ecore_win32_window_cursor_set(), ecore_win32_window_focus(), ecore_win32_window_focus_get(), ecore_win32_window_free(), ecore_win32_window_fullscreen_set(), ecore_win32_window_geometry_get(), ecore_win32_window_hide(), ecore_win32_window_iconified_set(), ecore_win32_window_lower(), ecore_win32_window_maximized_set(), ecore_win32_window_move(), ecore_win32_window_move_resize(), ecore_win32_window_new(), ecore_win32_window_override_new(), ecore_win32_window_raise(), ecore_win32_window_resize(), ecore_win32_window_show(), ecore_win32_window_size_base_get(), ecore_win32_window_size_base_set(), ecore_win32_window_size_get(), ecore_win32_window_size_max_get(), ecore_win32_window_size_max_set(), ecore_win32_window_size_min_get(), ecore_win32_window_size_min_set(), ecore_win32_window_size_step_get(), ecore_win32_window_size_step_set(), ecore_win32_window_state_get(), ecore_win32_window_state_request_send(), ecore_win32_window_state_set(), ecore_win32_window_title_set(), ecore_win32_window_type_set(), edje_edit_font_add(), edje_edit_font_del(), edje_object_part_swallow_get(), eet_data_descriptor_element_add(), eet_identity_certificate_print(), eeze_disk_eject(), eeze_disk_mount(), eeze_disk_unmount(), efl_quicklaunch_prepare(), efreet_icon_path_find(), efreet_menu_dump(), efreet_trash_ls(), eina_cow_add(), eina_file_open(), eina_module_load(), eina_prefix_new(), eio_monitor_stringshared_add(), elm_prefs_data_new(), elm_quicklaunch_fork(), elm_quicklaunch_prepare(), elua_init(), and elua_shutdown().

## DBG

#define DBG | ( |  | ... | ) |

Value:
EINA_LOG_DOM_DBG(_eina_file_log_dom, __VA_ARGS__)
EINA_LOG_DOM_DBG
#define EINA_LOG_DOM_DBG(DOM, fmt,...)
Logs a message with level DEBUG on the specified domain and format.
Definition eina_log.h:350

Macro for logging Eina debug messages.

Examples
  test_bouncing_ball.c, test_bouncing_text.c, test_camera.c, test_camera_track.c, test_collision_detection.c, test_collision_filter.c, test_constraint.c, test_delete.c, test_forces.c, test_growing_balls.c, test_no_gravity.c, test_rotating_forever.c, test_shapes.c, test_sleeping_threshold.c, test_slider.c, and test_velocity.c.

Referenced by _ecore_con_server_proxy_apply(), ecore_animator_source_set(), ecore_audio_init(), ecore_audio_shutdown(), ecore_buffer_consumer_buffer_dequeue(), ecore_buffer_consumer_buffer_release(), ecore_buffer_consumer_free(), ecore_buffer_consumer_new(), ecore_buffer_provider_buffer_acquire(), ecore_buffer_provider_buffer_enqueue(), ecore_buffer_provider_free(), ecore_buffer_provider_new(), ecore_buffer_queue_init(), ecore_buffer_queue_shutdown(), ecore_con_ssl_client_upgrade(), ecore_con_ssl_server_upgrade(), ecore_con_url_ftp_upload(), ecore_con_url_post(), ecore_con_url_verbose_set(), ecore_drm2_device_open(), ecore_drm2_fb_release(), ecore_drm2_plane_assign(), ecore_drm_device_find(), ecore_drm_device_master_drop(), ecore_drm_device_master_set(), ecore_drm_device_open(), ecore_drm_device_software_setup(), ecore_drm_tty_open(), ecore_evas_callback_msg_handle_set(), ecore_evas_callback_msg_parent_handle_set(), ecore_evas_msg_parent_send(), ecore_evas_msg_send(), ecore_evas_new(), ecore_file_download_abort(), ecore_ipc_server_add(), ecore_ipc_server_connect(), ecore_ipc_server_del(), ecore_main_loop_animator_ticked_get(), ecore_main_loop_begin(), ecore_wl2_display_create(), edje_mmap_group_exists(), efl_net_connman_init(), efl_net_connman_shutdown(), eina_convert_atod(), eina_future_as_value(), eina_mempool_add(), eina_mempool_del(), eina_mempool_gc(), eina_mempool_register(), eina_mempool_repack(), eina_mempool_statistics(), eina_mempool_unregister(), eina_module_free(), eina_module_list_free(), eina_module_list_load(), eina_module_list_unload(), eina_module_load(), eina_module_new(), eina_module_unload(), eina_prefix_new(), eina_promise_as_value(), eina_promise_continue_new(), eina_promise_new(), eina_promise_reject(), eina_quadtree_collide(), eina_rectangle_pool_data_set(), eina_rectangle_pool_free(), eina_rectangle_pool_new(), eina_rectangle_pool_packing_set(), eina_rectangle_pool_release(), eina_rectangle_pool_request(), eldbus_address_connection_get(), eldbus_connection_get(), eldbus_connection_ref(), eldbus_connection_unref(), eldbus_message_ref(), eldbus_message_unref(), eldbus_object_ref(), eldbus_object_unref(), eldbus_pending_cancel(), eldbus_private_address_connection_get(), eldbus_private_connection_get(), eldbus_proxy_ref(), eldbus_proxy_signal_handler_add(), eldbus_proxy_unref(), eldbus_signal_handler_ref(), eldbus_signal_handler_unref(), elm_win_trap_set(), emotion_object_play_speed_set(), emotion_object_video_channel_set(), emotion_object_video_mute_set(), emotion_object_video_subtitle_file_set(), emotion_object_vis_set(), ethumb_document_page_set(), ethumb_exists(), ethumb_file_free(), ethumb_file_set(), ethumb_frame_set(), ethumb_free(), ethumb_generate(), ethumb_new(), ethumb_thumb_aspect_set(), ethumb_thumb_category_set(), ethumb_thumb_compress_set(), ethumb_thumb_dir_path_set(), ethumb_thumb_format_set(), ethumb_thumb_orientation_set(), ethumb_thumb_quality_set(), ethumb_thumb_size_set(), ethumb_video_fps_set(), ethumb_video_interval_set(), ethumb_video_ntimes_set(), ethumb_video_start_set(), ethumb_video_time_set(), and evas_event_feed_axis_update().

## Typedef Documentation

## Eina_Stat

typedef struct _Eina_Stat Eina_Stat

A type for _Eina_Stat.

Since
  1.2

## Eina_File_Dir_List_Cb

typedef void(* Eina_File_Dir_List_Cb) (const char *name, const char *path, void *data)

Type for a callback to be called when iterating over the files of a directory.

Parameters

  [in] | name | The file name EXCLUDING the path
  [in] | path | The path passed to eina_file_dir_list()
  [in] | data | The data passed to eina_file_dir_list()

## Eina_File_Copy_Progress

typedef Eina_Bool(* Eina_File_Copy_Progress) (void *data, unsigned long long done, unsigned long long total)

Type for a callback to report file copy progress.

This function is used to report progress during eina_file_copy(), where `done` is the bytes already copied and `size` is the total file size.

Note
  If it returns EINA_FALSE, it will stop the copy.

## Eina_Statgen

typedef unsigned int Eina_Statgen

Stat Generation count state with it being 0 when disabled or some other value that is comparable (== or !=) to a stored value and if it is not equal, then do the actual stat i/o work.

Since
  1.23

## Enumeration Type Documentation

## Eina_File_Type

enum Eina_File_Type

Type for enumeration of a file type.

This type is used in Eina_File_Direct_Info.

Enumerator
EINA_FILE_UNKNOWN | Unknown file type.
EINA_FILE_FIFO | Named pipe (FIFO) type (unused on Windows).
EINA_FILE_CHR | Character device type (unused on Windows).
EINA_FILE_DIR | Directory type.
EINA_FILE_BLK | Block device type (unused on Windows).
EINA_FILE_REG | Regular file type.
EINA_FILE_LNK | Symbolic link type (unused on Windows).
EINA_FILE_SOCK | UNIX domain socket type (unused on Windows).
EINA_FILE_WHT | Whiteout file type (unused on Windows).

## Eina_File_Populate

enum Eina_File_Populate

Type for enumeration of a file access type.

This type is used in Eina_File_Direct_Info.

Enumerator
EINA_FILE_RANDOM | Advise random memory access to the mapped memory.
EINA_FILE_SEQUENTIAL | Advise sequential memory access to the mapped memory.
EINA_FILE_WILLNEED | Advise need for all the mapped memory.
EINA_FILE_POPULATE | Request for all the mapped memory.

EINA_FILE_DONTNEED

Indicate that the memory is no longer needed.

This may result in the memory being removed from any caches if applicable.

Since
  1.8

EINA_FILE_REMOVE

This memory is to be released and any content will be lost.

Subsequent accesses will succeed but return fresh memory as if accessed for the first time. This may not succeed if the filesystem does not support it.

Since
  1.8

## Eina_File_Access_Mode

enum Eina_File_Access_Mode

Type for enumeration of a file access mode.

This type is used with eina_file_access(). Enumerations can be combined bitwise with the OR operator.

Since
  1.28

Enumerator
EINA_FILE_ACCESS_MODE_EXIST | existence test: F_OK
EINA_FILE_ACCESS_MODE_EXEC | exec permission: X_OK
EINA_FILE_ACCESS_MODE_WRITE | write permission: W_OK
EINA_FILE_ACCESS_MODE_READ | read permission: R_OK

## Function Documentation

## eina_file_path_relative()

EINA_API Eina_Bool eina_file_path_relative | ( | const char * | path | ) |

Determines if a path is relative or absolute.

Parameters

  [in] | path | The path to check.

Returns
  EINA_TRUE if the path is relative, EINA_FALSE otherwise.

The implementation simply checks if the first char in the path is '/' on POSIX systems. On Windows, absolute paths begin with '\' or 'C:\' (or other letter). If it is not, the path is considered relative. If `path` is `NULL`, this function returns EINA_FALSE.

References EINA_FALSE, and EINA_TRUE.

Referenced by eina_file_path_sanitize(), eina_prefix_new(), elm_prefs_file_set(), elm_quicklaunch_exe_path_get(), and elm_theme_list_item_path_get().

## eina_file_dir_list()

EINA_API Eina_Bool eina_file_dir_list | ( | const char * | dir,
|  | Eina_Bool | recursive,
|  | Eina_File_Dir_List_Cb | cb,
|  | void * | data )

Lists all the files on the directory by calling the function for every file found.

This function calls `cb` for each file that is in `dir`. To have `cb` called on the files that are in subdirectories of `dir`, `recursive` should be EINA_TRUE. In other words, if `recursive` is EINA_FALSE, only direct children of `dir` are operated on, if `recursive` is EINA_TRUE the entire tree of files that is below `dir` is operated on.

If `cb` or `dir` is `NULL` or if `dir` is a string of size 0, or if `dir` cannot be opened, this function returns EINA_FALSE immediately. Otherwise, it returns EINA_TRUE.

Parameters

  [in] | dir | The directory name
  [in] | recursive | Iterate recursively in the directory
  [in] | cb | The callback to be called
  [in] | data | The data to pass to the callback

Returns
  EINA_TRUE on success, otherwise EINA_FALSE

Examples
  eina_file_01.c.

References alloca(), EINA_FALSE, EINA_FILE_DIR, eina_file_dir_list(), eina_file_stat_ls(), EINA_ITERATOR_FOREACH, eina_iterator_free(), EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_SAFETY_ON_TRUE_RETURN_VAL, EINA_TRUE, evil_wchar_to_char(), _Eina_File_Direct_Info::name_start, _Eina_File_Direct_Info::path, and _Eina_File_Direct_Info::type.

Referenced by eina_file_dir_list(), eina_module_arch_list_get(), and eina_module_list_get().

## eina_file_split()

EINA_API Eina_Array * eina_file_split | ( | char * | path | ) |

Splits a path according to the delimiter of the filesystem.

This function splits `path` according to the delimiter of the used filesystem. If `path` is `NULL` or if the array cannot be created, `NULL` is returned, otherwise an array with each part of `path` is returned.

Parameters

  [in] | path | The path to split

Returns
  An array of the parts of the path to split

References eina_array_new(), eina_array_push(), and EINA_SAFETY_ON_NULL_RETURN_VAL.

## eina_file_ls()

EINA_API Eina_Iterator * eina_file_ls | ( | const char * | dir | ) |

Gets an iterator to list the content of a directory.

This returns an iterator for shared strings, the name of each file in `dir` is only fetched when advancing the iterator, which means there is very little cost associated with creating the list and stopping halfway through it.

Parameters

  [in] | dir | The name of the directory to list

Returns
  An Eina_Iterator that walks over the files and directories in `dir`. On failure, it returns `NULL`.

Note
  The iterator hands the user a stringshared value with the full path. The user must free the string using eina_stringshare_del() on it.
  The container for the iterator is of type DIR*.
  The iterator walks over '.' and '..' without returning them.

See also
  eina_file_direct_ls()

Examples
  ecore_con_client_example.c, ecore_thread_example.c, and eina_file_01.c.

References EINA_MAGIC_SET, EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_UNLIKELY, FUNC_ITERATOR_FREE, FUNC_ITERATOR_GET_CONTAINER, and FUNC_ITERATOR_NEXT.

## eina_file_stat_ls()

EINA_API Eina_Iterator * eina_file_stat_ls | ( | const char * | dir | ) |

Gets an iterator to list the content of a directory, with direct information.

This returns an iterator for Eina_File_Direct_Info, the name of each file in `dir` is only fetched when advancing the iterator, which means there is cost associated with creating the list and stopping halfway through it.

Parameters

  [in] | dir | The name of the directory to list

Returns
  An Eina_Iterator that walks over the files and directories in `dir`. On failure, it returns `NULL`.

Warning
  The Eina_File_Direct_Info returned by the iterator must not be modified in any way.
  When the iterator is advanced or deleted the Eina_File_Direct_Info returned is no longer valid.

Note
  The container for the iterator is of type DIR*.
  The iterator walks over '.' and '..' without returning them.
  The difference between this function and eina_file_direct_ls() is that it guarantees the file type information to be correct by incurring a possible performance penalty.

See also
  eina_file_direct_ls()

Examples
  eina_file_01.c.

References eina_file_direct_ls(), EINA_MAGIC_SET, EINA_PATH_MAX, EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_UNLIKELY, FUNC_ITERATOR_FREE, FUNC_ITERATOR_GET_CONTAINER, and FUNC_ITERATOR_NEXT.

Referenced by eina_file_dir_list().

## eina_file_statat()

EINA_API int eina_file_statat | ( | void * | container,
|  | Eina_File_Direct_Info * | info,
|  | Eina_Stat * | buf )

Uses information provided by Eina_Iterator of eina_file_stat_ls() or eina_file_direct_ls() to call stat in the most efficient way on your system.

This function calls fstatat or stat depending on what your system supports. This makes it efficient and simple to use on your side without complex detection already done inside Eina on what the system can do.

Parameters

  [in] | container | The container returned by Eina_Iterator using eina_iterator_container_get()
  [in] | info | The content of the current Eina_File_Direct_Info provided by Eina_Iterator
  [in] | buf | The location put the result of the stat

Returns
  `0` is returned on success, otherwise `-1` is returned on error and errno is set appropriately

See also
  eina_file_direct_ls()
  eina_file_stat_ls()

Since
  1.2

References _Eina_Stat::atime, _Eina_Stat::atimensec, _Eina_Stat::blksize, _Eina_Stat::blocks, _Eina_Stat::ctime, _Eina_Stat::ctimensec, _Eina_Stat::dev, EINA_FILE_BLK, EINA_FILE_CHR, EINA_FILE_DIR, EINA_FILE_FIFO, EINA_FILE_LNK, EINA_FILE_REG, EINA_FILE_SOCK, EINA_FILE_UNKNOWN, EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_UNUSED, _Eina_Stat::gid, _Eina_Stat::ino, _Eina_Stat::mode, _Eina_Stat::mtime, _Eina_Stat::mtimensec, _Eina_File_Direct_Info::name_start, _Eina_Stat::nlink, _Eina_File_Direct_Info::path, _Eina_Stat::rdev, _Eina_Stat::size, _Eina_File_Direct_Info::type, and _Eina_Stat::uid.

## eina_file_close_from()

EINA_API void eina_file_close_from | ( | int | fd,
|  | int * | except_fd )

Close all file descriptors that are open at or above the given fd.

This closes all open file descriptors that are equal to or of higher value than the given inpit fd given. This is intended for niche use like closing all open files just before exec()ing a new process after calling fork(). The except_fd array can be NULL if no fd's are to be skipped, but if some fd's are to skip being closed then this will be an array of fd numbers being terminated by a fd value of -1.

Parameters

  [in] | fd | The fd value to begin closing at
  [in] | except_fd | An array of fd's not to close terminated by -1 as the last invalid fd

Since
  1.24

References alloca(), EINA_FALSE, and EINA_TRUE.

## eina_file_mkstemp()

EINA_API int eina_file_mkstemp | ( | const char * | templatename,
|  | Eina_Tmpstr ** | path )

Generates and creates a uniquely named temporary file from a template name.

The generated file is opened with the open(2) `O_EXCL` flag.

This function calls mkstemp(), generates a unique temporary filename from template, creates and opens the file, and returns an open file descriptor for the file.

Parameters

  [in] | templatename | This is a string. It must contain the six characters 'XXXXXX' at the end or directly followed by an extension as in 'prefixXXXXXX.ext'.
  [out] | path | The path to the created temporary file, or `NULL` in case of failure. It must be released by eina_tmpstr_del().

Returns
  On success `file` descriptor of the temporary file is returned, On error `-1` is returned, in which case `errno` is set appropriately.

Note
  If a filename extension was specified in `templatename`, then the new `path` will also contain this extension (since 1.10).
  If the `templatename` is a simple file name (no relative or absolute path to another directory), then a temporary file will be created inside the system temporary directory (

See also
  eina_environment_tmp_get()). If the `templatename` contains a directory separator ('/', or '\' on Windows) then the file will be created inside this directory, which must exist and be writeable. Use ./filename.XXXXXX to create files in the current working directory. (since 1.17)
  eina_file_mkdtemp()

Since
  1.8

Examples
  eet-data-cipher_decipher.c.

References eina_environment_tmp_get(), eina_file_path_join(), EINA_SAFETY_ON_NULL_RETURN_VAL, eina_strlcpy(), and eina_tmpstr_add().

Referenced by ecore_file_mv(), and ecore_x_resource_db_flush().

## eina_file_mkdtemp()

EINA_API Eina_Bool eina_file_mkdtemp | ( | const char * | templatename,
|  | Eina_Tmpstr ** | path )

Generates and creates a uniquely named temporary directory from a template name.

This function calls mkdtemp(). The directory is then created with permissions 0700.

Parameters

  [in] | templatename | This is a string. The last six characters of `templatename` must be XXXXXX.
  [out] | path | The path to the created temporary directory, or `NULL` in case of failure. It must be released by eina_tmpstr_del().

Returns
  On success `EINA_TRUE` is returned, On error `EINA_FALSE` is returned, in which case `errno` is set appropriately.

Note
  If the `templatename` is a simple directory name (no relative or absolute path to another directory), then a temporary directory will be created inside the system temporary directory (

See also
  eina_environment_tmp_get()). If the `templatename` contains a directory separator ('/', or '\' on Windows) then the temporary directory will be created inside that other directory, which must exist and be writeable. (since 1.17)
  eina_file_mkstemp()

Since
  1.8

References eina_environment_tmp_get(), EINA_FALSE, eina_file_path_join(), EINA_SAFETY_ON_NULL_RETURN_VAL, eina_strlcpy(), eina_tmpstr_add(), and EINA_TRUE.

## eina_file_direct_ls()

EINA_API Eina_Iterator * eina_file_direct_ls | ( | const char * | dir | ) |

Gets an iterator to list the content of a directory, with direct information.

This returns an iterator for Eina_File_Direct_Info, the name of each file in `dir` is only fetched when advancing the iterator, which means there is cost associated with creating the list and stopping halfway through it.

Parameters

  [in] | dir | The name of the directory to list

Returns
  An Eina_Iterator that walks over the files and directories in `dir`. On failure, it returns `NULL`.

Warning
  If readdir_r doesn't contain file type information, file type is EINA_FILE_UNKNOWN.
  The Eina_File_Direct_Info returned by the iterator must not be modified in any way.
  When the iterator is advanced or deleted the Eina_File_Direct_Info returned is no longer valid.

Note
  The container for the iterator is of type DIR*.
  The iterator walks over '.' and '..' without returning them.
  The difference between this function and eina_file_stat_ls() is that it may not get the file type information however it is likely to be faster.

See also
  eina_file_ls()

Examples
  eina_file_01.c.

References EINA_MAGIC_SET, EINA_PATH_MAX, EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_UNLIKELY, FUNC_ITERATOR_FREE, FUNC_ITERATOR_GET_CONTAINER, and FUNC_ITERATOR_NEXT.

Referenced by ecore_file_dir_is_empty(), ecore_file_ls(), ecore_file_recursive_rm(), edje_available_modules_get(), and eina_file_stat_ls().

## eina_file_path_sanitize()

EINA_API char * eina_file_path_sanitize | ( | const char * | path | ) |

Sanitizes the file path.

This function takes care of adding the current working directory if its a relative path and also removes all '..' and '//' references in the original path.

Parameters

  [in] | path | The path to sanitize

Returns
  An allocated string with the sanitized path

Since
  1.1

References eina_file_current_directory_get(), eina_file_path_relative(), eina_tmpstr_del(), and eina_tmpstr_len().

Referenced by efl_quicklaunch_prepare(), efreet_desktop_new(), efreet_desktop_uncached_new(), efreet_icon_deprecated_user_dir_get(), efreet_icon_user_dir_get(), elua_state_dirs_fill(), elua_state_dirs_set(), elua_state_include_path_add(), ethumb_file_set(), and ethumb_thumb_dir_path_set().

## eina_file_copy()

EINA_API Eina_Bool eina_file_copy | ( | const char * | src,
|  | const char * | dst,
|  | Eina_File_Copy_Flags | flags,
|  | Eina_File_Copy_Progress | cb,
|  | const void * | cb_data )

Copies one file to another using the fastest possible way and report progress.

This function tries to splice if it is available. It is blocked until the whole file is copied or it fails.

Parameters

  [in] | src | The source file.
  [in] | dst | The destination file.
  [in] | flags | Controls what is copied (data is always copied).
  [in] | cb | If it is provided will be called with file copy progress information.
  [in] | cb_data | Context data to provide to `cb` during copy.

Returns
  EINA_TRUE on success, EINA_FALSE otherwise (and `dst` will be deleted)

Note
  During the progress it may call back `cb` with the progress summary.

References EINA_FALSE, EINA_SAFETY_ON_FALSE_GOTO, EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_SAFETY_ON_TRUE_GOTO, EINA_SAFETY_ON_TRUE_RETURN_VAL, and eina_xattr_fd_copy().

## eina_file_open()

EINA_API Eina_File * eina_file_open | ( | const char * | name,
|  | Eina_Bool | shared )

Gets a read-only handler to a file.

This opens a file in the read-only mode. `name` should be an absolute path. An Eina_File handle can be shared among multiple instances if `shared` is EINA_TRUE, otherwise.

Parameters

  [in] | name | The filename to open
  [in] | shared | Requested a shm

Returns
  An Eina_File handle to the file

Since
  1.1

References _eina_file_cache, _eina_file_lock_cache, _Eina_File::delete_me, eina_file_close_on_exec(), eina_file_map_key_cmp(), eina_file_map_key_hash(), eina_file_map_key_length(), eina_file_statgen_get(), EINA_FREE_CB, eina_hash_del(), eina_hash_direct_add(), eina_hash_find(), eina_hash_new(), eina_hash_pointer_new(), EINA_KEY_CMP, EINA_KEY_HASH, EINA_KEY_LENGTH, EINA_MAGIC_SET, EINA_SAFETY_ON_NULL_RETURN_VAL, eina_stringshare_del(), EINA_TRUE, _Eina_File::filename, INF, _Eina_File::length, _Eina_File::mtime, _Eina_File::statgen, and WRN.

Referenced by edje_file_collection_list(), edje_file_color_class_used_list(), edje_file_data_get(), edje_file_group_exists(), and eet_open().

## eina_file_virtualize()

EINA_API Eina_File * eina_file_virtualize | ( | const char * | virtual_name,
|  | const void * | data,
|  | unsigned long long | length,
|  | Eina_Bool | copy )

Creates a virtual file from a memory pointer.

Parameters

  [in] | virtual_name | A virtual name for Eina_File, if `NULL`, a generated one will be given
  [in] | data | The memory pointer to take data from
  [in] | length | The length of the data in memory
  [in] | copy | EINA_TRUE if the data must be copied

Returns
  Eina_File handle to the file

Since
  1.8

References _Eina_File::copied, eina_file_map_key_cmp(), eina_file_map_key_hash(), eina_file_map_key_length(), EINA_FREE_CB, eina_hash_new(), eina_hash_pointer_new(), EINA_KEY_CMP, EINA_KEY_HASH, EINA_KEY_LENGTH, EINA_MAGIC_SET, EINA_SAFETY_ON_NULL_RETURN_VAL, eina_stringshare_add(), EINA_TRUE, _Eina_File::fd, _Eina_File::filename, _Eina_File::global_map, _Eina_File::length, _Eina_File::lock, _Eina_File::map, _Eina_File::mtime, _Eina_File::refcount, and _Eina_File::rmap.

Referenced by eina_file_dup(), and evas_object_image_memfile_set().

## eina_file_virtual()

EINA_API Eina_Bool eina_file_virtual | ( | Eina_File * | file | ) |

Tells if a file is a real file or only exists in memory.

Parameters

  [in] | file | The file to test

Returns
  EINA_TRUE if the file is a virtual file

Since
  1.8

References EINA_FALSE.

## eina_file_refresh()

EINA_API Eina_Bool eina_file_refresh | ( | Eina_File * | file | ) |

Refreshes file information.

All current map continue to exist. You need to manually delete and recreate them to have the new correct mapping.

Parameters

  [in,out] | file | The file to refresh

Returns
  EINA_TRUE if the file has changed

Since
  1.8

References EINA_FALSE, eina_file_flush(), EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_TRUE, _Eina_File::fd, _Eina_File::filename, _Eina_File::inode, _Eina_File::length, and _Eina_File::mtime.

Referenced by evas_object_image_reload().

## eina_file_dup()

EINA_API Eina_File * eina_file_dup | ( | const Eina_File * | file | ) |

Duplicates a read-only handler of a previously open file.

Parameters

  [in] | file | To duplicate a reference to

Returns
  Eina_File handle of the duplicated file

Note
  Opens a file in read-only mode.

Since
  1.8

References _Eina_File::copied, eina_file_virtualize(), EINA_TRUE, _Eina_File::filename, _Eina_File::global_map, _Eina_File::length, _Eina_File::lock, and _Eina_File::refcount.

Referenced by eet_mmap(), elm_theme_extension_mmap_add(), and elm_theme_overlay_mmap_add().

## eina_file_close()

EINA_API void eina_file_close | ( | Eina_File * | file | ) |

Unrefs the file handler.

This decrements the file's reference count and if it reaches zero it closes the file.

Parameters

  [in] | file | The file handler to unref

Since
  1.1

References _eina_file_cache, _eina_file_lock_cache, EINA_FALSE, eina_file_clean_close(), eina_hash_del_by_key_hash(), eina_hash_find_by_hash(), eina_hash_superfast(), EINA_TRUE, _Eina_File::filename, _Eina_File::lock, and _Eina_File::refcount.

Referenced by edje_file_collection_list(), edje_file_color_class_used_list(), edje_file_data_get(), edje_file_group_exists(), eet_open(), elm_theme_flush(), elm_theme_overlay_mmap_add(), elua_io_loadfile(), emile_image_close(), and evas_object_image_memfile_set().

## eina_file_size_get()

EINA_API size_t eina_file_size_get | ( | const Eina_File * | file | ) |

Gets the file size at open time.

Parameters

  [in] | file | The file handler to request the size from

Returns
  The length of the file

Since
  1.1

References _Eina_File::length.

Referenced by eet_mmap(), eet_open(), eio_file_map_all(), and elua_io_loadfile().

## eina_file_mtime_get()

EINA_API time_t eina_file_mtime_get | ( | const Eina_File * | file | ) |

Gets the last modification time of an open file.

Parameters

  [in] | file | The file handler to request the modification time from

Returns
  The last modification time

Since
  1.1

References _Eina_File::mtime.

## eina_file_filename_get()

EINA_API const char * eina_file_filename_get | ( | const Eina_File * | file | ) |

Gets the filename of an open file.

Parameters

  [in] | file | The file handler to request the name from

Returns
  The stringshared filename of the file

Since
  1.1

References _Eina_File::filename.

Referenced by edje_mmap_group_exists(), eet_mmap(), elm_code_file_filename_get(), elm_code_file_path_get(), elm_theme_extension_mmap_add(), elm_theme_group_path_find(), and elm_theme_overlay_mmap_add().

## eina_file_xattr_get()

EINA_API Eina_Iterator * eina_file_xattr_get | ( | Eina_File * | file | ) |

Gets the extended attribute of an open file.

Parameters

  [in] | file | The file handler to request the extended attribute from

Returns
  An iterator

Note
  The iterator lists all the extended attribute names without allocating them, so you need to copy them yourself if needed.

Since
  1.2

References EINA_API, EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_UNUSED, eina_xattr_fd_ls(), and _Eina_File::fd.

## eina_file_xattr_value_get()

EINA_API Eina_Iterator * eina_file_xattr_value_get | ( | Eina_File * | file | ) |

Gets the extended attribute of an open file.

Parameters

  [in] | file | The file handler to request the extended attribute from

Returns
  An iterator

Note
  The iterator lists all the extended attribute names without allocating them, so you need to copy them yourself if needed. It returns the Eina_Xattr structure.

Since
  1.2

References EINA_API, EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_UNUSED, eina_xattr_value_fd_ls(), and _Eina_File::fd.

## eina_file_map_all()

EINA_API void * eina_file_map_all | ( | Eina_File * | file,
|  | Eina_File_Populate | rule )

Maps all the files to a buffer.

Parameters

  [in] | file | The file handler to map in the memory
  [in] | rule | The rule to apply to the mapped memory

Returns
  A pointer to a buffer that maps all the file content
  `NULL` if it fails

Since
  1.1

References EINA_FALSE, EINA_FILE_POPULATE, eina_file_virtual_map_all(), eina_mmap_safety_enabled_set(), EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_TRUE, EINA_UNUSED, _Eina_File::fd, _Eina_File::global_hugetlb, _Eina_File::global_map, _Eina_File::global_refcount, _Eina_File::length, _Eina_File::lock, MAP_SHARED, and PROT_READ.

Referenced by eet_mmap(), eet_open(), eina_file_map_lines(), eina_file_map_new(), and elua_io_loadfile().

## eina_file_map_new()

EINA_API void * eina_file_map_new | ( | Eina_File * | file,
|  | Eina_File_Populate | rule,
|  | unsigned long int | offset,
|  | unsigned long int | length )

Maps a part of the file.

Parameters

  [in] | file | The file handler to map in the memory
  [in] | rule | The rule to apply to the mapped memory
  [in] | offset | The offset inside the file
  [in] | length | The length of the memory to map

Returns
  A valid pointer to the system memory with `length` valid bytes in it
  And `NULL` if not inside the file or anything else goes wrong.

Note
  This does handle reference counting so it can share the same memory area.

Since
  1.1

References EINA_FALSE, eina_file_map_all(), EINA_FILE_POPULATE, eina_file_virtual_map_new(), eina_hash_add(), eina_hash_direct_add(), eina_hash_find(), eina_mmap_safety_enabled_set(), EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_TRUE, _Eina_File::fd, _Eina_File_Map::hugetlb, _Eina_File::length, _Eina_File_Map::length, _Eina_File::lock, _Eina_File::map, _Eina_File_Map::map, MAP_SHARED, _Eina_File_Map::offset, PROT_READ, _Eina_File_Map::refcount, and _Eina_File::rmap.

## eina_file_map_free()

EINA_API void eina_file_map_free | ( | Eina_File * | file,
|  | void * | map )

Unrefs and unmaps memory if possible.

Parameters

  [in] | file | The file handler to unmap memory from
  [in] | map | The memory map to unref and unmap

Since
  1.1

References eina_file_common_map_free(), eina_file_virtual_map_free(), EINA_SAFETY_ON_NULL_RETURN, _Eina_File::global_map, _Eina_File::global_refcount, _Eina_File::length, _Eina_File::lock, and munmap().

Referenced by elua_io_loadfile().

## eina_file_map_populate()

EINA_API void eina_file_map_populate | ( | Eina_File * | file,
|  | Eina_File_Populate | rule,
|  | const void * | map,
|  | unsigned long int | offset,
|  | unsigned long int | length )

Asks the OS to populate or otherwise pages of memory in file mapping.

This advises the operating system as to what to do with the memory mapped to the given `file`. This affects a specific range of memory and may not be honored if the system chooses to ignore the request.

Parameters

  [in] | file | The file handle from which the map comes
  [in] | rule | The rule to apply to the mapped memory
  [in] | map | Memory that was mapped inside of which the memory range is
  [in] | offset | The offset in bytes from the start of the map address
  [in] | length | The length in bytes of the memory region to populate

Since
  1.8

References eina_hash_find(), EINA_SAFETY_ON_NULL_RETURN, EINA_UNUSED, _Eina_File::global_hugetlb, _Eina_File::global_map, _Eina_File_Map::hugetlb, _Eina_File::length, _Eina_File_Map::length, _Eina_File::lock, and _Eina_File::rmap.

## eina_file_map_lines()

EINA_API Eina_Iterator * eina_file_map_lines | ( | Eina_File * | file | ) |

Maps line by line in the memory efficiently using an Eina_Iterator.

This function returns an iterator that acts like fgets without useless memcpy. Be aware that once eina_iterator_next has been called, nothing can guarantee that the memory is still going to be mapped.

Parameters

  [in] | file | The file to run over

Returns
  An Eina_Iterator that produces Eina_File_Line

Since
  1.3

References _Eina_Lines_Iterator::boundary, _Eina_Lines_Iterator::current, eina_file_map_all(), EINA_FILE_SEQUENTIAL, EINA_MAGIC_SET, _Eina_File_Line::end, _Eina_Lines_Iterator::end, _Eina_Lines_Iterator::fp, _Eina_Iterator::free, FUNC_ITERATOR_FREE, FUNC_ITERATOR_GET_CONTAINER, FUNC_ITERATOR_NEXT, _Eina_Iterator::get_container, _Eina_File_Line::index, _Eina_Lines_Iterator::iterator, _Eina_File::length, _Eina_File_Line::length, _Eina_File::lock, _Eina_Lines_Iterator::map, _Eina_Iterator::next, _Eina_File::refcount, _Eina_File_Line::start, and _Eina_Iterator::version.

## eina_file_map_faulted()

EINA_API Eina_Bool eina_file_map_faulted | ( | Eina_File * | file,
|  | void * | map )

Tells whether there has been an IO error during the life of a mmaped file.

Parameters

  [in] | file | The file handler to the mmaped file
  [in] | map | The memory map to check if an error occurred on it

Returns
  EINA_TRUE if there has been an IO error, otherwise EINA_FALSE

Since
  1.2

References _Eina_File::dead_map, EINA_FALSE, eina_hash_find(), EINA_LIST_FOREACH, EINA_SAFETY_ON_NULL_RETURN_VAL, EINA_UNUSED, _Eina_File_Map::faulty, _Eina_File::global_faulty, _Eina_File::global_map, _Eina_File::lock, _Eina_File_Map::map, and _Eina_File::rmap.

## eina_file_path_join_len()

size_t eina_file_path_join_len | ( | char * | dst,
|  | size_t | size,
|  | const char * | a,
|  | size_t | a_len,
|  | const char * | b,
|  | size_t | b_len )

inline static

Joins two paths of known length.

This function is similar to eina_str_join_len(), but the separator is '\' on Windows and '/' otherwise.

Parameters

  [out] | dst | The buffer to store the result.
  [in] | size | Size (in byte) of the buffer.
  [in] | a | First path to use.
  [in] | a_len | length of `a`.
  [in] | b | Second path to use.
  [in] | b_len | length of `b`.

Returns
  The number of characters printed.

See also
  eina_str_join_len()
  eina_file_path_join()

Since
  1.16

References eina_file_path_join_len().

Referenced by eina_file_path_join_len().

## eina_file_path_join()

size_t eina_file_path_join | ( | char * | dst,
|  | size_t | size,
|  | const char * | a,
|  | const char * | b )

inline static

Joins two paths of known length.

This function is similar to eina_file_path_join_len(), but will compute the length of `a` and `b` using strlen(). The path separator is '\' on Windows and '/' otherwise.

Parameters

  [out] | dst | The buffer to store the result.
  [in] | size | Size (in byte) of the buffer.
  [in] | a | First string to use.
  [in] | b | Second string to use.

Returns
  The number of characters printed.

See also
  eina_file_path_join_len()

Since
  1.16

References EINA_API, eina_file_close_on_exec(), eina_file_path_join(), and eina_file_unlink().

Referenced by eina_file_mkdtemp(), eina_file_mkstemp(), eina_file_path_join(), and eina_prefix_new().

## eina_file_unlink()

EINA_API Eina_Bool eina_file_unlink | ( | const char * | pathname | ) |

Unlinks file.

This function is a wrapper around the unlink() system call. It removes a link to a file.

Parameters

  [in] | pathname | File name to unlink.

Returns
  EINA_TRUE if the unlink was successful, EINA_FALSE otherwise..

Since
  1.19

References _eina_file_cache, EINA_FALSE, eina_hash_find(), eina_stringshare_del(), and EINA_TRUE.

Referenced by eina_file_path_join().

## eina_file_close_on_exec()

EINA_API Eina_Bool eina_file_close_on_exec | ( | int | fd,
|  | Eina_Bool | on )

Make sure a file descriptor will be closed on exec.

This function is a wrapper around the fnctl() system call. It makes sure that the fd will be closed whenever exec is called.

Parameters

  [in] | fd | File descriptor to enforce close on exec on.
  [in] | on | EINA_TRUE will turn close on exec on, EINA_FALSE will turn it off.

Returns
  EINA_TRUE if it will be closed on exec, EINA_FALSE otherwise..

Since
  1.20

References EINA_FALSE, EINA_TRUE, ERR, and fcntl().

Referenced by ecore_pipe_full_add(), eina_file_open(), eina_file_path_join(), and eina_mmap_safety_enabled_set().

## eina_file_statgen_next()

EINA_API void eina_file_statgen_next | ( | void |  | ) |

Force the stat generation counter to tick over so any following i/o does real i/o and stat calls.

Since
  1.23

## eina_file_statgen_get()

EINA_API Eina_Statgen eina_file_statgen_get | ( | void |  | ) |

Get the current stat generation counter value.

Returns
  0 if you should always do stat calls and compare, or some other value that changes like a generation counter

Since
  1.23

Referenced by eina_file_open().

## eina_file_statgen_enable()

EINA_API void eina_file_statgen_enable | ( | void |  | ) |

Enable stat generation count optimiziing to only stat/do file i/o between generation counts changing.

Since
  1.23

## eina_file_statgen_disable()

EINA_API void eina_file_statgen_disable | ( | void |  | ) |

Disable stat generation count optimiziing to only stat/do file i/o between generation counts changing.

Since
  1.23

## eina_file_access()

EINA_API Eina_Bool eina_file_access | ( | const char * | path,
|  | Eina_File_Access_Mode | mode )

Determine the accessibility of a file or path.

Parameters

  [in] | path | The path to check.
  [in] | mode | Access permissions to be checked, or existence test.

Returns
  EINA_TRUE it `path` satisfies the tests, EINA_FALSE otherwise.

On Linux, this function just calls the access() function. On Windows, it mimics as best as possible the behavior of access():

- Existence is always checked.
- As on Windows, a file is either read only or read/write, read permission is equivalent to existence. so Write permission is equivalent to not being read only.
- A directory is always executable, except if greater privilege is needed.

The `mode` has the same values than F_OK, X_OK, W_OK and R_OK, and the usage is the same than the access() function.

If `path` is NULL or the epty string, this function returns EINA_FALSE.

Since
  1.28

References EINA_FALSE, EINA_FILE_ACCESS_MODE_EXEC, EINA_FILE_ACCESS_MODE_EXIST, EINA_FILE_ACCESS_MODE_WRITE, eina_str_has_extension(), and EINA_TRUE.

Referenced by ecore_file_can_exec(), ecore_file_can_read(), ecore_file_can_write(), eeze_disk_can_eject(), eeze_disk_can_mount(), eeze_disk_can_unmount(), elm_quicklaunch_exe_path_get(), elm_quicklaunch_prepare(), and ethumb_file_set().

## eina_file_current_directory_get()

Eina_Tmpstr * eina_file_current_directory_get | ( | const char * | path,
|  | size_t | len )

Gets the current directory and optionally appends a path to it.

If a string was passed in via the `path` parameter, it will be appended to the current working directory. Presumably, this will be a relative path.

Parameters

  [in] | path | The path to append to the current directory.
  [in] | len | The length of `path`.

Returns
  A pointer to a string that contains the absolute path to the current working directory plus any path you send in.

References alloca(), and eina_tmpstr_add_length().

Referenced by eina_file_path_sanitize().

## eina_file_cleanup()

char * eina_file_cleanup | ( | Eina_Tmpstr * | path | ) |

Cleans up Eina after a file is no longer needed.

Parameters

  [in,out] | path | The path of the file.

Returns
  On success, it will return the `path` string. If `path` is `NULL`, it will return and empty string.

References eina_tmpstr_del().

## eina_file_clean_close()

void eina_file_clean_close | ( | Eina_File * | file | ) |

Closes and cleans up after an Eina file.

Parameters

  [in,out] | file | The path of the file.

References eina_file_real_close(), eina_hash_free(), EINA_MAGIC_SET, eina_stringshare_del(), _Eina_File::filename, _Eina_File::map, and _Eina_File::rmap.

Referenced by eina_file_close().

## eina_file_real_close()

void eina_file_real_close | ( | Eina_File * | file | ) |

Closes a file from the OS perspective.

Parameters

  [in,out] | file | The path of the file.

References _eina_file_cache, _eina_file_lock_cache, and _eina_file_log_dom.

Referenced by eina_file_clean_close().

## eina_file_flush()

void eina_file_flush | ( | Eina_File * | file,
|  | unsigned long int | length )

Resets the internal housekeeping structures after a file has changed.

Despite the name, this routine does not write anything to disk. It invalidates the memory maps for the file. If the file has shrunk, it also adds any mapped regions past the end of the file to the dead_map.

Parameters

  [in,out] | file | The file.
  [in] | length | The current length of the file after the change.

References _Eina_File::dead_map, eina_hash_del(), eina_hash_iterator_data_new(), EINA_ITERATOR_FOREACH, eina_iterator_free(), eina_list_append(), EINA_LIST_FOREACH, eina_list_merge(), _Eina_File::global_map, _Eina_File::global_refcount, _Eina_File::length, _Eina_File_Map::length, _Eina_File::lock, _Eina_File::map, _Eina_File_Map::map, _Eina_File_Map::offset, _Eina_File::refcount, _Eina_File_Map::refcount, and _Eina_File::rmap.

Referenced by eina_file_refresh().

## eina_file_common_map_free()

void eina_file_common_map_free | ( | Eina_File * | file,
|  | void * | map,
|  | void(* | free_func )(Eina_File_Map *map) )

Removes a mapped region from the file and frees the resources.

This routine will remove a previously mapped region from the internal Eina File housekeeping and free the resources associated with it. In the case where the map is part of the dead_map, `free_func` will be called to handle the actual deallocation.

Parameters

  [in,out] | file | The file.
  [in,out] | map | The memory mapped region that is to be freed.
  [in] | free_func | A pointer to a function that will be called to free up the resources used by the map.

References _Eina_File::dead_map, EINA_FALSE, eina_hash_del(), eina_hash_find(), EINA_LIST_FOREACH, eina_list_remove_list(), EINA_TRUE, _Eina_File_Map::length, _Eina_File::map, _Eina_File_Map::map, _Eina_File_Map::offset, _Eina_File_Map::refcount, and _Eina_File::rmap.

Referenced by eina_file_map_free().

## eina_file_virtual_map_all()

void * eina_file_virtual_map_all | ( | Eina_File * | file | ) |

Map the entire contents of a virtual file to a buffer.

Parameters

  [in] | file | The virtual file to map in memory

Returns
  The buffer

References _Eina_File::global_map, _Eina_File::global_refcount, and _Eina_File::lock.

Referenced by eina_file_map_all().

## eina_file_virtual_map_new()

void * eina_file_virtual_map_new | ( | Eina_File * | file,
|  | unsigned long int | offset,
|  | unsigned long int | length )

Map a part of a virtual file to a buffer.

Parameters

  [in,out] | file | The virtual file to map in memory
  [in] | offset | The offset inside the file to start mapping
  [in] | length | The length of the region to map

Returns
  The buffer

References eina_hash_add(), eina_hash_direct_add(), eina_hash_find(), _Eina_File::global_map, _Eina_File_Map::length, _Eina_File::lock, _Eina_File::map, _Eina_File_Map::map, _Eina_File_Map::offset, _Eina_File_Map::refcount, and _Eina_File::rmap.

Referenced by eina_file_map_new().

## eina_file_virtual_map_free()

void eina_file_virtual_map_free | ( | Eina_File * | file,
|  | void * | map )

Unref and unmap memory if possible.

Parameters

  [in,out] | file | The file handler to unmap memory from.
  [in,out] | map | Memory map to unref and unmap.

References eina_hash_del(), eina_hash_find(), _Eina_File::global_map, _Eina_File::global_refcount, _Eina_File_Map::length, _Eina_File::lock, _Eina_File::map, _Eina_File_Map::offset, _Eina_File_Map::refcount, and _Eina_File::rmap.

Referenced by eina_file_map_free().

## eina_file_map_key_length()

unsigned int eina_file_map_key_length | ( | const void * | key | ) |

Get the length of a map key.

Warning
  This function is not yet implemented. At present it only returns
  sizeof (unsigned long int) * 2

Parameters

  [in] | key | The key for which length will be calculated.

Returns
  The length of the key.

References EINA_UNUSED.

Referenced by eina_file_open(), eina_file_open(), and eina_file_virtualize().

## eina_file_map_key_cmp()

int eina_file_map_key_cmp | ( | const unsigned long long int * | key1,
|  | int | key1_length,
|  | const unsigned long long int * | key2,
|  | int | key2_length )

Compares two map keys.

The implementation assumes that `key1` and `key2` are both pointers to an array with 2 elements, as is the case with the Eina file map keys.

Parameters

  [in] | key1 | The first key.
  [in] | key1_length | The length of the first key.
  [in] | key2 | The second key.
  [in] | key2_length | The length of the second key.

Returns
  Positive number if Key1 > Key2, else a negative number. Will return zero if both elements of the key are exactly the same.

References EINA_UNUSED.

Referenced by eina_file_open(), eina_file_open(), and eina_file_virtualize().

## eina_file_map_key_hash()

int eina_file_map_key_hash | ( | const unsigned long long int * | key,
|  | int | key_length )

Creates a hash from a map key.

Parameters

  [in] | key | A pointer to the key.
  [in] | key_length | The length of the key.

Returns
  A key hash.

References eina_hash_int64(), and EINA_UNUSED.

Referenced by eina_file_open(), eina_file_open(), and eina_file_virtualize().