Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/readfile.c
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| * \return true is this path ends with a blender file extension. | * \return true is this path ends with a blender file extension. | ||||
| */ | */ | ||||
| bool BLO_has_bfile_extension(const char *str) | bool BLO_has_bfile_extension(const char *str) | ||||
| { | { | ||||
| const char *ext_test[4] = {".blend", ".ble", ".blend.gz", NULL}; | const char *ext_test[4] = {".blend", ".ble", ".blend.gz", NULL}; | ||||
| return BLI_path_extension_check_array(str, ext_test); | return BLI_path_extension_check_array(str, ext_test); | ||||
| } | } | ||||
| /** | |||||
| * Check whether given path ends with a blend backup file extension | |||||
| * Note: returns TRUE for regular blends too, so use cautiously. | |||||
| * (`.blend1`, `.blend2`, `.blend`). | |||||
| * | |||||
| * \param str: The path to check. | |||||
| * \return true is this path ends with a blender backup file extension. | |||||
| */ | |||||
| bool BLO_has_bfile_backup_extension(const char *str) | |||||
| { | |||||
| const size_t a = strlen(str); | |||||
| size_t b = 7; | |||||
| bool retval = 0; | |||||
| if (a == 0 || b >= a) { | |||||
| /* pass */ | |||||
| } | |||||
| else { | |||||
| const char *loc; | |||||
| if (a > b + 1) { | |||||
| b++; | |||||
| } | |||||
| /* allow .blend1 .blend2 .blend32 */ | |||||
| loc = BLI_strcasestr(str + a - b, ".blend"); | |||||
| if (loc) { | |||||
| retval = 1; | |||||
| } | |||||
| } | |||||
| return retval; | |||||
| } | |||||
| /** | /** | ||||
| * Try to explode given path into its 'library components' | * Try to explode given path into its 'library components' | ||||
| * (i.e. a .blend file, id type/group, and data-block itself). | * (i.e. a .blend file, id type/group, and data-block itself). | ||||
| * | * | ||||
| * \param path: the full path to explode. | * \param path: the full path to explode. | ||||
| * \param r_dir: the string that'll contain path up to blend file itself ('library' path). | * \param r_dir: the string that'll contain path up to blend file itself ('library' path). | ||||
| * WARNING! Must be #FILE_MAX_LIBEXTRA long (it also stores group and name strings)! | * WARNING! Must be #FILE_MAX_LIBEXTRA long (it also stores group and name strings)! | ||||
| * \param r_group: the string that'll contain 'group' part of the path, if any. May be NULL. | * \param r_group: the string that'll contain 'group' part of the path, if any. May be NULL. | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||