1
1
mc/lib/fs.h

102 строки
2.2 KiB
C
Исходник Обычный вид История

/** \file fs.h
* \brief Header: fs compatibility definitions
*/
1998-02-27 07:54:42 +03:00
/* Include file to use opendir/closedir/readdir */
#ifndef MC_FS_H
#define MC_FS_H
1998-02-27 07:54:42 +03:00
#include <sys/types.h>
2009-02-06 15:44:53 +03:00
#include <unistd.h>
1998-02-27 07:54:42 +03:00
#include <sys/stat.h>
#include <dirent.h>
1998-02-27 07:54:42 +03:00
/*** typedefs(not structures) and defined constants **********************************************/
/* Replacement for permission bits missing in sys/stat.h */
#ifndef S_ISLNK
#define S_ISLNK(x) 0
#endif
#ifndef S_ISSOCK
#define S_ISSOCK(x) 0
#endif
#ifndef S_ISFIFO
#define S_ISFIFO(x) 0
#endif
#ifndef S_ISCHR
#define S_ISCHR(x) 0
#endif
#ifndef S_ISBLK
#define S_ISBLK(x) 0
#endif
/* Door is something that only exists on Solaris */
#ifndef S_ISDOOR
#define S_ISDOOR(x) 0
#endif
/* Special named files are widely used in QNX6 */
#ifndef S_ISNAM
#define S_ISNAM(x) 0
#endif
#ifndef PATH_MAX
#ifdef _POSIX_VERSION
#define PATH_MAX _POSIX_PATH_MAX
#else
#ifdef MAXPATHLEN
#define PATH_MAX MAXPATHLEN
#else
#define PATH_MAX 1024
#endif
#endif
#endif
1998-02-27 07:54:42 +03:00
#ifndef MAXPATHLEN
#define MC_MAXPATHLEN 4096
1998-02-27 07:54:42 +03:00
#else
#define MC_MAXPATHLEN MAXPATHLEN
1998-02-27 07:54:42 +03:00
#endif
/* unistd.h defines _POSIX_VERSION on POSIX.1 systems. */
2009-02-06 15:44:53 +03:00
#define NLENGTH(dirent) (strlen ((dirent)->d_name))
#define DIRENT_LENGTH_COMPUTED 1
1998-02-27 07:54:42 +03:00
/* DragonFlyBSD doesn't provide MAXNAMLEN macro */
#ifndef MAXNAMLEN
#define MAXNAMLEN NAME_MAX
#endif
#define MC_MAXFILENAMELEN MAXNAMLEN
#define DIR_IS_DOT(x) ((x)[0] == '.' && (x)[1] == '\0')
#define DIR_IS_DOTDOT(x) ((x)[0] == '.' && (x)[1] == '.' && (x)[2] == '\0')
/*** enums ***************************************************************************************/
/*** structures declarations (and typedefs of structures)*****************************************/
/*** global variables defined in .c file *********************************************************/
/*** declarations of public functions ************************************************************/
/*** inline functions ****************************************************************************/
static inline void
compute_namelen (struct dirent *dent __attribute__ ((unused)))
{
#ifdef DIRENT_LENGTH_COMPUTED
(void) dent;
return;
#else
dent->d_namlen = strlen (dent);
#endif
}
#endif