Mercurial > molko
changeset 540:876eee0eb0ad
core: doxygenize sys
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 05 Mar 2023 12:50:11 +0100 |
parents | 7fb5a859bcb4 |
children | 970cad994a95 |
files | doc/Doxyfile libmlk-core/mlk/core/sys.c libmlk-core/mlk/core/sys.h |
diffstat | 3 files changed, 42 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/Doxyfile Sun Mar 05 12:33:01 2023 +0100 +++ b/doc/Doxyfile Sun Mar 05 12:50:11 2023 +0100 @@ -8,8 +8,6 @@ TAB_SIZE = 8 OPTIMIZE_OUTPUT_FOR_C = YES -MARKDOWN_SUPPORT = YES -AUTOLINK_SUPPORT = YES MAX_INITIALIZER_LINES = 0 HIDE_UNDOC_MEMBERS = YES
--- a/libmlk-core/mlk/core/sys.c Sun Mar 05 12:33:01 2023 +0100 +++ b/libmlk-core/mlk/core/sys.c Sun Mar 05 12:50:11 2023 +0100 @@ -80,7 +80,7 @@ /* Kept for future use. */ (void)kind; - static char path[MLK_PATH_MAX]; + static _Thread_local char path[MLK_PATH_MAX]; char *pref; if ((pref = SDL_GetPrefPath(info.organization, info.name))) { @@ -98,7 +98,7 @@ #ifdef _WIN32 /* TODO: add error using the convenient FormatMessage function. */ if (!CreateDirectoryA(path, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) - return errorf("unable to create directory: %s", path); + return MLK_ERR_ERRNO; #else if (mkdir(path, 0755) < 0 && errno != EEXIST) return MLK_ERR_ERRNO;
--- a/libmlk-core/mlk/core/sys.h Sun Mar 05 12:33:01 2023 +0100 +++ b/libmlk-core/mlk/core/sys.h Sun Mar 05 12:50:11 2023 +0100 @@ -19,9 +19,21 @@ #ifndef MLK_CORE_SYS_H #define MLK_CORE_SYS_H +/** + * \file mlk/core/sys.h + * \brief System routines + */ + #include <stdarg.h> +/** + * \enum mlk_sys_dir + * \brief Special directory constants + */ enum mlk_sys_dir { + /** + * Path to the preferred save directory. + */ MLK_SYS_DIR_SAVE }; @@ -29,15 +41,40 @@ extern "C" { #endif +/** + * Initialize system, takes same arguments as ::mlk_core_init. + * + * \note This function is already called by ::mlk_core_init and usually not + * required by the user. + */ int -mlk_sys_init(const char *, const char *); +mlk_sys_init(const char *organization, const char *name); +/** + * Obtain a path for the given special directory. + * + * \param directory directory type + * \return a path to a thread-local static array + */ const char * -mlk_sys_dir(enum mlk_sys_dir); +mlk_sys_dir(enum mlk_sys_dir directory); +/** + * Try to create a directory recursively specified by the path. + * + * \pre path != NULL + * \param path the path to the directory + * \return 0 on success or an error code on failure + */ int -mlk_sys_mkdir(const char *); +mlk_sys_mkdir(const char *path); +/** + * Cleanup system resources. + * + * \note This function is already called by ::mlk_core_finish and usually not + * required by the user. + */ void mlk_sys_finish(void);