diff options
| author | 2016-02-26 15:03:52 -0800 | |
|---|---|---|
| committer | 2016-02-26 15:26:12 -0800 | |
| commit | 9127435ffbb081fe91a30169f394a57fd31fd05e (patch) | |
| tree | 846979a42ec4c59c27dec1d4a0730f65a6d3a1ed | |
| parent | c507e7c3883c698ea8456709df4d2136fde7d388 (diff) | |
Rename .zip file if necessary.
Users have the option to rename the suffix of the files generated by
dumpstate by letting Shell set the dumpstate.PID.name property.
This works fine for text files and used to work for zip files as well,
but now the zip file is opened earlier in the process, so it has to be
renamed at the end.
BUG: 27384407
Change-Id: I288d8eb4a3ffe0161b86cdce14f63e9bfdf865ab
| -rw-r--r-- | cmds/dumpstate/dumpstate.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 3abd8f0b76..9bc5b5ceb0 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -1335,6 +1335,17 @@ int main(int argc, char *argv[]) { do_text_file = true; } else { do_text_file = false; + // Since zip file is already created, it needs to be renamed. + std::string new_path = bugreport_dir + "/" + base_name + "-" + suffix + ".zip"; + if (path != new_path) { + MYLOGD("Renaming zip file from %s to %s\n", path.c_str(), new_path.c_str()); + if (rename(path.c_str(), new_path.c_str())) { + MYLOGE("rename(%s, %s): %s\n", path.c_str(), + new_path.c_str(), strerror(errno)); + } else { + path = new_path; + } + } } } if (do_text_file) { |