Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/intern/path_util.c
| Show First 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | void BLI_path_normalize_dir(const char *relabase, char *dir) | ||||
| if (dir[0] == '\0') { | if (dir[0] == '\0') { | ||||
| return; | return; | ||||
| } | } | ||||
| BLI_path_normalize(relabase, dir); | BLI_path_normalize(relabase, dir); | ||||
| BLI_path_slash_ensure(dir); | BLI_path_slash_ensure(dir); | ||||
| } | } | ||||
| bool BLI_filename_make_safe(char *fname) | bool BLI_filename_make_safe_ex(char *fname, bool allow_tokens) | ||||
| { | { | ||||
| const char *invalid = | #define INVALID_CHARS \ | ||||
| "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" | "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" \ | ||||
| "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" | "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" \ | ||||
| "/\\?*:|\"<>"; | "/\\?*:|\"" | ||||
| #define INVALID_TOKENS "<>" | |||||
| const char *invalid = allow_tokens ? INVALID_CHARS : INVALID_CHARS INVALID_TOKENS; | |||||
| #undef INVALID_CHARS | |||||
| #undef INVALID_TOKENS | |||||
| char *fn; | char *fn; | ||||
| bool changed = false; | bool changed = false; | ||||
| if (*fname == '\0') { | if (*fname == '\0') { | ||||
| return changed; | return changed; | ||||
| } | } | ||||
| for (fn = fname; *fn && (fn = strpbrk(fn, invalid)); fn++) { | for (fn = fname; *fn && (fn = strpbrk(fn, invalid)); fn++) { | ||||
| ▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | #ifdef WIN32 | ||||
| MEM_freeN(lower_fname); | MEM_freeN(lower_fname); | ||||
| } | } | ||||
| #endif | #endif | ||||
| return changed; | return changed; | ||||
| } | } | ||||
| bool BLI_filename_make_safe(char *fname) | |||||
| { | |||||
| return BLI_filename_make_safe_ex(fname, false); | |||||
| } | |||||
| bool BLI_path_make_safe(char *path) | bool BLI_path_make_safe(char *path) | ||||
| { | { | ||||
| /* Simply apply BLI_filename_make_safe() over each component of the path. | /* Simply apply BLI_filename_make_safe() over each component of the path. | ||||
| * Luckily enough, same 'safe' rules applies to filenames and dirnames. */ | * Luckily enough, same 'safe' rules applies to filenames and dirnames. */ | ||||
| char *curr_slash, *curr_path = path; | char *curr_slash, *curr_path = path; | ||||
| bool changed = false; | bool changed = false; | ||||
| bool skip_first = false; | bool skip_first = false; | ||||
| ▲ Show 20 Lines • Show All 1,494 Lines • Show Last 20 Lines | |||||