-API int pkgmgrinfo_pkginfo_get_total_size(pkgmgrinfo_pkginfo_h handle, int *size)
-{
- char *pkgid;
- char device_path[PKG_STRING_LEN_MAX] = { '\0', };
- long long rw_size = 0;
- long long ro_size = 0;
- long long tmp_size = 0;
- long long total_size = 0;
- struct stat fileinfo;
- int ret;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- ret = pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
- if (ret < 0)
- return PMINFO_R_ERROR;
-
- /* RW area */
- snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RW_PATH, pkgid);
- if (lstat(device_path, &fileinfo) == 0) {
- if (!S_ISLNK(fileinfo.st_mode)) {
- tmp_size = _pkgmgr_calculate_dir_size(device_path);
- if (tmp_size > 0)
- rw_size += tmp_size;
- }
- }
-
- snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RW_PATH, pkgid);
- if (lstat(device_path, &fileinfo) == 0) {
- if (!S_ISLNK(fileinfo.st_mode)) {
- tmp_size = _pkgmgr_calculate_dir_size(device_path);
- if (tmp_size > 0)
- rw_size += tmp_size;
- }
- }
-
- snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RW_PATH, pkgid);
- if (lstat(device_path, &fileinfo) == 0) {
- if (!S_ISLNK(fileinfo.st_mode)) {
- tmp_size = _pkgmgr_calculate_dir_size(device_path);
- if (tmp_size > 0)
- rw_size += tmp_size;
- }
- }
-
- snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
- if (lstat(device_path, &fileinfo) == 0) {
- if (!S_ISLNK(fileinfo.st_mode)) {
- tmp_size = _pkgmgr_calculate_dir_size(device_path);
- if (tmp_size > 0)
- rw_size += tmp_size;
- }
- }
-
- snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RW_PATH, pkgid);
- if (lstat(device_path, &fileinfo) == 0) {
- if (!S_ISLNK(fileinfo.st_mode)) {
- tmp_size = _pkgmgr_calculate_dir_size(device_path);
- if (tmp_size > 0)
- rw_size += tmp_size;
- }
- }
-
- snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RW_PATH, pkgid);
- if (lstat(device_path, &fileinfo) == 0) {
- if (!S_ISLNK(fileinfo.st_mode)) {
- tmp_size = _pkgmgr_calculate_dir_size(device_path);
- if (tmp_size > 0)
- rw_size += tmp_size;
- }
- }
-
- /* RO area */
- snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/bin", PKG_RO_PATH, pkgid);
- if (lstat(device_path, &fileinfo) == 0) {
- if (!S_ISLNK(fileinfo.st_mode)) {
- tmp_size = _pkgmgr_calculate_dir_size(device_path);
- if (tmp_size > 0)
- ro_size += tmp_size;
- }
- }
-
- snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/info", PKG_RO_PATH, pkgid);
- if (lstat(device_path, &fileinfo) == 0) {
- if (!S_ISLNK(fileinfo.st_mode)) {
- tmp_size = _pkgmgr_calculate_dir_size(device_path);
- if (tmp_size > 0)
- ro_size += tmp_size;
- }
- }
-
- snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/res", PKG_RO_PATH, pkgid);
- if (lstat(device_path, &fileinfo) == 0) {
- if (!S_ISLNK(fileinfo.st_mode)) {
- tmp_size = _pkgmgr_calculate_dir_size(device_path);
- if (tmp_size > 0)
- ro_size += tmp_size;
- }
- }
-
- snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RO_PATH, pkgid);
- if (lstat(device_path, &fileinfo) == 0) {
- if (!S_ISLNK(fileinfo.st_mode)) {
- tmp_size = _pkgmgr_calculate_dir_size(device_path);
- if (tmp_size > 0)
- ro_size += tmp_size;
- }
- }
-
- snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/shared", PKG_RO_PATH, pkgid);
- if (lstat(device_path, &fileinfo) == 0) {
- if (!S_ISLNK(fileinfo.st_mode)) {
- tmp_size = _pkgmgr_calculate_dir_size(device_path);
- if (tmp_size > 0)
- ro_size += tmp_size;
- }
- }
-
- snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/setting", PKG_RO_PATH, pkgid);
- if (lstat(device_path, &fileinfo) == 0) {
- if (!S_ISLNK(fileinfo.st_mode)) {
- tmp_size = _pkgmgr_calculate_dir_size(device_path);
- if (tmp_size > 0)
- ro_size += tmp_size;
- }
- }
-
- /* Total size */
- total_size = rw_size + ro_size;
- *size = (int)total_size;
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_data_size(pkgmgrinfo_pkginfo_h handle, int *size)
-{
- char *pkgid;
- char device_path[PKG_STRING_LEN_MAX] = { '\0', };
- long long total_size = 0;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid) < 0)
- return PMINFO_R_ERROR;
-
- snprintf(device_path, PKG_STRING_LEN_MAX, "%s%s/data", PKG_RW_PATH, pkgid);
- if (access(device_path, R_OK) == 0)
- total_size = _pkgmgr_calculate_dir_size(device_path);
- if (total_size < 0)
- return PMINFO_R_ERROR;
-
- *size = (int)total_size;
-
- return PMINFO_R_OK;
-}
-