From c9ff7a341b03b3013eca57c7554417b623ab6bb0 Mon Sep 17 00:00:00 2001 From: Dees_Troy Date: Thu, 27 Sep 2012 10:09:41 -0400 Subject: Port backup name checking to Partition Manager --- extra-functions.c | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) (limited to 'extra-functions.c') diff --git a/extra-functions.c b/extra-functions.c index f202aff33..3735472a3 100644 --- a/extra-functions.c +++ b/extra-functions.c @@ -55,51 +55,3 @@ void run_script(const char *str1, const char *str2, const char *str3, const char } } -int check_backup_name(int show_error) { - // Check the backup name to ensure that it is the correct size and contains only valid characters - // and that a backup with that name doesn't already exist - char backup_name[MAX_BACKUP_NAME_LEN]; - char backup_loc[255], tw_image_dir[255]; - int copy_size = strlen(DataManager_GetStrValue(TW_BACKUP_NAME)); - int index, cur_char; - struct stat st; - - // Check size - if (copy_size > MAX_BACKUP_NAME_LEN) { - if (show_error) - LOGE("Backup name is too long.\n"); - return -2; - } - - // Check characters - strncpy(backup_name, DataManager_GetStrValue(TW_BACKUP_NAME), copy_size); - if (strcmp(backup_name, "0") == 0) - return 0; // A "0" (zero) means to use the current timestamp for the backup name - for (index=0; index= 48 && cur_char <= 57) || (cur_char >= 65 && cur_char <= 91) || cur_char == 93 || cur_char == 95 || (cur_char >= 97 && cur_char <= 123) || cur_char == 125 || cur_char == 45 || cur_char == 46) { - // These are valid characters - // Numbers - // Upper case letters - // Lower case letters - // Space - // and -_.{}[] - } else { - if (show_error) - LOGE("Backup name '%s' contains invalid character: '%c'\n", backup_name, (char)cur_char); - return -3; - } - } - - // Check to make sure that a backup with this name doesn't already exist - strcpy(backup_loc, DataManager_GetStrValue(TW_BACKUPS_FOLDER_VAR)); - sprintf(tw_image_dir,"%s/%s/.", backup_loc, backup_name); - if (stat(tw_image_dir, &st) == 0) { - if (show_error) - LOGE("A backup with this name already exists.\n"); - return -4; - } - - // No problems found, return 0 - return 0; -} -- cgit v1.2.3