|
myMPD
Internal API documentation
|
File functions for sds strings. More...
#include "compile_time.h"#include "src/lib/sds/sds_file.h"#include "dist/sds/sds.h"#include "src/lib/log.h"#include "src/lib/sds/sds_extras.h"#include <assert.h>#include <errno.h>#include <string.h>
Functions | |
| sds | sds_getline (sds s, FILE *fp, size_t max, int *nread) |
| sds | sds_getfile (sds s, const char *file_path, size_t max, bool remove_newline, bool warn, int *nread) |
| sds | sds_getfile_from_fp (sds s, FILE *fp, size_t max, bool remove_newline, int *nread) |
| sds | sds_basename (sds s) |
| sds | sds_dirname (sds s) |
| void | sds_basename_uri (sds uri) |
| void | sds_strip_slash (sds dirname) |
| void | sds_strip_file_extension (sds filename) |
| sds | sds_replace_file_extension (sds filename, const char *ext) |
| void | sds_sanitize_filename (sds filename) |
| void | sds_sanitize_filename2 (sds filename) |
Variables | |
| static const char * | invalid_filename_chars = "<>/.:?&$%!#=;\a\b\f\n\r\t\v\\|" |
| static const char * | invalid_filename_chars2 = "\a\b\f\n\r\t\v/\\" |
File functions for sds strings.
| sds sds_basename | ( | sds | s | ) |
Replacement for basename function. Modifies the sds string in place.
| s | sds string to apply basename function |
| void sds_basename_uri | ( | sds | uri | ) |
Calculates the basename for files and uris
| uri | sds string to modify in place |
| sds sds_dirname | ( | sds | s | ) |
Replacement for dirname function. Modifies the sds string in place.
| s | sds string to apply dirname function |
| sds sds_getfile | ( | sds | s, |
| const char * | file_path, | ||
| size_t | max, | ||
| bool | remove_newline, | ||
| bool | warn, | ||
| int * | nread ) |
Reads a whole file in the sds string s from *fp Removes whitespace characters from start and end
| s | an already allocated sds string that should hold the file content |
| file_path | filename to read |
| max | maximum bytes to read |
| remove_newline | removes CR/LF if true |
| warn | log an error if file does not exist |
| nread | Number of bytes read, -1 error reading file, -2 file is too big |
| sds sds_getfile_from_fp | ( | sds | s, |
| FILE * | fp, | ||
| size_t | max, | ||
| bool | remove_newline, | ||
| int * | nread ) |
Reads a whole file in the sds string s from *fp Removes whitespace characters from start and end
| s | an already allocated sds string that should hold the file content |
| fp | FILE pointer to read |
| max | maximum bytes to read |
| remove_newline | removes CR/LF if true |
| nread | Number of bytes read, -2 if file is too big |
| sds sds_getline | ( | sds | s, |
| FILE * | fp, | ||
| size_t | max, | ||
| int * | nread ) |
Getline function that trims whitespace characters
| s | an already allocated sds string |
| fp | a file descriptor to read from |
| max | max line length to read |
| nread | Number of bytes read, -1 on EOF |
| sds sds_replace_file_extension | ( | sds | filename, |
| const char * | ext ) |
Replaces the file extension
| filename | sds string to replace the extension |
| ext | new file extension |
| void sds_sanitize_filename | ( | sds | filename | ) |
Replaces invalid and uncommon filename characters with "_"
| filename | sds string to sanitize |
| void sds_sanitize_filename2 | ( | sds | filename | ) |
Replaces invalid filename characters with "_", same chars as vcb_isfilename
| filename | sds string to sanitize |
| void sds_strip_file_extension | ( | sds | filename | ) |
Removes the file extension
| filename | sds string to remove the extension |
| void sds_strip_slash | ( | sds | dirname | ) |
Strips all slashes from the end
| dirname | sds string to strip |
|
static |
Invalid and uncommon characters for filenames.
|
static |
Invalid characters for filenames.