misc.h

Go to the documentation of this file.
00001 // Copyright 2006 Benedikt Böhm <hollow@gentoo.org>
00002 //
00003 // This program is free software; you can redistribute it and/or modify
00004 // it under the terms of the GNU General Public License as published by
00005 // the Free Software Foundation; either version 2 of the License, or
00006 // (at your option) any later version.
00007 //
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the
00015 // Free Software Foundation, Inc.,
00016 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 
00018 /*!
00019  * @defgroup misc Miscellaneous helpers
00020  *
00021  * The misc family of functions provide wrappers not fitting in any other
00022  * module and not being worth an own category for each of them.
00023  *
00024  * The isdir(), isfile() and islink() functions wrap the stat(2) system call and
00025  * checks if the path in the string pointed to by path is a directory, regular
00026  * file or link, respectively.
00027  *
00028  * The mkdirp() function creates any missing parent directories of the path in
00029  * the string pointed to by path, before creating the directory itself. The
00030  * mkdirnamep() function additionally calls dirname(3) on the path string
00031  * before calling mkdirp().
00032  *
00033  * The path_concat() function concatenates the strings pointed to by dirname and
00034  * basename and checks the latter using str_path_isdot().
00035  *
00036  * The runlink() function removes all files and directories in the path pointed
00037  * to by the string path.
00038  *
00039  * @{
00040  */
00041 
00042 #ifndef _LUCID_MISC_H
00043 #define _LUCID_MISC_H
00044 
00045 #include <sys/types.h>
00046 
00047 /*!
00048  * @brief check if given path is a directory
00049  *
00050  * @param[in] path path to check
00051  *
00052  * @return 1 on success, 0 otherwise
00053  *
00054  * @see stat(2)
00055  */
00056 int isdir(const char *path);
00057 
00058 /*!
00059  * @brief check if given path is a regular file
00060  *
00061  * @param[in] path path to check
00062  *
00063  * @return 1 on success, 0 otherwise
00064  *
00065  * @see stat(2)
00066  */
00067 int isfile(const char *path);
00068 
00069 /*!
00070  * @brief check if given path is a symbolic link
00071  *
00072  * @param[in] path path to check
00073  *
00074  * @return 1 on success, 0 otherwise
00075  *
00076  * @see stat(2)
00077  */
00078 int islink(const char *path);
00079 
00080 /*!
00081  * @brief recursive mkdir(2) with dirname(3)
00082  *
00083  * @param[in] path path to create
00084  * @param[in] mode file permissions
00085  *
00086  * @return 0 on success, -1 on error with errno set
00087  *
00088  * @see mkdir(2)
00089  * @see dirname(3)
00090  */
00091 int mkdirnamep(const char *path, mode_t mode);
00092 
00093 /*!
00094  * @brief recursive mkdir(2)
00095  *
00096  * @param[in] path path to create
00097  * @param[in] mode file permissions
00098  *
00099  * @return 0 on success, -1 on error with errno set
00100  *
00101  * @see mkdir(2)
00102  */
00103 int mkdirp(const char *path, mode_t mode);
00104 
00105 /*!
00106  * @brief recursive unlink(2) and rmdir(2)
00107  *
00108  * @param[in] path path to remove
00109  *
00110  * @return 0 on success, -1 on error with errno set
00111  *
00112  * @see unlink(2)
00113  * @see rmdir(2)
00114  */
00115 int runlink(const char *path);
00116 
00117 #endif
00118 
00119 /*! @} misc */

Generated on Sun Dec 3 17:45:53 2006 for lucid by  doxygen 1.5.1