mirror of
https://gitee.com/openharmony/startup_appspawn
synced 2024-11-27 01:00:38 +00:00
目录判断
Signed-off-by: 王达 <wangda20@huawei.com>
This commit is contained in:
parent
749b14fe16
commit
f18162f90e
@ -184,11 +184,14 @@ int HnpDeleteFolder(const char *path)
|
||||
#ifdef _WIN32
|
||||
return ret;
|
||||
#else
|
||||
DIR *dir = opendir(path);
|
||||
struct dirent *entry;
|
||||
struct stat statbuf;
|
||||
char filePath[MAX_FILE_PATH_LEN];
|
||||
|
||||
if (access(path, F_OK) != 0) {
|
||||
return 0;
|
||||
}
|
||||
DIR *dir = opendir(path);
|
||||
if (dir == NULL) {
|
||||
HNP_LOGE("delete folder open dir=%s unsuccess ", path);
|
||||
return HNP_ERRNO_BASE_DIR_OPEN_FAILED;
|
||||
|
@ -418,6 +418,9 @@ int HnpPackageInfoGet(const char *packageName, HnpPackageInfo **packageInfoOut,
|
||||
|
||||
int ret = ReadFileToStream(HNP_PACKAGE_INFO_JSON_FILE_PATH, &infoStream, &size);
|
||||
if (ret != 0) {
|
||||
if (ret == HNP_ERRNO_BASE_FILE_OPEN_FAILED || ret == HNP_ERRNO_BASE_GET_FILE_LEN_NULL) {
|
||||
return 0;
|
||||
}
|
||||
HNP_LOGE("package info get read hnp info file unsuccess");
|
||||
return HNP_ERRNO_BASE_READ_FILE_STREAM_FAILED;
|
||||
}
|
||||
@ -519,6 +522,9 @@ int HnpPackageInfoDelete(const char *packageName)
|
||||
|
||||
int ret = ReadFileToStream(HNP_PACKAGE_INFO_JSON_FILE_PATH, &infoStream, &size);
|
||||
if (ret != 0) {
|
||||
if (ret == HNP_ERRNO_BASE_FILE_OPEN_FAILED || ret == HNP_ERRNO_BASE_GET_FILE_LEN_NULL) {
|
||||
return 0;
|
||||
}
|
||||
HNP_LOGE("package info delete read hnp info file unsuccess");
|
||||
return HNP_ERRNO_BASE_READ_FILE_STREAM_FAILED;
|
||||
}
|
||||
|
@ -221,6 +221,19 @@ static int HnpUnInstall(int uid, const char *packageName)
|
||||
HnpPackageInfo *packageInfo = NULL;
|
||||
int count = 0;
|
||||
char privatePath[MAX_FILE_PATH_LEN];
|
||||
char dstPath[MAX_FILE_PATH_LEN];
|
||||
|
||||
/* 拼接卸载路径 */
|
||||
if (sprintf_s(dstPath, MAX_FILE_PATH_LEN, HNP_DEFAULT_INSTALL_ROOT_PATH"/%d", uid) < 0) {
|
||||
HNP_LOGE("hnp install sprintf unsuccess, uid:%d", uid);
|
||||
return HNP_ERRNO_BASE_SPRINTF_FAILED;
|
||||
}
|
||||
|
||||
/* 验证卸载路径是否存在 */
|
||||
if (access(dstPath, F_OK) != 0) {
|
||||
HNP_LOGE("hnp uninstall uid path[%s] is not exist", dstPath);
|
||||
return HNP_ERRNO_UNINSTALLER_HNP_PATH_NOT_EXIST;
|
||||
}
|
||||
|
||||
int ret = HnpPackageInfoGet(packageName, &packageInfo, &count);
|
||||
if (ret != 0) {
|
||||
@ -250,9 +263,8 @@ static int HnpUnInstall(int uid, const char *packageName)
|
||||
return HNP_ERRNO_BASE_SPRINTF_FAILED;
|
||||
}
|
||||
|
||||
if (access(privatePath, F_OK) == 0) {
|
||||
(void)HnpDeleteFolder(privatePath);
|
||||
}
|
||||
(void)HnpDeleteFolder(privatePath);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user