summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmds/installd/tests/installd_cache_test.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/cmds/installd/tests/installd_cache_test.cpp b/cmds/installd/tests/installd_cache_test.cpp
index db0907017c..5a5cb53431 100644
--- a/cmds/installd/tests/installd_cache_test.cpp
+++ b/cmds/installd/tests/installd_cache_test.cpp
@@ -67,29 +67,29 @@ bool create_cache_path(char path[PKG_PATH_MAX] ATTRIBUTE_UNUSED,
}
static void mkdir(const char* path) {
- const char* fullPath = StringPrintf("/data/local/tmp/user/0/%s", path).c_str();
- ::mkdir(fullPath, 0755);
+ const std::string fullPath = StringPrintf("/data/local/tmp/user/0/%s", path);
+ ::mkdir(fullPath.c_str(), 0755);
}
static void touch(const char* path, int len, int time) {
- const char* fullPath = StringPrintf("/data/local/tmp/user/0/%s", path).c_str();
- int fd = ::open(fullPath, O_RDWR | O_CREAT, 0644);
+ const std::string fullPath = StringPrintf("/data/local/tmp/user/0/%s", path);
+ int fd = ::open(fullPath.c_str(), O_RDWR | O_CREAT, 0644);
::fallocate(fd, 0, 0, len);
::close(fd);
struct utimbuf times;
times.actime = times.modtime = std::time(0) + time;
- ::utime(fullPath, &times);
+ ::utime(fullPath.c_str(), &times);
}
static int exists(const char* path) {
- const char* fullPath = StringPrintf("/data/local/tmp/user/0/%s", path).c_str();
- return ::access(fullPath, F_OK);
+ const std::string fullPath = StringPrintf("/data/local/tmp/user/0/%s", path);
+ return ::access(fullPath.c_str(), F_OK);
}
static int64_t size(const char* path) {
- const char* fullPath = StringPrintf("/data/local/tmp/user/0/%s", path).c_str();
+ const std::string fullPath = StringPrintf("/data/local/tmp/user/0/%s", path);
struct stat buf;
- if (!stat(fullPath, &buf)) {
+ if (!stat(fullPath.c_str(), &buf)) {
return buf.st_size;
} else {
return -1;
@@ -107,8 +107,8 @@ static int64_t free() {
}
static void setxattr(const char* path, const char* key) {
- const char* fullPath = StringPrintf("/data/local/tmp/user/0/%s", path).c_str();
- ::setxattr(fullPath, key, "", 0, 0);
+ const std::string fullPath = StringPrintf("/data/local/tmp/user/0/%s", path);
+ ::setxattr(fullPath.c_str(), key, "", 0, 0);
}
class CacheTest : public testing::Test {