Add ms_user_get_root_length 22/307222/3
authorminje.ahn <minje.ahn@samsung.com>
Wed, 6 Mar 2024 06:18:20 +0000 (15:18 +0900)
committerminje.ahn <minje.ahn@samsung.com>
Wed, 6 Mar 2024 06:29:10 +0000 (15:29 +0900)
Change-Id: Ia5a8fb9278d8d5d346e5f7999579e1c77dd0b7db
Signed-off-by: minje.ahn <minje.ahn@samsung.com>
lib/include/media-util-user.h
lib/media-util-user.c

index dd18d09..6532eb4 100644 (file)
@@ -20,6 +20,8 @@
 #ifndef _MEDIA_UTIL_USER_H_
 #define _MEDIA_UTIL_USER_H_
 
+#include <stddef.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -35,6 +37,7 @@ int ms_user_get_wordbook_db_path(uid_t uid, char **path);
 int ms_user_get_mediashared_path(uid_t uid, char **path);
 #endif
 
+size_t ms_user_get_root_length(const char *path, uid_t uid);
 char *ms_user_get_ipc_path(ms_msg_port_type_e type);
 
 #ifdef __cplusplus
index fb486cd..071bdc4 100644 (file)
@@ -187,4 +187,19 @@ char *ms_user_get_ipc_path(ms_msg_port_type_e type)
                return NULL;
 
        return g_strdup(tzplatform_mkpath(TZ_SYS_RUN, MEDIA_IPC_PATH[type]));
+}
+
+size_t ms_user_get_root_length(const char *path, uid_t uid)
+{
+       g_autofree gchar *internal = NULL;
+
+       if (!path || strlen(path) == 0)
+               return 0;
+
+       if (g_str_has_prefix(path, tzplatform_getenv(TZ_SYS_STORAGE)))
+               return strlen(tzplatform_getenv(TZ_SYS_STORAGE)) + 1;
+
+       ms_user_get_internal_root_path(uid, &internal);
+
+       return strlen(internal);
 }
\ No newline at end of file