The file manager's names and paths (fm_name.h).
More...
#include "fm_name.h"
#include <string.h>
|
| static char | lower (char c) |
| | c in lower case, for ASCII.
|
| static bool | same3 (const char *s, size_t n, const char *word) |
| | Whether the n bytes at s, in any case, are the 3 of word.
|
| static bool | device (const char *s, size_t n) |
| | Whether the stem of a name, the n bytes before its first full stop, is a device name.
|
| static size_t | name_char (const unsigned char *s) |
| | Bytes of the character at s a name may hold: printable ASCII but the marks a FAT name cannot hold, or a German letter.
|
| fm_name_t | fm_name_check (const char *name) |
| | Whether a person may give a file or a folder the name name.
|
| bool | fm_name_new (const char *name, char *out, size_t n) |
| | The name a save writes first: name and FM_NEW_SUFFIX.
|
| static bool | path_name (const char *s, size_t n) |
| | Whether the n bytes at s are a name a path may hold: not empty, not "." or "..", and without "/".
|
| fm_path_t | fm_path_check (const char *path) |
| | Whether path is a folder path: "" or names separated by one "/", at most FM_PATH_MAX bytes and FM_DEPTH_MAX folders.
|
| size_t | fm_path_depth (const char *path) |
| | Folders in path.
|
| fm_path_t | fm_path_join (const char *dir, const char *name, bool is_dir, char *out, size_t n) |
| | The path of name in folder dir: "name" in the root, "dir/name" elsewhere.
|
| bool | fm_path_up (char *path) |
| | Take the last name off path, in place: up one folder.
|
| const char * | fm_path_base (const char *path) |
| | The last name of path.
|
The file manager's names and paths (fm_name.h).
SPDX-License-Identifier: MIT
◆ device()
| bool device |
( |
const char * | s, |
|
|
size_t | n ) |
|
static |
Whether the stem of a name, the n bytes before its first full stop, is a device name.
- Parameters
-
| s | The name. |
| n | Bytes of its stem. |
- Returns
- true for CON, PRN, AUX, NUL, COM1 to COM9 and LPT1 to LPT9.
◆ fm_name_check()
Whether a person may give a file or a folder the name name.
- Parameters
-
- Returns
- FM_NAME_OK, or the first rule it breaks, in the order of fm_name_t.
◆ fm_name_new()
| bool fm_name_new |
( |
const char * | name, |
|
|
char * | out, |
|
|
size_t | n ) |
The name a save writes first: name and FM_NEW_SUFFIX.
- Parameters
-
| name | The file's name. |
| out | Out: the name; left as it was when refused. |
| n | Room in out. |
- Returns
- false for a NULL, an empty name, a name over FM_NAME_MAX bytes or an
out without room.
◆ fm_path_base()
| const char * fm_path_base |
( |
const char * | path | ) |
|
The last name of path.
- Parameters
-
- Returns
- Inside
path; "" for the root and NULL.
◆ fm_path_check()
Whether path is a folder path: "" or names separated by one "/", at most FM_PATH_MAX bytes and FM_DEPTH_MAX folders.
- Parameters
-
- Returns
- FM_PATH_OK, or the first fault: ARG, LONG, BAD, DEEP.
◆ fm_path_depth()
| size_t fm_path_depth |
( |
const char * | path | ) |
|
Folders in path.
- Parameters
-
- Returns
- 0 for the root and NULL.
◆ fm_path_join()
| fm_path_t fm_path_join |
( |
const char * | dir, |
|
|
const char * | name, |
|
|
bool | is_dir, |
|
|
char * | out, |
|
|
size_t | n ) |
The path of name in folder dir: "name" in the root, "dir/name" elsewhere.
out may be dir itself, so a pane goes down into a folder in place. The name may be any name the card lists; fm_name_check() is the rule for names a person types.
- Parameters
-
| dir | A folder path. |
| name | A name without "/". |
| is_dir | Whether name is a folder: the path then counts it in its depth. |
| out | Out: the path; left as it was when refused. |
| n | Room in out. |
- Returns
- FM_PATH_OK, or the first fault: ARG, then
dir's, then BAD for the name, LONG, DEEP, and ARG for an out without room.
◆ fm_path_up()
| bool fm_path_up |
( |
char * | path | ) |
|
Take the last name off path, in place: up one folder.
- Parameters
-
- Returns
- false at the root and for NULL;
path is unchanged then.
◆ lower()
c in lower case, for ASCII.
- Parameters
-
- Returns
- Its lower case; other characters as they are.
◆ name_char()
| size_t name_char |
( |
const unsigned char * | s | ) |
|
|
static |
Bytes of the character at s a name may hold: printable ASCII but the marks a FAT name cannot hold, or a German letter.
- Parameters
-
| s | The name at the character. |
- Returns
- 1 or 2; 0 for a character no name holds.
◆ path_name()
| bool path_name |
( |
const char * | s, |
|
|
size_t | n ) |
|
static |
Whether the n bytes at s are a name a path may hold: not empty, not "." or "..", and without "/".
- Parameters
-
- Returns
- true for a name.
◆ same3()
| bool same3 |
( |
const char * | s, |
|
|
size_t | n, |
|
|
const char * | word ) |
|
static |
Whether the n bytes at s, in any case, are the 3 of word.
- Parameters
-
| s | The bytes. |
| n | Their count. |
| word | 3 lower-case letters. |
- Returns
- true when they are the same.