diff options
Diffstat (limited to 'apps/misc.c')
-rw-r--r-- | apps/misc.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/apps/misc.c b/apps/misc.c index 93b5247ae9..e6c8a219ea 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -1387,6 +1387,32 @@ int string_option(const char *option, const char *const oplist[], bool ignore_ca | |||
1387 | return -1; | 1387 | return -1; |
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | /* Make sure part of path only contain chars valid for a FAT32 long name. | ||
1391 | * Double quotes are replaced with single quotes, other unsupported chars | ||
1392 | * are replaced with an underscore. | ||
1393 | * | ||
1394 | * path - path to modify. | ||
1395 | * offset - where in path to start checking. | ||
1396 | * count - number of chars to check. | ||
1397 | */ | ||
1398 | void fix_path_part(char* path, int offset, int count) | ||
1399 | { | ||
1400 | static const char invalid_chars[] = "*/:<>?\\|"; | ||
1401 | int i; | ||
1402 | |||
1403 | path += offset; | ||
1404 | |||
1405 | for (i = 0; i <= count; i++, path++) | ||
1406 | { | ||
1407 | if (*path == 0) | ||
1408 | return; | ||
1409 | if (*path == '"') | ||
1410 | *path = '\''; | ||
1411 | else if (strchr(invalid_chars, *path)) | ||
1412 | *path = '_'; | ||
1413 | } | ||
1414 | } | ||
1415 | |||
1390 | /* open but with a builtin printf for assembling the path */ | 1416 | /* open but with a builtin printf for assembling the path */ |
1391 | int open_pathfmt(char *buf, size_t size, int oflag, const char *pathfmt, ...) | 1417 | int open_pathfmt(char *buf, size_t size, int oflag, const char *pathfmt, ...) |
1392 | { | 1418 | { |