Pass adjusted file path to backend
[platform/core/appfw/pkgmgr-server.git] / src / util.c
index d64ccb7..97799ac 100644 (file)
@@ -22,24 +22,12 @@ struct manifest_and_type type_map[] = {
 
 static const char legacy_content_path[] = "/opt/usr/media";
 
-const char *_get_pkgtype_from_file(const char *org_file_path, uid_t caller_uid)
+const char *_get_pkgtype_from_file(const char *file_path)
 {
        const char *type = NULL;
-       const char *file_path = NULL;
        unzFile uf;
        int i;
 
-       if (caller_uid >= REGULAR_USER &&
-               strstr(org_file_path, legacy_content_path) == org_file_path) {
-               DBG("legacy media path!");
-               tzplatform_set_user(caller_uid);
-               file_path = tzplatform_mkpath(TZ_USER_CONTENT,
-                       org_file_path + strlen(legacy_content_path));
-               tzplatform_reset_user();
-       } else {
-               file_path = org_file_path;
-       }
-
        uf = unzOpen(file_path);
        if (uf == NULL) {
                ERR("failed to open zip file %s", file_path);
@@ -83,3 +71,21 @@ char *_get_pkgtype_from_pkgid(const char *pkgid, uid_t uid)
 
        return type;
 }
+
+const char *_get_adjusted_pkgpath(const char *org_file_path, uid_t caller_uid)
+{
+       const char *file_path;
+
+       if (caller_uid >= REGULAR_USER &&
+               strstr(org_file_path, legacy_content_path) == org_file_path) {
+               DBG("legacy media path!");
+               tzplatform_set_user(caller_uid);
+               file_path = tzplatform_mkpath(TZ_USER_CONTENT,
+                       org_file_path + strlen(legacy_content_path));
+               tzplatform_reset_user();
+       } else {
+               file_path = org_file_path;
+       }
+
+       return file_path;
+}