file-operations: replace control characters for FAT fs operations

Those are invalid - if we find one, replace it with an underscore as
well.

https://bugzilla.gnome.org/show_bug.cgi?id=706131
This commit is contained in:
Cosimo Cecchi 2013-08-16 18:32:50 +02:00
parent 16ea52970d
commit 8ff0bf18f9

View file

@ -3080,16 +3080,16 @@ get_max_name_length (GFile *file_dir)
#define FAT_FORBIDDEN_CHARACTERS "/:;*?\"<>"
static gboolean
str_replace (char *str,
const char *chars_to_replace,
char replacement)
fat_str_replace (char *str,
char replacement)
{
gboolean success;
int i;
success = FALSE;
for (i = 0; str[i] != '\0'; i++) {
if (strchr (chars_to_replace, str[i])) {
if (strchr (FAT_FORBIDDEN_CHARACTERS, str[i]) ||
str[i] < 32) {
success = TRUE;
str[i] = replacement;
}
@ -3110,7 +3110,7 @@ make_file_name_valid_for_dest_fs (char *filename,
gboolean ret;
int i, old_len;
ret = str_replace (filename, FAT_FORBIDDEN_CHARACTERS, '_');
ret = fat_str_replace (filename, '_');
old_len = strlen (filename);
for (i = 0; i < old_len; i++) {