eina: enhance doxygen in eina_file.h

Summary:
Arrange grouping
Add @brief for brief description
Add @details for detailed description
Add @note for noted description
Add [in] & [out] for parameters
Add @see more
Add links for EINA_TRUE, EINA_FALSE, etc.
Fix indentation & Fix typeof
Use @p instead of @a for the consistency

Reviewers: raster, cedric

Reviewed By: cedric

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D1611

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
Tae-Hwan Kim 2014-10-30 08:49:01 +01:00 committed by Cedric BAIL
parent 4c9995f4ee
commit 24ee38f3c1
1 changed files with 243 additions and 243 deletions

View File

@ -33,7 +33,7 @@
* @page eina_file_example_01_page * @page eina_file_example_01_page
* @dontinclude eina_file_01.c * @dontinclude eina_file_01.c
* *
* For brevity includes, variable declarations and initialization was omitted * To include brevity, variable declarations and initialization is omitted
* from this page, however the full source code can be seen @ref * from this page, however the full source code can be seen @ref
* eina_file_example_01 "here". * eina_file_example_01 "here".
* *
@ -45,7 +45,7 @@
* We can use this callback in the following call: * We can use this callback in the following call:
* @skipline eina_file_dir_list * @skipline eina_file_dir_list
* *
* The above was a way to print the files in a directory, but it is not the only * The above is a way to print the files in a directory, but it is not the only
* one: * one:
* @until iterator_free * @until iterator_free
* *
@ -53,32 +53,28 @@
* @until iterator_free * @until iterator_free
* @until iterator_free * @until iterator_free
* *
* The above ways of getting files on a list may produce the same output, but * The above mentioned ways of getting files on a list may produce the same output, but
* they have an important difference, eina_file_direct_ls() will @b not call * they have an important difference, eina_file_direct_ls() does @b not call
* stat, this means that on some systems it might not have file type * stat, this means that on some systems it might not have file type
* information. On the other hand it might be faster than eina_file_stat_ls(). * information. On the other hand, it might be faster than eina_file_stat_ls().
*/ *
/**
* @page eina_file_example_01 * @page eina_file_example_01
* @include eina_file_01.c * @include eina_file_01.c
* @example eina_file_01.c * @example eina_file_01.c
*/ */
/** /**
* @addtogroup Eina_Tools_Group Tools * @defgroup Eina_File_Group File
* @ingroup Eina_Tools_Group
* *
* @{ * @brief This group discusses the functions to handle files and directories.
*/
/**
* @addtogroup Eina_File_Group File
* *
* @brief Functions to handle files and directories. * @details These functions make it easier to do a number of file and directory operations
* such as getting the list of files in a directory, spliting paths, and finding
* out file size and type.
* *
* This functions make it easier to do a number o file and directory operations * @warning All functions in this group are @b blocking, which means they may
* such as getting the list of files in a directory, spliting paths and finding * take a long time to return, use them carefully.
* out file size and type.
*
* @warning All functions in this group are @b blocking which means they make
* take a long time to return, use them carefully.
* *
* See an example @ref eina_file_example_01_page "here". * See an example @ref eina_file_example_01_page "here".
* *
@ -87,27 +83,27 @@
/** /**
* @typedef Eina_File_Direct_Info * @typedef Eina_File_Direct_Info
* A typedef to #_Eina_File_Direct_Info. * @brief A type for #_Eina_File_Direct_Info.
*/ */
typedef struct _Eina_File_Direct_Info Eina_File_Direct_Info; typedef struct _Eina_File_Direct_Info Eina_File_Direct_Info;
/** /**
* @typedef Eina_Stat * @typedef Eina_Stat
* A typedef to #_Eina_Stat. * @brief A type for #_Eina_Stat.
* @since 1.2 * @since 1.2
*/ */
typedef struct _Eina_Stat Eina_Stat; typedef struct _Eina_Stat Eina_Stat;
/** /**
* @typedef Eina_File_Line * @typedef Eina_File_Line
* A typedef to #_Eina_File_Line. * @brief A type for #_Eina_File_Line.
*/ */
typedef struct _Eina_File_Line Eina_File_Line; typedef struct _Eina_File_Line Eina_File_Line;
/** /**
* @typedef Eina_File_Dir_List_Cb * @typedef Eina_File_Dir_List_Cb
* Type for a callback to be called when iterating over the files of a * @brief Type for a callback to be called when iterating over the files of a
* directory. * directory.
* @param name The file name EXCLUDING the path * @param name The file name EXCLUDING the path
* @param path The path passed to eina_file_dir_list() * @param path The path passed to eina_file_dir_list()
* @param data The data passed to eina_file_dir_list() * @param data The data passed to eina_file_dir_list()
@ -116,35 +112,37 @@ typedef void (*Eina_File_Dir_List_Cb)(const char *name, const char *path, void *
/** /**
* @typedef Eina_File_Type * @typedef Eina_File_Type
* file type in Eina_File_Direct_Info. * @brief Type for enumeration of a file type.
* @details This type is used in #Eina_File_Direct_Info.
*/ */
typedef enum { typedef enum {
EINA_FILE_UNKNOWN, /**< Unknown file type. */ EINA_FILE_UNKNOWN, /**< Unknown file type */
EINA_FILE_FIFO, /**< Named pipe (FIFO) type (unused on Windows). */ EINA_FILE_FIFO, /**< Named pipe (FIFO) type (unused on Windows) */
EINA_FILE_CHR, /**< Character device type (unused on Windows). */ EINA_FILE_CHR, /**< Character device type (unused on Windows) */
EINA_FILE_DIR, /**< Directory type. */ EINA_FILE_DIR, /**< Directory type */
EINA_FILE_BLK, /**< Block device type (unused on Windows). */ EINA_FILE_BLK, /**< Block device type (unused on Windows) */
EINA_FILE_REG, /**< Regular file type. */ EINA_FILE_REG, /**< Regular file type */
EINA_FILE_LNK, /**< Symbolic link type. */ EINA_FILE_LNK, /**< Symbolic link type */
EINA_FILE_SOCK, /**< UNIX domain socket type (unused on Windows). */ EINA_FILE_SOCK, /**< UNIX domain socket type (unused on Windows) */
EINA_FILE_WHT /**< Whiteout file type (unused on Windows). */ EINA_FILE_WHT /**< Whiteout file type (unused on Windows) */
} Eina_File_Type; } Eina_File_Type;
/** /**
* @typedef Eina_File * @typedef Eina_File
* A file handle. * @brief A file handle.
*/ */
typedef struct _Eina_File Eina_File; typedef struct _Eina_File Eina_File;
/** /**
* @typedef Eina_File_Populate * @typedef Eina_File_Populate
* File access type used in Eina_File_Direct_info. * @brief Type for enumeration of a file access type.
* @details This type is used in #Eina_File_Direct_Info.
*/ */
typedef enum { typedef enum {
EINA_FILE_RANDOM, /**< Advise random memory access to the mapped memory. */ EINA_FILE_RANDOM, /**< Advise random memory access to the mapped memory */
EINA_FILE_SEQUENTIAL, /**< Advise sequential memory access to the mapped memory. */ EINA_FILE_SEQUENTIAL, /**< Advise sequential memory access to the mapped memory */
EINA_FILE_WILLNEED, /**< Advise need for all the mapped memory. */ EINA_FILE_WILLNEED, /**< Advise need for all the mapped memory */
EINA_FILE_POPULATE, /**< Request all the mapped memory. */ EINA_FILE_POPULATE, /**< Request for all the mapped memory */
EINA_FILE_DONTNEED, /**< Indicate that the memory is no longer needed. This may result in the memory being removed from any caches if applicable. @since 1.8 */ EINA_FILE_DONTNEED, /**< Indicate that the memory is no longer needed. This may result in the memory being removed from any caches if applicable. @since 1.8 */
EINA_FILE_REMOVE /**< This memory is to be released and any content will be lost. Subsequent accesses will succeed but return fresh memory as if accessed for the first time. This may not suceed if the filesystem does not support it. @since 1.8 */ EINA_FILE_REMOVE /**< This memory is to be released and any content will be lost. Subsequent accesses will succeed but return fresh memory as if accessed for the first time. This may not suceed if the filesystem does not support it. @since 1.8 */
} Eina_File_Populate; } Eina_File_Populate;
@ -152,11 +150,11 @@ typedef enum {
/* Why do this? Well PATH_MAX may vary from when eina itself is compiled /* Why do this? Well PATH_MAX may vary from when eina itself is compiled
* to when the app using eina is compiled. Exposing the path buffer below * to when the app using eina is compiled. Exposing the path buffer below
* can't safely and portably vary based on how/when you compile. It should * can't safely and portably vary based on how/when you compile. It should
* always be the same for both eina inside AND for apps outside that use eina * always be the same for both eina inside AND for apps outside that use eina,
* so define this to 8192 - most PATH_MAX values are like 4096 or 1024 (with * so define this to 8192 - most PATH_MAX values are like 4096 or 1024 (with
* windows i think being 260), so 8192 should cover almost all cases. There * Windows I think being 260), so 8192 should cover almost all the cases. There
* is a possibility that PATH_MAX could be more than 8192. If anyone spots * is a possibility that PATH_MAX could be more than 8192. If anyone spots
* a path_max that is bigger - let us know, but, for now we will assume * a path_max that is bigger - let us know, but, for now we assume that
* it never happens */ * it never happens */
/** /**
* @def EINA_PATH_MAX * @def EINA_PATH_MAX
@ -165,20 +163,20 @@ typedef enum {
#define EINA_PATH_MAX 8192 #define EINA_PATH_MAX 8192
/** /**
* @struct _Eina_File_Direct_Info * @struct _Eina_File_Direct_Info
* A structure to store informations of a path. * @brief The structure to store information of a path.
*/ */
struct _Eina_File_Direct_Info struct _Eina_File_Direct_Info
{ {
size_t path_length; /**< size of the whole path */ size_t path_length; /**< Size of the whole path */
size_t name_length; /**< size of the filename/basename component */ size_t name_length; /**< Size of the filename/basename component */
size_t name_start; /**< where the filename/basename component starts */ size_t name_start; /**< Start position of the filename/basename component */
Eina_File_Type type; /**< file type */ Eina_File_Type type; /**< File type */
char path[EINA_PATH_MAX]; /**< the path */ char path[EINA_PATH_MAX]; /**< The path */
}; };
/** /**
* @struct _Eina_Stat * @struct _Eina_Stat
* A structure to store some file statistics. * @brief The structure to store some file statistics.
* @since 1.2 * @since 1.2
*/ */
struct _Eina_Stat struct _Eina_Stat
@ -203,7 +201,7 @@ struct _Eina_Stat
/** /**
* @struct _Eina_File_Line * @struct _Eina_File_Line
* A structure to store information of line * @brief The structure to store information of a line.
* @since 1.3 * @since 1.3
*/ */
struct _Eina_File_Line struct _Eina_File_Line
@ -216,33 +214,33 @@ struct _Eina_File_Line
/** /**
* @def EINA_FILE_DIR_LIST_CB * @def EINA_FILE_DIR_LIST_CB
* @brief cast to an #Eina_File_Dir_List_Cb. * @brief The macro to cast to an #Eina_File_Dir_List_Cb.
* *
* @param function The function to cast. * @param function The function to cast
* *
* This macro casts @p function to Eina_File_Dir_List_Cb. * @details This macro casts @p function to #Eina_File_Dir_List_Cb.
*/ */
#define EINA_FILE_DIR_LIST_CB(function) ((Eina_File_Dir_List_Cb)function) #define EINA_FILE_DIR_LIST_CB(function) ((Eina_File_Dir_List_Cb)function)
/** /**
* @brief List all files on the directory calling the function for every file found. * @brief Lists all the files on the directory by calling the function for every file found.
* *
* @param dir The directory name. * @param[in] dir The directory name
* @param recursive Iterate recursively in the directory. * @param[in] recursive Iterate recursively in the directory
* @param cb The callback to be called. * @param[in] cb The callback to be called
* @param data The data to pass to the callback. * @param[in] data The data to pass to the callback
* @return #EINA_TRUE on success, #EINA_FALSE otherwise. * @return #EINA_TRUE on success, otherwise #EINA_FALSE
* *
* This function calls @p cb for each file that is in @p dir. To have @p cb * @details This function calls @p cb for each file that is in @p dir. To have @p cb
* called on files that are in subdirectories of @p dir @p recursive should * called on the files that are in subdirectories of @p dir, @p recursive should
* be #EINA_TRUE. In other words if @p recursive is #EINA_FALSE, only direct children * be #EINA_TRUE. In other words, if @p recursive is #EINA_FALSE, only direct children
* of @p dir will be operated on, if @p recursive is #EINA_TRUE the entire tree * of @p dir are operated on, if @p recursive is #EINA_TRUE the entire tree
* of files that is below @p dir will be operated on. * of files that is below @p dir is operated on.
* *
* If @p cb or @p dir are @c NULL, or if @p dir is a string of size 0, * If @p cb or @p dir is @c NULL or if @p dir is a string of size 0,
* or if @p dir can not be opened, this function returns #EINA_FALSE * or if @p dir cannot be opened, this function returns #EINA_FALSE
* immediately. otherwise, it returns #EINA_TRUE. * immediately. Otherwise, it returns #EINA_TRUE.
*/ */
EAPI Eina_Bool eina_file_dir_list(const char *dir, EAPI Eina_Bool eina_file_dir_list(const char *dir,
Eina_Bool recursive, Eina_Bool recursive,
@ -250,62 +248,61 @@ EAPI Eina_Bool eina_file_dir_list(const char *dir,
void *data) EINA_ARG_NONNULL(1, 3); void *data) EINA_ARG_NONNULL(1, 3);
/** /**
* @brief Split a path according to the delimiter of the filesystem. * @brief Splits a path according to the delimiter of the filesystem.
* *
* @param path The path to split. * @param[in] path The path to split
* @return An array of the parts of the path to split. * @return An array of the parts of the path to split
* *
* This function splits @p path according to the delimiter of the used * @details This function splits @p path according to the delimiter of the used
* filesystem. If @p path is @c NULL or if the array can not be * filesystem. If @p path is @c NULL or if the array cannot be
* created, @c NULL is returned, otherwise, an array with each part of @p path * created, @c NULL is returned, otherwise an array with each part of @p path
* is returned. * is returned.
*/ */
EAPI Eina_Array *eina_file_split(char *path) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; EAPI Eina_Array *eina_file_split(char *path) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
/** /**
* @brief Get an iterator to list the content of a directory. * @brief Gets an iterator to list the content of a directory.
* *
* @param dir The name of the directory to list * @param [in] dir The name of the directory to list
* @return Return an Eina_Iterator that will walk over the files and directories * @return An #Eina_Iterator that walks over the files and directories
* in @p dir. On failure it will return @c NULL. * in @p dir. On failure, it returns @c NULL.
* *
* Returns an iterator for shared strings, the name of each file in @p dir will * @details This returns an iterator for shared strings, the name of each file in @p dir is
* only be fetched when advancing the iterator, which means there is very little * only fetched when advancing the iterator, which means there is very little
* cost associated with creating the list and stopping halfway through it. * cost associated with creating the list and stopping halfway through it.
* *
* @warning The iterator will hand the user a stringshared value with the full * @note The iterator hands the user a stringshared value with the full
* path. The user must free the string using eina_stringshare_del() on it. * path. The user must free the string using eina_stringshare_del() on it.
* *
* @note The container for the iterator is of type DIR*. * @note The container for the iterator is of type DIR*.
* @note The iterator will walk over '.' and '..' without returning them. * @note The iterator walks over '.' and '..' without returning them.
* *
* @see eina_file_direct_ls() * @see eina_file_direct_ls()
*/ */
EAPI Eina_Iterator *eina_file_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; EAPI Eina_Iterator *eina_file_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
/** /**
* @brief Get an iterator to list the content of a directory, with direct * @brief Gets an iterator to list the content of a directory, with direct
* information. * information.
* *
* @param dir The name of the directory to list * @param [in] dir The name of the directory to list
* *
* @return Return an Eina_Iterator that will walk over the files and * @return An #Eina_Iterator that walks over the files and
* directory in the pointed directory. On failure it will * directories in @p dir. On failure, it returns @c NULL.
* return NULL.
* *
* Returns an iterator for Eina_File_Direct_Info, the name of each file in @p * @details This returns an iterator for #Eina_File_Direct_Info, the name of each file in @p
* dir will only be fetched when advancing the iterator, which means there is * dir is only fetched when advancing the iterator, which means there is
* cost associated with creating the list and stopping halfway through it. * cost associated with creating the list and stopping halfway through it.
* *
* @warning The Eina_File_Direct_Info returned by the iterator <b>must not</b> * @warning The #Eina_File_Direct_Info returned by the iterator <b>must not</b>
* be modified in any way. * be modified in any way.
* @warning When the iterator is advanced or deleted the Eina_File_Direct_Info * @warning When the iterator is advanced or deleted the #Eina_File_Direct_Info
* returned is no longer valid. * returned is no longer valid.
* *
* @note The container for the iterator is of type DIR*. * @note The container for the iterator is of type DIR*.
* @note The iterator will walk over '.' and '..' without returning them. * @note The iterator walks over '.' and '..' without returning them.
* @note The difference between this function and eina_file_direct_ls() is that * @note The difference between this function and eina_file_direct_ls() is that
* it guarantees the file type information will be correct incurring a * it guarantees the file type information to be correct by incurring a
* possible performance penalty. * possible performance penalty.
* *
* @see eina_file_direct_ls() * @see eina_file_direct_ls()
@ -313,40 +310,42 @@ EAPI Eina_Iterator *eina_file_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_A
EAPI Eina_Iterator *eina_file_stat_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; EAPI Eina_Iterator *eina_file_stat_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
/** /**
* @brief Use information provided by Eina_Iterator of eina_file_stat_ls or eina_file_direct_ls * @brief Uses information provided by #Eina_Iterator of eina_file_stat_ls() or eina_file_direct_ls()
* to call stat in the most efficient way on your system. * to call stat in the most efficient way on your system.
* *
* @param container The container returned by the Eina_Iterator using eina_iterator_container_get(). * @param[in] container The container returned by #Eina_Iterator using eina_iterator_container_get()
* @param info The content of the current Eina_File_Direct_Info provided by the Eina_Iterator * @param[in] info The content of the current #Eina_File_Direct_Info provided by #Eina_Iterator
* @param buf Where to put the result of the stat * @param[in] buf The location put the result of the stat
* @return On success @c 0 is returned, On error @c -1 is returned and errno is set appropriately. * @return @c 0 is returnedon success, otherwise @c -1 is returned on error and errno is set appropriately
* *
* This function calls fstatat or stat depending on what your system supports. This makes it efficient and simple * @details This function calls fstatat or stat depending on what your system supports. This makes it efficient and simple
* to use on your side without complex detection already done inside Eina on what the system can do. * to use on your side without complex detection already done inside Eina on what the system can do.
* *
* @see eina_file_direct_ls() * @see eina_file_direct_ls()
* @see eina_file_stat_ls() * @see eina_file_stat_ls()
*
* @since 1.2 * @since 1.2
*/ */
EAPI int eina_file_statat(void *container, Eina_File_Direct_Info *info, Eina_Stat *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2, 3); EAPI int eina_file_statat(void *container, Eina_File_Direct_Info *info, Eina_Stat *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2, 3);
/** /**
* @brief Generate and create a uniquely named temporary file from template. * @brief Generates and creates a uniquely named temporary file from template.
* Generated file is opened with the open(2) O_EXCL flag. * Generated file is opened with the open(2) O_EXCL flag.
* *
* @param [in] templatename is a string. It must contain the six characters 'XXXXXX' * @param[in] templatename This is a string. It must contain the six characters 'XXXXXX'
* at the end or directly followed by an extension as in 'prefixXXXXXX.ext'. * at the end or directly followed by an extension as in
* @param [out] path Where to put the name of the created file. If not NULL * 'prefixXXXXXX.ext'.
* should be released by eina_tmpstr_del. * @param[out] path Where to put the name of the created file. If not @c NULL
* should be released by eina_tmpstr_del().
* @return On success @c file descriptor of the temporary file is returned, * @return On success @c file descriptor of the temporary file is returned,
* On error @c -1 is returned, in which case errno is set appropriately. * On error @c -1 is returned, in which case @c errno is set appropriately.
* *
* This function calls mkstemp[s], generates a unique temporary filename * @details This function calls mkstemp(), generates a unique temporary filename
* from template, creates and opens the file, and returns an open file * from template, creates and opens the file, and returns an open file
* descriptor for the file. * descriptor for the file.
* *
* If a filename extension was specified in @a templatename, then the new @a path * @note If a filename extension was specified in @p templatename, then the new @p path
* will also contain this extension (since 1.10). * will also contain this extension (since 1.10).
* *
* @see eina_file_mkdtemp() * @see eina_file_mkdtemp()
* @since 1.8 * @since 1.8
@ -354,15 +353,17 @@ EAPI int eina_file_statat(void *container, Eina_File_Direct_Info *info, Eina_Sta
EAPI int eina_file_mkstemp(const char *templatename, Eina_Tmpstr **path); EAPI int eina_file_mkstemp(const char *templatename, Eina_Tmpstr **path);
/** /**
* @brief Generate and create a uniquely named temporary directory from template. * @brief Generates and creates a uniquely named temporary directory from template.
* *
* @param [in] templatename is a string. The last six characters of templatename must be XXXXXX. * @param[in] templatename This is a string. The last six characters of @p templatename
* @param [out] path Where to put the name of the created directory. If not NULL * must be XXXXXX.
* should be released by eina_tmpstr_del. * @param[out] path Where to put the name of the created directory. If not @c NULL
* should be released by eina_tmpstr_del().
* @return On success @c EINA_TRUE is returned, On error @c EINA_FALSE is returned, * @return On success @c EINA_TRUE is returned, On error @c EINA_FALSE is returned,
* in which case errno is set appropriately. * in which case @c errno is set appropriately.
* *
* This function calls mkdtemp. The directory is then created with permissions 0700. * @details This function calls mkdtemp(). The directory is then created with
* permissions 0700.
* *
* @see eina_file_mkstemp() * @see eina_file_mkstemp()
* @since 1.8 * @since 1.8
@ -370,28 +371,27 @@ EAPI int eina_file_mkstemp(const char *templatename, Eina_Tmpstr **path);
EAPI Eina_Bool eina_file_mkdtemp(const char *templatename, Eina_Tmpstr **path); EAPI Eina_Bool eina_file_mkdtemp(const char *templatename, Eina_Tmpstr **path);
/** /**
* @brief Get an iterator to list the content of a directory, with direct * @brief Gets an iterator to list the content of a directory, with direct
* information. * information.
* *
* @param dir The name of the directory to list * @param [in] dir The name of the directory to list
* *
* @return Return an Eina_Iterator that will walk over the files and * @return An Eina_Iterator that walks over the files and
* directory in the pointed directory. On failure it will * directories in @p dir. On failure, it returns @c NULL.
* return @c NULL.
* *
* Returns an iterator for Eina_File_Direct_Info, the name of each file in @p * @details This returns an iterator for #Eina_File_Direct_Info, the name of each file in
* dir will only be fetched when advancing the iterator, which means there is * @p dir is only fetched when advancing the iterator, which means there is
* cost associated with creating the list and stopping halfway through it. * cost associated with creating the list and stopping halfway through it.
* *
* @warning If readdir_r doesn't contain file type information file type will * @warning If readdir_r doesn't contain file type information, file type is
* be DT_UNKNOW. * DT_UNKNOWN.
* @warning The Eina_File_Direct_Info returned by the iterator <b>must not</b> * @warning The #Eina_File_Direct_Info returned by the iterator <b>must not</b>
* be modified in any way. * be modified in any way.
* @warning When the iterator is advanced or deleted the Eina_File_Direct_Info * @warning When the iterator is advanced or deleted the #Eina_File_Direct_Info
* returned is no longer valid. * returned is no longer valid.
* *
* @note The container for the iterator is of type DIR*. * @note The container for the iterator is of type DIR*.
* @note The iterator will walk over '.' and '..' without returning them. * @note The iterator walks over '.' and '..' without returning them.
* @note The difference between this function and eina_file_stat_ls() is that * @note The difference between this function and eina_file_stat_ls() is that
* it may not get the file type information however it is likely to be * it may not get the file type information however it is likely to be
* faster. * faster.
@ -401,33 +401,33 @@ EAPI Eina_Bool eina_file_mkdtemp(const char *templatename, Eina_Tmpstr **path);
EAPI Eina_Iterator *eina_file_direct_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; EAPI Eina_Iterator *eina_file_direct_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
/** /**
* @brief Sanitize file path. * @brief Sanitizes the file path.
* *
* @param path The path to sanitize * @param[in] path The path to sanitize
* *
* @return an allocated string with the sanitized path. * @return An allocated string with the sanitized path
* *
* This function take care of adding the current working directory if it's a * @details This function takes care of adding the current working directory if its a
* relative path and also remove all '..' and '//' reference in the original * relative path and also removes all '..' and '//' references in the original
* path. * path.
* *
* @since 1.1 * @since 1.1
*/ */
EAPI char *eina_file_path_sanitize(const char *path); EAPI char *eina_file_path_sanitize(const char *path);
/** /**
* @typedef Eina_File_Copy_Progress * @typedef Eina_File_Copy_Progress
* used to report progress during eina_file_copy(), where @c done * @brief Type for a callback to report file copy progress.
* is the bytes already copied and @c size is the total file size. * @details This function is used to report progress during eina_file_copy(), where @p done
* is the bytes already copied and @c size is the total file size.
* *
* If returns #EINA_FALSE, it will stop the copy. * @note If it returns #EINA_FALSE, it will stop the copy.
*/ */
typedef Eina_Bool (*Eina_File_Copy_Progress)(void *data, unsigned long long done, unsigned long long total); typedef Eina_Bool (*Eina_File_Copy_Progress)(void *data, unsigned long long done, unsigned long long total);
/** /**
* @typedef Eina_File_Copy_Flags * @typedef Eina_File_Copy_Flags
* what to copy from file. * @brief Enumeration for a flag what to copy from file.
*/ */
typedef enum { typedef enum {
EINA_FILE_COPY_DATA = 0, EINA_FILE_COPY_DATA = 0,
@ -436,33 +436,34 @@ typedef enum {
} Eina_File_Copy_Flags; } Eina_File_Copy_Flags;
/** /**
* Copy one file to another using the fastest possible way, report progress. * @brief Copy one file to another using the fastest possible way and report progress.
* *
* This function will try splice if it is available. It * @param[in] src The source file.
* will block until the whole file is copied or it fails. * @param[in] dst The destination file.
* * @param[in] flags Controls what is copied (data is always copied).
* During the progress it may call back @a cb with the progress summary. * @param[in] cb If it is provided will be called with file copy progress information.
* * @param[in] cb_data Context data to provide to @p cb during copy.
* @param src the source file. * @return #EINA_TRUE on success, #EINA_FALSE otherwise (and @p dst
* @param dst the destination file.
* @param flags controls what is copied (data is always copied).
* @param cb if provided will be called with file copy progress information.
* @param cb_data context data to provide to @a cb during copy.
* @return #EINA_TRUE on success, #EINA_FALSE otherwise (and @a dst
* will be deleted) * will be deleted)
*
* @details This function tries to splice if it is available. It is blocked
* until the whole file is copied or it fails.
*
* @note During the progress it may call back @p cb with the progress summary.
*/ */
EAPI Eina_Bool eina_file_copy(const char *src, const char *dst, Eina_File_Copy_Flags flags, Eina_File_Copy_Progress cb, const void *cb_data) EINA_ARG_NONNULL(1, 2); EAPI Eina_Bool eina_file_copy(const char *src, const char *dst, Eina_File_Copy_Flags flags, Eina_File_Copy_Progress cb, const void *cb_data) EINA_ARG_NONNULL(1, 2);
/** /**
* @brief Get a read-only handler to a file. * @brief Gets a read-only handler to a file.
* *
* @param name Filename to open * @param[in] name The filename to open
* @param shared Requested a shm * @param[in] shared Requested a shm
* @return Eina_File handle to the file
* @return An #Eina_File handle to the file
* *
* Opens a file in read-only mode. @p name should be an absolute path. An * @details This opens a file in the read-only mode. @p name should be an absolute path. An
* Eina_File handle can be shared among multiple instances if @p shared * #Eina_File handle can be shared among multiple instances if @p shared
* is #EINA_TRUE. * is #EINA_TRUE, otherwise.
* *
* @since 1.1 * @since 1.1
*/ */
@ -471,11 +472,11 @@ EAPI Eina_File *eina_file_open(const char *name, Eina_Bool shared) EINA_WARN_UNU
/** /**
* @brief Create a virtual file from a memory pointer. * @brief Create a virtual file from a memory pointer.
* *
* @param virtual_name A virtual name for Eina_File, if @c NULL, a generated one will be given * @param[in] virtual_name A virtual name for Eina_File, if @c NULL, a generated one will be given
* @param data The memory pointer to take data from * @param[in] data The memory pointer to take data from
* @param length The length of the data in memory * @param[in] length The length of the data in memory
* @param copy #EINA_TRUE if the data must be copied * @param[in] copy #EINA_TRUE if the data must be copied
* @return Eina_File handle to the file * @return #Eina_File handle to the file
* *
* @since 1.8 * @since 1.8
*/ */
@ -483,7 +484,7 @@ EAPI Eina_File *
eina_file_virtualize(const char *virtual_name, const void *data, unsigned long long length, Eina_Bool copy) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); eina_file_virtualize(const char *virtual_name, const void *data, unsigned long long length, Eina_Bool copy) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
/** /**
* @brief Tell if a file is a real file or only exist in memory * @brief Tells if a file is a real file or only exist in memory
* *
* @param file The file to test * @param file The file to test
* @return #EINA_TRUE if the file is a virtual file * @return #EINA_TRUE if the file is a virtual file
@ -494,119 +495,121 @@ EAPI Eina_Bool
eina_file_virtual(Eina_File *file) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); eina_file_virtual(Eina_File *file) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
/** /**
* @brief Refresh file information * @brief Refreshes file information
* *
* @param file The file to refresh * @param file The file to refresh
* @return #EINA_TRUE if the file has changed * @return #EINA_TRUE if the file has changed
* *
* All current map continue to exist. You need to manually delete * @details All current map continue to exist. You need to manually delete
* and recreate them to have the new correct mapping. * and recreate them to have the new correct mapping.
* *
* @since 1.8 * @since 1.8
*/ */
EAPI Eina_Bool eina_file_refresh(Eina_File *file); EAPI Eina_Bool eina_file_refresh(Eina_File *file);
/** /**
* @brief Dup a read-only handler of a previously open file. * @brief Duplicates a read-only handler of a previously open file.
* *
* @param file To duplicate a reference to * @param file To duplicate a reference to
* @return Eina_File handle to the duplicated file * @return #Eina_File handle of the duplicated file
* *
* Opens a file in read-only mode. * @note Opens a file in read-only mode.
* *
* @since 1.8 * @since 1.8
*/ */
EAPI Eina_File * eina_file_dup(const Eina_File *file); EAPI Eina_File * eina_file_dup(const Eina_File *file);
/** /**
* @brief Unref file handler. * @brief Unrefs the file handler.
* *
* @param file File handler to unref. * @param[in] file The file handler to unref
* *
* Decrement file's refcount and if it reaches zero close it. * @details This decrements the file's reference count and if it reaches zero it closes the file.
* *
* @since 1.1 * @since 1.1
*/ */
EAPI void eina_file_close(Eina_File *file); EAPI void eina_file_close(Eina_File *file);
/** /**
* @brief Get file size at open time. * @brief Gets the file size at open time.
* *
* @param file The file handler to request the size from. * @param[in] file The file handler to request the size from
* @return The length of the file. * @return The length of the file
* *
* @since 1.1 * @since 1.1
*/ */
EAPI size_t eina_file_size_get(const Eina_File *file); EAPI size_t eina_file_size_get(const Eina_File *file);
/** /**
* @brief Get the last modification time of an open file. * @brief Gets the last modification time of an open file.
* *
* @param file The file handler to request the modification time from. * @param[in] file The file handler to request the modification time from
* @return The last modification time. * @return The last modification time
* *
* @since 1.1 * @since 1.1
*/ */
EAPI time_t eina_file_mtime_get(const Eina_File *file); EAPI time_t eina_file_mtime_get(const Eina_File *file);
/** /**
* @brief Get the filename of an open file. * @brief Gets the filename of an open file.
* *
* @param file The file handler to request the name from. * @param[in] file The file handler to request the name from
* @return Stringshared filename of the file. * @return The stringshared filename of the file
* *
* @since 1.1 * @since 1.1
*/ */
EAPI const char *eina_file_filename_get(const Eina_File *file); EAPI const char *eina_file_filename_get(const Eina_File *file);
/** /**
* @brief Get the eXtended attribute of an open file. * @brief Gets the extended attribute of an open file.
* *
* @param file The file handler to request the eXtended attribute from. * @param[in] file The file handler to request the extended attribute from
* @return an iterator. * @return An iterator
* *
* The iterator will list all eXtended attribute name without allocating * @note The iterator lists all the extended attribute names without allocating
* them, so you need to copy them yourself if needed. * them, so you need to copy them yourself if needed.
* *
* @since 1.2 * @since 1.2
*/ */
EAPI Eina_Iterator *eina_file_xattr_get(Eina_File *file); EAPI Eina_Iterator *eina_file_xattr_get(Eina_File *file);
/** /**
* @brief Get the eXtended attribute of an open file. * @brief Gets the extended attribute of an open file.
* *
* @param file The file handler to request the eXtended attribute from. * @param[in] file The file handler to request the extended attribute from
* @return an iterator. * @return An iterator
* *
* The iterator will list all eXtended attribute without allocating * @note The iterator lists all the extended attribute names without allocating
* them, so you need to copy them yourself if needed. It is returning * them, so you need to copy them yourself if needed. It returns the
* Eina_Xattr structure. * Eina_Xattr structure.
* *
* @since 1.2 * @since 1.2
*/ */
EAPI Eina_Iterator *eina_file_xattr_value_get(Eina_File *file); EAPI Eina_Iterator *eina_file_xattr_value_get(Eina_File *file);
/** /**
* @brief Map all the file to a buffer. * @brief Maps all the files to a buffer.
* *
* @param file The file handler to map in memory * @param[in] file The file handler to map in the memory
* @param rule The rule to apply to the mapped memory * @param[in] rule The rule to apply to the mapped memory
* @return A pointer to a buffer that map all the file content. @c NULL if it fail. * @return A pointer to a buffer that maps all the file content \n
* @c NULL if it fails
* *
* @since 1.1 * @since 1.1
*/ */
EAPI void *eina_file_map_all(Eina_File *file, Eina_File_Populate rule); EAPI void *eina_file_map_all(Eina_File *file, Eina_File_Populate rule);
/** /**
* @brief Map a part of the file. * @brief Maps a part of the file.
* *
* @param file The file handler to map in memory * @param[in] file The file handler to map in the memory
* @param rule The rule to apply to the mapped memory * @param[in] rule The rule to apply to the mapped memory
* @param offset The offset inside the file * @param[in] offset The offset inside the file
* @param length The length of the memory to map * @param[in] length The length of the memory to map
* @return A valid pointer to the system memory with @p length valid byte in it. And @c NULL if not inside the file or anything else goes wrong. * @return A valid pointer to the system memory with @p length valid bytes in it \n
* And @c NULL if not inside the file or anything else goes wrong.
* *
* This does handle refcounting so it will share map that target the same memory area. * @note This does handle reference counting so it can share the same memory area.
* *
* @since 1.1 * @since 1.1
*/ */
@ -614,10 +617,10 @@ EAPI void *eina_file_map_new(Eina_File *file, Eina_File_Populate rule,
unsigned long int offset, unsigned long int length); unsigned long int offset, unsigned long int length);
/** /**
* @brief Unref and unmap memory if possible. * @brief Unrefs and unmaps memory if possible.
* *
* @param file The file handler to unmap memory from. * @param[in] file The file handler to unmap memory from
* @param map Memory map to unref and unmap. * @param[in] map The memory map to unref and unmap
* *
* @since 1.1 * @since 1.1
*/ */
@ -626,15 +629,15 @@ EAPI void eina_file_map_free(Eina_File *file, void *map);
/** /**
* @brief Ask the OS to populate or otherwise pages of memory in file mapping * @brief Ask the OS to populate or otherwise pages of memory in file mapping
* *
* @param file The file handle from which the map comes * @param[in] file The file handle from which the map comes
* @param rule The rule to apply to the mapped memory * @param[in] rule The rule to apply to the mapped memory
* @param map Memory that was mapped inside of which the memory range is * @param[in] map Memory that was mapped inside of which the memory range is
* @param offset The offset in bytes from the start of the map address * @param[in] offset The offset in bytes from the start of the map address
* @param length The length in bytes of the memory region to populate * @param [in]length The length in bytes of the memory region to populate
* *
* This advises the operating system as to what to do with the memory mapped * @details This advises the operating system as to what to do with the memory mapped
* to the given @p file. This affects a specific range of memory and may not * to the given @p file. This affects a specific range of memory and may not
* be honored if the system chooses to ignore the request. * be honored if the system chooses to ignore the request.
* *
* @since 1.8 * @since 1.8
*/ */
@ -643,33 +646,30 @@ eina_file_map_populate(Eina_File *file, Eina_File_Populate rule, const void *map
unsigned long int offset, unsigned long int length); unsigned long int offset, unsigned long int length);
/** /**
* @brief Map line by line in memory efficiently with an Eina_Iterator * @brief Maps line by line in the memory efficiently using an #Eina_Iterator.
* @param file The file to run over
* @return an Eina_Iterator that will produce @ref Eina_File_Line.
* *
* This function return an iterator that will act like fgets without the * @param[in] file The file to run over
* useless memcpy. Be aware that once eina_iterator_next has been called, * @return An Eina_Iterator that produces #Eina_File_Line
* nothing garanty you that the memory will still be mapped. *
* @details This function returns an iterator that acts like fgets without
* useless memcpy. Be aware that once eina_iterator_next has been called,
* nothing can guarantee that the memory is still going to be mapped.
* *
* @since 1.3 * @since 1.3
*/ */
EAPI Eina_Iterator *eina_file_map_lines(Eina_File *file); EAPI Eina_Iterator *eina_file_map_lines(Eina_File *file);
/** /**
* @brief Tell if there was an IO error during the life of a mmaped file * @brief Tells whether there has been an IO error during the life of a mmaped file,
* *
* @param file The file handler to the mmaped file. * @param[in] file The file handler to the mmaped file
* @param map Memory map to check if an error occurred on it. * @param[in] map The memory map to check if an error occurred on it
* @return #EINA_TRUE if there was an IO error, #EINA_FALSE otherwise. * @return #EINA_TRUE if there has been an IO error, otherwise #EINA_FALSE
* *
* @since 1.2 * @since 1.2
*/ */
EAPI Eina_Bool eina_file_map_faulted(Eina_File *file, void *map); EAPI Eina_Bool eina_file_map_faulted(Eina_File *file, void *map);
/**
* @}
*/
/** /**
* @} * @}
*/ */