89 leafname = strrchr(
path,
'/');
96 fname = strdup(leafname);
103 *size = strlen(fname);
125 if ((url == NULL) || (path_out == NULL)) {
131 if (lwc_string_caseless_isequal(scheme, corestring_lwc_file,
132 &match) != lwc_error_ok)
136 lwc_string_unref(scheme);
137 if (match ==
false) {
142 if (urlpath == NULL) {
147 lwc_string_length(urlpath),
150 lwc_string_unref(urlpath);
179 if ((
path == NULL) || (url_out == NULL) || (*
path == 0)) {
190 while (*escpaths ==
'/') {
196 urlstr = malloc(urllen);
197 if (urlstr == NULL) {
223 dname = strdup(fname);
225 sep = strrchr(dname,
'/');
234 if (stat(dname, &sb) == 0) {
236 if (S_ISDIR(sb.st_mode)) {
245 while (*sep ==
'/') {
248 while ((sep = strchr(sep,
'/')) != NULL) {
250 if (stat(dname, &sb) != 0) {
251 if (
nsmkdir(dname, S_IRWXU) != 0) {
257 if (! S_ISDIR(sb.st_mode)) {
265 while (*sep ==
'/') {
323 struct dirent *entry;
325 struct stat ent_stat;
337 while ((entry = readdir(
parent))) {
338 char *leafpath = NULL;
340 if (strcmp(entry->d_name,
".") == 0 ||
341 strcmp(entry->d_name,
"..") == 0)
348#if (defined(HAVE_DIRFD) && defined(HAVE_FSTATAT))
349 if (fstatat(dirfd(
parent), entry->d_name, &ent_stat,
350 AT_SYMLINK_NOFOLLOW) != 0) {
352 if (stat(leafpath, &ent_stat) != 0) {
357 if (S_ISDIR(ent_stat.st_mode)) {
364#if (defined(HAVE_DIRFD) && defined(HAVE_UNLINKAT))
365 if (unlinkat(dirfd(
parent), entry->d_name, 0) != 0) {
367 if (unlink(leafpath) != 0) {
377 if (rmdir(
path) != 0) {
Useful interned string pointers (interface).
#define FILE_SCHEME_PREFIX_LEN
File url prefix length.
#define FILE_SCHEME_PREFIX
File url prefix.
directory traversal and entry
nserror
Enumeration of error codes.
@ NSERROR_NOT_FOUND
Requested item not found.
@ NSERROR_BAD_PARAMETER
Bad Parameter.
@ NSERROR_UNKNOWN
Unknown error - DO NOT USE.
@ NSERROR_NOT_DIRECTORY
Missing directory.
@ NSERROR_NOMEM
Memory exhaustion.
struct netsurf_table * guit
The global interface table.
Interface to core interface table.
NetSurf URL handling (interface).
nserror nsurl_create(const char *const url_s, nsurl **url)
Create a NetSurf URL object from a URL string.
lwc_string * nsurl_get_component(const nsurl *url, nsurl_component part)
Get part of a URL as a lwc_string, from a NetSurf URL object.
struct nsurl nsurl
NetSurf URL object.
Minimal compatibility header for AmigaOS 3.
Interface to utility string handling.
nserror vsnstrjoin(char **str, size_t *size, char sep, size_t nelm, va_list ap)
Generate a string from one or more component elements separated with a single value.
/brief function table for file and filename operations.
nserror(* mkdir_all)(const char *fname)
Ensure that all directory elements needed to store a filename exist.
nserror(* nsurl_to_path)(struct nsurl *url, char **path)
Create a path from a nsurl.
nserror(* mkpath)(char **str, size_t *size, size_t nemb, va_list ap)
Generate a path from one or more component elemnts.
nserror(* path_to_nsurl)(const char *path, struct nsurl **url)
Create a nsurl from a path.
struct gui_file_table * file
File table.
nserror url_escape(const char *unescaped, bool sptoplus, const char *escexceptions, char **result)
Escape a string suitable for inclusion in an URL.
nserror url_unescape(const char *str, size_t length, size_t *length_out, char **result_out)
Convert an escaped string to plain.
Interface to URL parsing and joining operations.
static nserror posix_nsurl_to_path(struct nsurl *url, char **path_out)
Create a path from a nsurl using posix file handling.
nserror netsurf_mkdir_all(const char *fname)
Ensure that all directory elements needed to store a filename exist.
static nserror posix_path_to_nsurl(const char *path, struct nsurl **url_out)
Create a nsurl from a path using posix file handling.
nserror netsurf_nsurl_to_path(struct nsurl *url, char **path_out)
Create a path from a nsurl.
static nserror posix_mkdir_all(const char *fname)
Ensure that all directory elements needed to store a filename exist.
static struct gui_file_table file_table
default to using the posix file handling
struct gui_file_table * default_file_table
Default (posix) file operation table.
static nserror posix_basename(const char *path, char **str, size_t *size)
Get the basename of a file using posix path handling.
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.
nserror netsurf_path_to_nsurl(const char *path, struct nsurl **url)
Create a nsurl from a path.
nserror netsurf_mkpath(char **str, size_t *size, size_t nelm,...)
Generate a path from one or more component elemnts.
nserror netsurf_recursive_rm(const char *path)
Recursively remove a directory.
Default operations table for files.
Interface to a number of general purpose functionality.
#define nsmkdir(dir, mode)
POSIX mkdir function.
static nserror path(const struct redraw_context *ctx, const plot_style_t *pstyle, const float *p, unsigned int n, const float transform[6])
Plots a path.