NetSurf
|
Table operations for files with posix compliant path separator. More...
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include "desktop/gui_internal.h"
#include "utils/utils.h"
#include "utils/corestrings.h"
#include "utils/url.h"
#include "utils/nsurl.h"
#include "utils/file.h"
#include "utils/dirent.h"
Go to the source code of this file.
Functions | |
static nserror | posix_vmkpath (char **str, size_t *size, size_t nelm, va_list ap) |
Generate a posix path from one or more component elemnts. More... | |
static nserror | posix_basename (const char *path, char **str, size_t *size) |
Get the basename of a file using posix path handling. More... | |
static nserror | posix_nsurl_to_path (struct nsurl *url, char **path_out) |
Create a path from a nsurl using posix file handling. More... | |
static nserror | posix_path_to_nsurl (const char *path, struct nsurl **url_out) |
Create a nsurl from a path using posix file handling. More... | |
static nserror | posix_mkdir_all (const char *fname) |
Ensure that all directory elements needed to store a filename exist. More... | |
nserror | netsurf_mkpath (char **str, size_t *size, size_t nelm,...) |
Generate a path from one or more component elemnts. More... | |
nserror | netsurf_nsurl_to_path (struct nsurl *url, char **path_out) |
Create a path from a nsurl. More... | |
nserror | netsurf_path_to_nsurl (const char *path, struct nsurl **url) |
Create a nsurl from a path. More... | |
nserror | netsurf_mkdir_all (const char *fname) |
Ensure that all directory elements needed to store a filename exist. More... | |
nserror | netsurf_recursive_rm (const char *path) |
Recursively remove a directory. More... | |
Variables | |
static struct gui_file_table | file_table |
default to using the posix file handling More... | |
struct gui_file_table * | default_file_table = &file_table |
Default (posix) file operation table. More... | |
Table operations for files with posix compliant path separator.
Definition in file file.c.
nserror netsurf_mkdir_all | ( | const char * | fname | ) |
Ensure that all directory elements needed to store a filename exist.
fname | The filename to ensure the path to exists. |
Definition at line 313 of file file.c.
References netsurf_table::file, guit, and gui_file_table::mkdir_all.
Referenced by create_cache_home(), create_config_home(), ro_gui_create_dirs(), store_open(), and write_control().
nserror netsurf_mkpath | ( | char ** | str, |
size_t * | size, | ||
size_t | nelm, | ||
... | |||
) |
Generate a path from one or more component elemnts.
If a string is allocated it must be freed by the caller.
[in,out] | str | pointer to string pointer if this is NULL enough storage will be allocated for the complete path. |
[in,out] | size | The size of the space available if str not NULL on input and if not NULL set to the total output length on output. |
[in] | nelm | The number of elements. |
[in] | ... | The elements of the path as string pointers. |
Definition at line 288 of file file.c.
References netsurf_table::file, guit, and gui_file_table::mkpath.
Referenced by ami_gui_check_resource(), ami_gui_map_filename(), ami_locate_resource(), check_dirname(), create_cache_home(), create_config_home(), get_cachepath(), netsurf_recursive_rm(), nsgtk_option_init(), nsgtk_preferences_dialogPreferences_deleteevent(), nsgtk_preferences_dialogPreferences_destroy(), nsgtk_preferences_dialogPreferences_response(), nsgtk_toolbar_customisation_save(), nsw32_option_init(), nsws_prefs_save(), print_button_clicked_cb(), process_dir_ent(), read_blocks(), read_control(), read_entries(), save_complete_inventory(), save_complete_save_buffer(), save_complete_save_html_document(), savewindowsize_button_clicked_cb(), set_defaults(), store_fname(), unlink_entries(), write_blocks(), write_cache_tag(), write_control(), and write_entries().
Create a path from a nsurl.
[in] | url | The url to encode. |
[out] | path_out | A string containing the result path which must be freed by the caller. |
Definition at line 301 of file file.c.
References netsurf_table::file, guit, and gui_file_table::nsurl_to_path.
Referenced by ro_gui_view_source(), and ro_gui_window_close().
Create a nsurl from a path.
Perform the necessary operations on a path to generate a nsurl.
[in] | path | The path to convert. |
[out] | url | pointer to recive the nsurl, The returned url should be unreferenced by the caller. |
Definition at line 307 of file file.c.
References netsurf_table::file, guit, path(), and gui_file_table::path_to_nsurl.
Referenced by ami_file_open(), ami_handle_applib(), ami_handle_appmsg(), get_resource_url(), gui_get_resource_url(), gui_init(), gui_init2(), nsgtk_get_resource_url(), nsw32_get_resource_url(), ro_msg_dataload(), ro_msg_dataopen(), and tab_init_fname().
nserror netsurf_recursive_rm | ( | const char * | path | ) |
Recursively remove a directory.
If this returns a failure code, there's an unpredictable amount left unremoved.
path | The path to recursively remove |
Definition at line 320 of file file.c.
References netsurf_mkpath(), netsurf_recursive_rm(), NSERROR_NOT_FOUND, NSERROR_OK, NSERROR_UNKNOWN, parent, and path().
Referenced by filename_flush_directory(), initialise(), and netsurf_recursive_rm().
|
static |
Get the basename of a file using posix path handling.
This gets the last element of a path and returns it.
[in] | path | The path to extract the name from. |
[in,out] | str | Pointer to string pointer if this is NULL enough storage will be allocated for the path element. |
[in,out] | size | The size of the space available if str not NULL on input and set to the total output length on output. |
Definition at line 80 of file file.c.
References NSERROR_BAD_PARAMETER, NSERROR_NOMEM, NSERROR_OK, and path().
|
static |
Ensure that all directory elements needed to store a filename exist.
fname | The filename to ensure the path to exists. |
Definition at line 217 of file file.c.
References NSERROR_NOT_DIRECTORY, NSERROR_NOT_FOUND, NSERROR_OK, and nsmkdir.
Create a path from a nsurl using posix file handling.
[in] | url | The url to encode. |
[out] | path_out | A string containing the result path which should be freed by the caller. |
Definition at line 117 of file file.c.
References NSERROR_BAD_PARAMETER, NSERROR_OK, nsurl_get_component(), NSURL_PATH, NSURL_SCHEME, path(), and url_unescape().
Create a nsurl from a path using posix file handling.
Perform the necessary operations on a path to generate a nsurl.
[in] | path | The path to convert. |
[out] | url_out | pointer to recive the nsurl, The returned url should be unreferenced by the caller. |
Definition at line 171 of file file.c.
References FILE_SCHEME_PREFIX, FILE_SCHEME_PREFIX_LEN, NSERROR_BAD_PARAMETER, NSERROR_NOMEM, NSERROR_OK, nsurl_create(), path(), and url_escape().
|
static |
Generate a posix path from one or more component elemnts.
If a string is allocated it must be freed by the caller.
[in,out] | str | pointer to string pointer if this is NULL enough storage will be allocated for the complete path. |
[in,out] | size | The size of the space available if str not NULL on input and if not NULL set to the total output length on output. |
[in] | nelm | The number of elements. |
[in] | ap | The elements of the path as string pointers. |
Definition at line 61 of file file.c.
References vsnstrjoin().
struct gui_file_table* default_file_table = &file_table |
Default (posix) file operation table.
Definition at line 285 of file file.c.
Referenced by netsurf_register().
|
static |
default to using the posix file handling