From c6396d9204cb40f7736530e793288948e1adb55f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 28 Jul 2015 21:30:20 +1000 Subject: Fix for file unpack checking existing files Wasn't expanding the path '//' before checking the path on-disk. --- source/blender/blenkernel/intern/packedFile.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern/packedFile.c') diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 800df252c69..151889b10a1 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -418,12 +418,14 @@ int checkPackedFile(const char *filename, PackedFile *pf) return(ret_val); } -/* unpackFile() looks at the existing files (abs_name, local_name) and a packed file. +/** + * unpackFile() looks at the existing files (abs_name, local_name) and a packed file. * * It returns a char *to the existing file name / new file name or NULL when * there was an error or when the user decides to cancel the operation. + * + * \warning 'abs_name' may be relative still! (use a "//" prefix) be sure to run #BLI_path_abs on it first. */ - char *unpackFile(ReportList *reports, const char *abs_name, const char *local_name, PackedFile *pf, int how) { char *newname = NULL; @@ -438,27 +440,41 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na temp = abs_name; break; case PF_USE_LOCAL: + { + char temp_abs[FILE_MAX]; + + BLI_strncpy(temp_abs, local_name, sizeof(temp_abs)); + BLI_path_abs(temp_abs, G.main->name); + /* if file exists use it */ - if (BLI_exists(local_name)) { + if (BLI_exists(temp_abs)) { temp = local_name; break; } /* else create it */ /* fall-through */ + } case PF_WRITE_LOCAL: if (writePackedFile(reports, local_name, pf, 1) == RET_OK) { temp = local_name; } break; case PF_USE_ORIGINAL: + { + char temp_abs[FILE_MAX]; + + BLI_strncpy(temp_abs, abs_name, sizeof(temp_abs)); + BLI_path_abs(temp_abs, G.main->name); + /* if file exists use it */ - if (BLI_exists(abs_name)) { + if (BLI_exists(temp_abs)) { BKE_reportf(reports, RPT_INFO, "Use existing file (instead of packed): %s", abs_name); temp = abs_name; break; } /* else create it */ /* fall-through */ + } case PF_WRITE_ORIGINAL: if (writePackedFile(reports, abs_name, pf, 1) == RET_OK) { temp = abs_name; -- cgit v1.2.3