Add rename code back
This partially reverts commit a7db63415007c9e042cfccd9b7e106f2a21fdb53.
Renaming is used when user changes the suffix.
Test: renamed bugreport in interactive mode and verified the final
carried the new name.
Change-Id: Ia86e7ce9d9ed71de7b4e4b0c90ee7320c50762d8
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 026c260..9a11da6 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -1858,6 +1858,17 @@
do_text_file = true;
} else {
do_text_file = false;
+ // If the user has changed the suffix, we need to change the zip file name.
+ std::string new_path = ds.GetPath(".zip");
+ if (ds.path_ != new_path) {
+ MYLOGD("Renaming zip file from %s to %s\n", ds.path_.c_str(), new_path.c_str());
+ if (rename(ds.path_.c_str(), new_path.c_str())) {
+ MYLOGE("rename(%s, %s): %s\n", ds.path_.c_str(), new_path.c_str(),
+ strerror(errno));
+ } else {
+ ds.path_ = new_path;
+ }
+ }
}
}
if (do_text_file) {