diff --git a/playlist.c b/playlist.c index 72d3919b27..ab5e582ce3 100644 --- a/playlist.c +++ b/playlist.c @@ -136,33 +136,33 @@ void playlist_set_cached_external(playlist_t* pl) /* Convenience function: copies specified playlist * path to specified playlist configuration object */ -void playlist_config_set_path(playlist_config_t *config, const char *path) +size_t playlist_config_set_path(playlist_config_t *config, const char *path) { - if (!config) - return; - - if (!string_is_empty(path)) - strlcpy(config->path, path, sizeof(config->path)); - else + if (config) + { + if (!string_is_empty(path)) + return strlcpy(config->path, path, sizeof(config->path)); config->path[0] = '\0'; + } + return 0; } /* Convenience function: copies base content directory * path to specified playlist configuration object. * Also sets autofix_paths boolean, depending on base * content directory value */ -void playlist_config_set_base_content_directory( +size_t playlist_config_set_base_content_directory( playlist_config_t* config, const char* path) { - if (!config) - return; - - config->autofix_paths = !string_is_empty(path); - if (config->autofix_paths) - strlcpy(config->base_content_directory, path, - sizeof(config->base_content_directory)); - else + if (config) + { + config->autofix_paths = !string_is_empty(path); + if (config->autofix_paths) + return strlcpy(config->base_content_directory, path, + sizeof(config->base_content_directory)); config->base_content_directory[0] = '\0'; + } + return 0; } diff --git a/playlist.h b/playlist.h index ac7a62840e..6d67a7db02 100644 --- a/playlist.h +++ b/playlist.h @@ -158,11 +158,11 @@ typedef struct /* Convenience function: copies specified playlist * path to specified playlist configuration object */ -void playlist_config_set_path(playlist_config_t *config, const char *path); +size_t playlist_config_set_path(playlist_config_t *config, const char *path); /* Convenience function: copies base content directory * path to specified playlist configuration object */ -void playlist_config_set_base_content_directory(playlist_config_t* config, const char* path); +size_t playlist_config_set_base_content_directory(playlist_config_t* config, const char* path); /* Creates a copy of the specified playlist configuration. * Returns false in the event of an error */ diff --git a/runtime_file.c b/runtime_file.c index 5055bfa4a6..2b4c794c27 100644 --- a/runtime_file.c +++ b/runtime_file.c @@ -487,29 +487,19 @@ static void runtime_log_get_runtime_hms(runtime_log_t *runtime_log, } /* Gets runtime as a pre-formatted string */ -void runtime_log_get_runtime_str(runtime_log_t *runtime_log, +size_t runtime_log_get_runtime_str(runtime_log_t *runtime_log, char *s, size_t len) { size_t _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME), len); - s[_len ] = ' '; if (runtime_log) - snprintf(s + _len + 1, len - _len - 1, "%02u:%02u:%02u", + _len += snprintf(s + _len, len - _len, " %02u:%02u:%02u", runtime_log->runtime.hours, runtime_log->runtime.minutes, runtime_log->runtime.seconds); else - { - s[_len+1] = '0'; - s[_len+2] = '0'; - s[_len+3] = ':'; - s[_len+4] = '0'; - s[_len+5] = '0'; - s[_len+6] = ':'; - s[_len+7] = '0'; - s[_len+8] = '0'; - s[_len+9] = '\0'; - } + _len += strlcpy(s + _len, " 00:00:00", len - _len); + return _len; } /* Gets last played entry values */ diff --git a/runtime_file.h b/runtime_file.h index 2084f367b5..e485e686e0 100644 --- a/runtime_file.h +++ b/runtime_file.h @@ -96,7 +96,7 @@ void runtime_log_reset(runtime_log_t *runtime_log); * cleaner to have a symmetrical set/get interface) */ /* Gets runtime as a pre-formatted string */ -void runtime_log_get_runtime_str(runtime_log_t *runtime_log, char *str, size_t len); +size_t runtime_log_get_runtime_str(runtime_log_t *runtime_log, char *s, size_t len); /* Gets last played entry values */ void runtime_log_get_last_played(runtime_log_t *runtime_log,