libsysutils

diff include/datapath.h @ 0:a8277d8f687a

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 19 Feb 2015 01:33:54 +0200
parents
children c1323f9f202d
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/include/datapath.h	Thu Feb 19 01:33:54 2015 +0200
     1.3 @@ -0,0 +1,32 @@
     1.4 +#ifndef LIBSYSUTILS_DATAPATH_H_
     1.5 +#define LIBSYSUTILS_DATAPATH_H_
     1.6 +
     1.7 +enum sysu_dir_type {
     1.8 +	SYSU_DATA_DIR,		/* read-only assets directory */
     1.9 +	SYSU_STORAGE_DIR,	/* read-write persistent storage directory */
    1.10 +	SYSU_CONFIG_DIR,	/* configuration directory */
    1.11 +	SYSU_TMP_DIR,		/* temporary data directory */
    1.12 +	SYSU_HOME_DIR,		/* user's home directory */
    1.13 +	SYSU_CURRENT_DIR	/* current working directory */
    1.14 +};
    1.15 +
    1.16 +const char *sysu_get_directory(sysu_dir_type type);
    1.17 +
    1.18 +/* Writes the path to outpath, and returns the size of the path in bytes.
    1.19 + * Call with len <= 0 and outpath == NULL to return required storage
    1.20 + * size for the path.
    1.21 + */
    1.22 +int sysu_datapath(const char *inpath, char *outpath, int len);
    1.23 +
    1.24 +/* same as above, but stores the path to an internal static buffer,
    1.25 + * which will be overwritten or moved at the next call (thread unsafe).
    1.26 + */
    1.27 +const char *sysu_datapath_static(const char *inpath);
    1.28 +
    1.29 +/* same as above, but allocates storage for the returned path
    1.30 + * which must be freed by a call to sysu_free_datapath.
    1.31 + */
    1.32 +char *sysu_datapath_alloc(const char *inpath);
    1.33 +void sysu_free_datapath(char *p);
    1.34 +
    1.35 +#endif	/* LIBSYSUTILS_DATAPATH_H_ */