!634 优化解压缩临时文件路径

Merge pull request !634 from yuyanqing/master
This commit is contained in:
openharmony_ci 2024-11-06 07:14:45 +00:00 committed by Gitee
commit 002dcd8d80
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 5 additions and 4 deletions

View File

@ -156,7 +156,7 @@ public:
" must be a power of two, rang[2,1024], default is 1024.\n"
" --app <package_name>\n"
" Collect profile info for an OHOS app, the app must be debuggable.\n"
" Record will exit if the process is not started within 10 seconds.\n"
" Record will exit if the process is not started within 20 seconds.\n"
" --chkms <millisec>\n"
" Set the interval of querying the <package_name>.\n"
" <millisec> is in range [1-200], default is 10.\n"

View File

@ -31,6 +31,7 @@ namespace Developtools {
namespace HiPerf {
const int FETURE_MAX = 256;
const int SIZE_FETURE_COUNT = 8;
constexpr char UNCOMPRESS_TMP_FILE[] = "/data/local/tmp/.perf.data";
std::unique_ptr<PerfFileReader> PerfFileReader::Instance(const std::string &fileName)
{
@ -48,11 +49,11 @@ std::unique_ptr<PerfFileReader> PerfFileReader::Instance(const std::string &file
fclose(fp);
reader->fp_ = nullptr;
CHECK_TRUE(!UncompressFile(fileName, ".perf.data"), nullptr, 1,
CHECK_TRUE(!UncompressFile(fileName, UNCOMPRESS_TMP_FILE), nullptr, 1,
"Fail to UncompressFile(%s)", fileName.c_str());
// open the uncompressed hidden file .perf.data
FILE *fp2 = fopen(".perf.data", "rb");
FILE *fp2 = fopen(UNCOMPRESS_TMP_FILE, "rb");
if (fp2 == nullptr) {
HLOGE("fail to open uncompressed file .perf.data");
return nullptr;
@ -95,7 +96,7 @@ PerfFileReader::~PerfFileReader()
// remove the uncompressed .perf.data
if (compressData_) {
if (remove(".perf.data") != 0) {
if (remove(UNCOMPRESS_TMP_FILE) != 0) {
HLOGE("Fail to remove uncompressed file .perf.data");
perror("Fail to remove temp file");
}