#include "media-util.h"
#include "media-common-types.h"
-int ms_strappend(char *res, const int size, const char *pattern, const char *str1, const char *str2);
bool ms_config_get_int(const char *key, int *value);
bool ms_config_set_int(const char *key, int value);
bool ms_config_get_str(const char *key, char **value);
#include "media-common-system.h"
#include "media-common-utils.h"
-int ms_strappend(char *res, const int size, const char *pattern, const char *str1, const char *str2)
-{
- int len = 0;
- int real_size = size - 1;
-
- if (!res || !pattern || !str1 || !str2)
- return MS_MEDIA_ERR_INVALID_PARAMETER;
-
- if (real_size < (int)(strlen(str1) + strlen(str2)))
- return MS_MEDIA_ERR_INVALID_PARAMETER;
-
- len = snprintf(res, real_size, pattern, str1, str2);
- if (len < 0)
- return MS_MEDIA_ERR_INVALID_PARAMETER;
-
- res[len] = '\0';
-
- return MS_MEDIA_ERR_NONE;
-}
-
bool ms_config_get_int(const char *key, int *value)
{
int err;
if (strcmp(name, RECYCLE_DIR_NAME) == 0)
continue;
- if (ms_strappend(path, sizeof(path), "%s/%s", current_path, name) != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_strappend failed");
+ if (g_snprintf(path, MS_FILE_PATH_LEN_MAX, "%s/%s", current_path, name) >= MS_FILE_PATH_LEN_MAX) {
+ MS_DBG_ERR("g_snprintf failed");
continue;
}
if (strcmp(name, RECYCLE_DIR_NAME) == 0)
continue;
- if (ms_strappend(path, sizeof(path), "%s/%s", current_path, name) != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_strappend failed");
+ if (g_snprintf(path, MS_FILE_PATH_LEN_MAX, "%s/%s", current_path, name) >= MS_FILE_PATH_LEN_MAX) {
+ MS_DBG_ERR("g_snprintf failed");
continue;
}
if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
- if (!ms_check_support_media_type(path)) {
+ if (!ms_check_support_media_type(path))
continue;
- }
ret = scan_function(handle, storage_id, path, uid);
if (ret != MS_MEDIA_ERR_NONE) {