From 8198a2db778d1805a7d30b6e72d46642d73df681 Mon Sep 17 00:00:00 2001 From: Allanis Date: Sat, 12 Oct 2013 18:33:55 +0100 Subject: [PATCH] [Add] Documentation for lfile.c --- dat/faction.xml | 2 +- src/lfile.c | 45 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/dat/faction.xml b/dat/faction.xml index 49aa5a3..3c515c8 100644 --- a/dat/faction.xml +++ b/dat/faction.xml @@ -29,7 +29,7 @@ - Gallactic Pirates + Galactic Pirates -20 Empire diff --git a/src/lfile.c b/src/lfile.c index 4ab40c1..a7247ab 100644 --- a/src/lfile.c +++ b/src/lfile.c @@ -1,3 +1,9 @@ +/** + * @file lfile.c + * + * @brief Handle read/write abstractions to the users directory. + */ + #include #include #ifdef LINUX @@ -14,8 +20,13 @@ #include "log.h" #include "lfile.h" -/* Return lephisto's base path. */ -static char lephisto_base[128] = "\0"; +/** + * @fn char* lfile_basePath(void) + * + * @brief Get Lephisto's base path (for saves etc..). + * @return The base path to Lephisto. + */ +static char lephisto_base[128] = "\0"; /**< Store Lephisto's base path. */ char* lfile_basePath(void) { char* home; @@ -31,8 +42,15 @@ char* lfile_basePath(void) { return lephisto_base; } -/* Check if a directory exists, and create it if it doesn't. */ -/* Based on lephisto_base. */ +/** + * @fn int lfile_dirMakeExist(const char* path) + * + * @brief Create a directory if it doesn't exist. + * + * Uses relative path to basePath. + * @param path Path to create directory if it doesn't exist. + * @return 0 on success. + */ int lfile_dirMakeExist(const char* path) { char file[PATH_MAX]; @@ -58,7 +76,13 @@ int lfile_dirMakeExist(const char* path) { return 0; } -/* Check if a file exists. */ +/** + * @fn int lfile_fileExists(const char* path, ...) + * + * @brief Check to see if a file exists. + * @param path printf formatted string pointing to the file to check for existance. + * @return 1 if file exists, 0 if it doesn't or -1 on error. + */ int lfile_fileExists(const char* path, ...) { char file[PATH_MAX], name[PATH_MAX]; va_list ap; @@ -85,7 +109,16 @@ int lfile_fileExists(const char* path, ...) { return 0; } -/* List all the files in a dir (besides . and ..). */ +/** + * @fn char** lfile_readDir(int* lfiles, const char* path) + * + * @brief Lists all the visible files in a directory. + * + * Should also sort by last modified but thats up to the OS in question. + * Paths are relative to base directory. + * @param[out] lfiles Returns how many files there are. + * @param path Directory to read. + */ char** lfile_readDir(int* lfiles, const char* path) { char file[PATH_MAX]; char** files;