NetSurf
Functions | Variables
file.c File Reference

Atari file handling callbacks. More...

#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "utils/utils.h"
#include "utils/corestrings.h"
#include "utils/url.h"
#include "utils/nsurl.h"
#include "utils/file.h"
Include dependency graph for file.c:

Go to the source code of this file.

Functions

static nserror atari_mkpath (char **str, size_t *size, size_t nelm, va_list ap)
 Generate a GEMDOS path from one or more component elemnts. More...
 
static nserror atari_basename (const char *path, char **str, size_t *size)
 Get the basename of a file using GEMDOS path handling. More...
 
static nserror atari_nsurl_to_path (struct nsurl *url, char **path_out)
 Create a path from a nsurl using GEMDOS file handling. More...
 
static nserror atari_path_to_nsurl (const char *path, struct nsurl **url_out)
 Create a nsurl from a path using GEMDOS file handling. More...
 
static nserror atari_mkdir_all (const char *fname)
 Ensure that all directory elements needed to store a filename exist. More...
 

Variables

static struct gui_file_table file_table
 
struct gui_file_tableatari_file_table = &file_table
 

Detailed Description

Atari file handling callbacks.

Most of this code was taken from windows/gui.c

Definition in file file.c.

Function Documentation

◆ atari_basename()

static nserror atari_basename ( const char *  path,
char **  str,
size_t *  size 
)
static

Get the basename of a file using GEMDOS path handling.

This gets the last element of a path and returns it.

Parameters
[in]pathThe path to extract the name from.
[in,out]strPointer to string pointer if this is NULL enough storage will be allocated for the path element.
[in,out]sizeThe size of the space available if str not NULL on input and set to the total output length on output.
Returns
NSERROR_OK and the complete path is written to str or error code on faliure.

Definition at line 75 of file file.c.

References NSERROR_BAD_PARAMETER, NSERROR_NOMEM, NSERROR_OK, and path().

Here is the call graph for this function:

◆ atari_mkdir_all()

static nserror atari_mkdir_all ( const char *  fname)
static

Ensure that all directory elements needed to store a filename exist.

Parameters
fnameThe filename to ensure the path to exists.
Returns
NSERROR_OK on success or error code on failure.

Definition at line 229 of file file.c.

References NSERROR_NOT_DIRECTORY, NSERROR_NOT_FOUND, NSERROR_OK, and nsmkdir.

◆ atari_mkpath()

static nserror atari_mkpath ( char **  str,
size_t *  size,
size_t  nelm,
va_list  ap 
)
static

Generate a GEMDOS path from one or more component elemnts.

If a string is allocated it must be freed by the caller.

Parameters
[in,out]strpointer to string pointer if this is NULL enough storage will be allocated for the complete path.
[in,out]sizeThe size of the space available if str not NULL on input and if not NULL set to the total output length on output.
[in]nelmThe number of elements.
[in]apThe elements of the path as string pointers.
Returns
NSERROR_OK and the complete path is written to str or error code on faliure.

Definition at line 56 of file file.c.

References vsnstrjoin().

Here is the call graph for this function:

◆ atari_nsurl_to_path()

static nserror atari_nsurl_to_path ( struct nsurl url,
char **  path_out 
)
static

Create a path from a nsurl using GEMDOS file handling.

Parameters
[in]urlThe url to encode.
[out]path_outA string containing the result path which should be freed by the caller.
Returns
NSERROR_OK and the path is written to path or error code on faliure.
Todo:
Need to check returning the unaltered path in this case is correct

Definition at line 112 of file file.c.

References NSERROR_BAD_PARAMETER, NSERROR_OK, nsurl_get_component(), NSURL_PATH, NSURL_SCHEME, path(), and url_unescape().

Here is the call graph for this function:

◆ atari_path_to_nsurl()

static nserror atari_path_to_nsurl ( const char *  path,
struct nsurl **  url_out 
)
static

Create a nsurl from a path using GEMDOS file handling.

Perform the necessary operations on a path to generate a nsurl.

Parameters
[in]pathThe path to convert.
[out]url_outpointer to recive the nsurl, The returned url should be unreferenced by the caller.
Returns
NSERROR_OK and the url is placed in url or error code on faliure.

Definition at line 183 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().

Here is the call graph for this function:

Variable Documentation

◆ atari_file_table

struct gui_file_table* atari_file_table = &file_table

Definition at line 296 of file file.c.

Referenced by main().

◆ file_table

struct gui_file_table file_table
static
Initial value:
= {
.mkpath = atari_mkpath,
.basename = atari_basename,
.nsurl_to_path = atari_nsurl_to_path,
.path_to_nsurl = atari_path_to_nsurl,
.mkdir_all = atari_mkdir_all,
}
static nserror atari_path_to_nsurl(const char *path, struct nsurl **url_out)
Create a nsurl from a path using GEMDOS file handling.
Definition: file.c:183
static nserror atari_mkdir_all(const char *fname)
Ensure that all directory elements needed to store a filename exist.
Definition: file.c:229
static nserror atari_mkpath(char **str, size_t *size, size_t nelm, va_list ap)
Generate a GEMDOS path from one or more component elemnts.
Definition: file.c:56
static nserror atari_basename(const char *path, char **str, size_t *size)
Get the basename of a file using GEMDOS path handling.
Definition: file.c:75
static nserror atari_nsurl_to_path(struct nsurl *url, char **path_out)
Create a path from a nsurl using GEMDOS file handling.
Definition: file.c:112

Definition at line 288 of file file.c.