|
NetSurf
|
Provides a central method of obtaining unique filenames. More...
#include <assert.h>#include <sys/types.h>#include <stdbool.h>#include <string.h>#include <stdio.h>#include <stdlib.h>#include <errno.h>#include <fcntl.h>#include <sys/stat.h>#include <unistd.h>#include "utils/dirent.h"#include "utils/errors.h"#include "utils/file.h"#include "utils/filename.h"#include "utils/log.h"#include "utils/utils.h"Go to the source code of this file.
Data Structures | |
| struct | directory |
Macros | |
| #define | FULL_WORD (unsigned int)0xffffffffu |
| #define | START_PREFIX ('0' + '0' * 10) |
Functions | |
| static struct directory * | filename_create_directory (const char *prefix) |
| Creates a new directory. More... | |
| static bool | filename_flush_directory (const char *folder, int depth) |
| Deletes some files in a directory that are not accounted for. More... | |
| const char * | filename_request (void) |
| Request a new, unique, filename. More... | |
| bool | filename_claim (const char *filename) |
| Claim a specific filename. More... | |
| void | filename_release (const char *filename) |
| Releases a filename for future use. More... | |
| bool | filename_initialise (void) |
| Initialise the filename provider. More... | |
| void | filename_flush (void) |
| Deletes all files in the cache directory that are not accounted for. More... | |
Variables | |
| static struct directory * | root = NULL |
| static char | filename_buffer [12] |
| static char | filename_directory [256] |
Provides a central method of obtaining unique filenames.
A maximum of 2^24 files can be allocated at any point in time.
Definition in file filename.c.
| #define FULL_WORD (unsigned int)0xffffffffu |
Definition at line 43 of file filename.c.
| #define START_PREFIX ('0' + '0' * 10) |
Definition at line 44 of file filename.c.
| bool filename_claim | ( | const char * | filename | ) |
Claim a specific filename.
| filename | the filename to claim |
Definition at line 115 of file filename.c.
References filename_create_directory(), directory::high_used, directory::low_used, and START_PREFIX.
|
static |
Creates a new directory.
| prefix | the prefix to use, or NULL to allocate a new one |
Empty directories are never deleted, except by an explicit call to filename_flush().
Definition at line 401 of file filename.c.
References filename_directory, directory::high_used, is_dir(), directory::low_used, directory::next, NSLOG, nsmkdir, directory::numeric_prefix, directory::prefix, root, SLEN, START_PREFIX, and TEMP_FILENAME_PREFIX.
Referenced by filename_claim(), and filename_request().
| void filename_flush | ( | void | ) |
Deletes all files in the cache directory that are not accounted for.
Definition at line 219 of file filename.c.
References filename_flush_directory(), and TEMP_FILENAME_PREFIX.
|
static |
Deletes some files in a directory that are not accounted for.
A single call to this function may not delete all the files in a directory. It should be called until it returns false.
| folder | the folder to search |
| depth | the folder depth |
Definition at line 235 of file filename.c.
References filename_flush_directory(), directory::high_used, directory::low_used, netsurf_recursive_rm(), directory::next, NSERROR_OK, NSLOG, directory::numeric_prefix, parent, directory::prefix, root, and START_PREFIX.
Referenced by filename_flush(), and filename_flush_directory().
| bool filename_initialise | ( | void | ) |
Initialise the filename provider.
Definition at line 178 of file filename.c.
References NSLOG, nsmkdir, and TEMP_FILENAME_PREFIX.
Referenced by gui_init().
| void filename_release | ( | const char * | filename | ) |
Releases a filename for future use.
| filename | the filename to release |
Definition at line 151 of file filename.c.
References directory::high_used, directory::low_used, directory::next, directory::numeric_prefix, root, and START_PREFIX.
| const char * filename_request | ( | void | ) |
Request a new, unique, filename.
Definition at line 68 of file filename.c.
References filename_buffer, filename_create_directory(), FULL_WORD, directory::high_used, directory::low_used, directory::next, NSLOG, directory::prefix, and root.
Referenced by nsbeos_gui_view_source(), and ro_gui_view_source().
|
static |
Definition at line 56 of file filename.c.
Referenced by filename_request().
|
static |
Definition at line 57 of file filename.c.
Referenced by filename_create_directory().
|
static |
Definition at line 55 of file filename.c.
Referenced by box_normalise_block(), box_normalise_flex(), box_normalise_inline_container(), box_normalise_table(), box_normalise_table_row(), box_normalise_table_row_group(), box_normalise_table_spans(), browser_window_callback(), browser_window_console_log(), browser_window_content_ready(), browser_window_convert_to_download(), browser_window_download(), browser_window_frame_resize_start(), browser_window_get_position(), browser_window_set_pointer(), convert_xml_to_box(), cookie_manager_find_entry(), cookie_manager_find_folder(), CookieWindow::CookieWindow(), fb_redraw_text(), fb_redraw_text_button(), fbtk_click(), fbtk_enable_oskb(), fbtk_event(), fbtk_get_caret(), fbtk_get_nsfb(), fbtk_get_redraw_pending(), fbtk_init(), fbtk_input(), fbtk_redraw(), fbtk_set_caret(), fbtk_set_focus(), fbtk_set_ptr(), fbtk_tgrab_pointer(), fbtk_warp_pointer(), filename_create_directory(), filename_flush_directory(), filename_release(), filename_request(), gui_resize(), hscroll_redraw(), layout_position_relative(), ns_computed_display(), save_complete_libdom_treewalk(), treeview_create_node_root(), treeview_redraw_search(), treeview_redraw_tree(), treeview_walk(), treeview_walk_internal(), urldb_count_urls(), urldb_destroy_host_tree(), urldb_destroy_path_tree(), urldb_destroy_search_tree(), urldb_iterate_partial_host(), urldb_search_find(), urldb_search_insert(), urldb_search_insert_internal(), urldb_search_skew(), urldb_search_split(), vscroll_redraw(), and window_scroll_by().