From: Jay Freeman (saurik) Date: Sun, 27 Sep 2015 10:09:53 +0000 (-0700) Subject: Push few filename variables into the deeper scope. X-Git-Tag: v2.1.0~90 X-Git-Url: https://git.saurik.com/ldid.git/commitdiff_plain/8762082fa68f4d4b9d4005065a074cc3cfc7e8b8?hp=e57b1f91c2669a5fbc872db6ccd87a4cc6be6e6e Push few filename variables into the deeper scope. --- diff --git a/ldid.cpp b/ldid.cpp index 6207304..12e31ed 100644 --- a/ldid.cpp +++ b/ldid.cpp @@ -1564,28 +1564,29 @@ int main(int argc, char *argv[]) { size_t filei(0), filee(0); _foreach (file, files) try { const char *path(file.c_str()); - const char *base = strrchr(path, '/'); - - std::string dir; - if (base != NULL) - dir.assign(path, base++ - path + 1); - else - base = path; - - const char *name(flag_I ?: base); std::string temp; if (flag_S || flag_r) { Map input(path, O_RDONLY, PROT_READ, MAP_PRIVATE); + std::string dir; + const char *base = strrchr(path, '/'); + + if (base != NULL) + dir.assign(path, base++ - path + 1); + else + base = path; + temp = dir + "." + base + ".cs"; std::filebuf output; _assert(output.open(temp.c_str(), std::ios::out | std::ios::trunc | std::ios::binary) == &output); if (flag_r) resign(input.data(), input.size(), output); - else + else { + const char *name(flag_I ?: base); resign(input.data(), input.size(), output, name, entitlements, key, slots); + } } Map mapping(!temp.empty() ? temp.c_str() : path, flag_T || flag_s);