2008-11-17 00:36:30 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* include/dirent.h
|
2007-03-15 06:41:09 +08:00
|
|
|
*
|
2009-12-15 07:32:23 +08:00
|
|
|
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
2012-07-17 11:58:11 +08:00
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
2007-03-15 06:41:09 +08:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
2008-11-17 00:36:30 +08:00
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
2007-03-15 06:41:09 +08:00
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
2008-11-17 00:36:30 +08:00
|
|
|
****************************************************************************/
|
2007-03-15 06:41:09 +08:00
|
|
|
|
2008-11-17 00:36:30 +08:00
|
|
|
#ifndef __INCLUDE_DIRENT_H
|
|
|
|
#define __INCLUDE_DIRENT_H
|
2007-03-15 06:41:09 +08:00
|
|
|
|
2008-11-17 00:36:30 +08:00
|
|
|
/****************************************************************************
|
2007-03-15 06:41:09 +08:00
|
|
|
* Included Files
|
2008-11-17 00:36:30 +08:00
|
|
|
****************************************************************************/
|
2007-03-15 06:41:09 +08:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
2009-12-15 07:32:23 +08:00
|
|
|
|
2007-03-15 06:41:09 +08:00
|
|
|
#include <sys/types.h>
|
2009-12-15 07:32:23 +08:00
|
|
|
#include <stdint.h>
|
2007-03-15 06:41:09 +08:00
|
|
|
#include <limits.h>
|
|
|
|
|
2008-11-17 00:36:30 +08:00
|
|
|
/****************************************************************************
|
2009-12-15 07:32:23 +08:00
|
|
|
* Pre-processor Definitions
|
2008-11-17 00:36:30 +08:00
|
|
|
****************************************************************************/
|
2007-03-15 06:41:09 +08:00
|
|
|
|
|
|
|
/* File type code for the d_type field in dirent struct.
|
|
|
|
* Note that because of the simplified filesystem organization
|
|
|
|
* of NuttX, an inode can be BOTH a file and a directory
|
|
|
|
*/
|
|
|
|
|
2017-02-04 01:23:57 +08:00
|
|
|
#define DTYPE_UNKNOWN 0 /* The file type could not be determined */
|
|
|
|
#define DTYPE_FILE (1 << 0) /* Bit 0: Regular file */
|
|
|
|
#define DTYPE_CHR (1 << 1) /* Bit 1: Character device */
|
|
|
|
#define DTYPE_BLK (1 << 2) /* Bit 2: Block device */
|
|
|
|
#define DTYPE_DIRECTORY (1 << 3) /* Bit 3: Directory */
|
|
|
|
#define DTYPE_LINK (1 << 4) /* Bit 4: Symbolic link */
|
2007-03-15 06:41:09 +08:00
|
|
|
|
2017-02-04 05:50:41 +08:00
|
|
|
#define DIRENT_ISFILE(dtype) (((dtype) & DTYPE_FILE) != 0)
|
|
|
|
#define DIRENT_ISCHR(dtype) (((dtype) & DTYPE_CHR) != 0)
|
|
|
|
#define DIRENT_ISBLK(dtype) (((dtype) & DTYPE_BLK) != 0)
|
|
|
|
#define DIRENT_ISDIRECTORY(dtype) (((dtype) & DTYPE_DIRECTORY) != 0)
|
|
|
|
#define DIRENT_ISLINK(dtype) (((dtype) & DTYPE_LINK) != 0)
|
2007-03-15 06:41:09 +08:00
|
|
|
|
2008-11-17 00:36:30 +08:00
|
|
|
/****************************************************************************
|
2007-03-15 06:41:09 +08:00
|
|
|
* Public Type Definitions
|
2008-11-17 00:36:30 +08:00
|
|
|
****************************************************************************/
|
2007-03-15 06:41:09 +08:00
|
|
|
|
2012-07-17 11:58:11 +08:00
|
|
|
/* The POSIX specification requires that the caller of readdir_r provide
|
|
|
|
* storage "large enough for a dirent with the d_name member and an array
|
|
|
|
* of char containing at least {NAME_MAX} plus one elements.
|
2007-03-15 06:41:09 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct dirent
|
|
|
|
{
|
2009-12-15 07:32:23 +08:00
|
|
|
uint8_t d_type; /* type of file */
|
2007-03-15 06:41:09 +08:00
|
|
|
char d_name[NAME_MAX+1]; /* filename */
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef void DIR;
|
|
|
|
|
2008-11-17 00:36:30 +08:00
|
|
|
/****************************************************************************
|
2015-10-03 06:30:35 +08:00
|
|
|
* Public Data
|
2008-11-17 00:36:30 +08:00
|
|
|
****************************************************************************/
|
2007-03-15 06:41:09 +08:00
|
|
|
|
2008-11-17 00:36:30 +08:00
|
|
|
/****************************************************************************
|
2007-03-15 06:41:09 +08:00
|
|
|
* Public Function Prototypes
|
2008-11-17 00:36:30 +08:00
|
|
|
****************************************************************************/
|
2007-03-15 06:41:09 +08:00
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
#define EXTERN extern "C"
|
2014-07-24 04:49:16 +08:00
|
|
|
extern "C"
|
|
|
|
{
|
2007-03-15 06:41:09 +08:00
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* POSIX-like File System Interfaces */
|
|
|
|
|
2014-07-24 04:49:16 +08:00
|
|
|
int closedir(FAR DIR *dirp);
|
|
|
|
FAR DIR *opendir(FAR const char *path);
|
|
|
|
FAR struct dirent *readdir(FAR DIR *dirp);
|
|
|
|
int readdir_r(FAR DIR *dirp, FAR struct dirent *entry,
|
|
|
|
FAR struct dirent **result);
|
|
|
|
void rewinddir(FAR DIR *dirp);
|
|
|
|
void seekdir(FAR DIR *dirp, off_t loc);
|
|
|
|
off_t telldir(FAR DIR *dirp);
|
2007-03-15 06:41:09 +08:00
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-11-17 00:36:30 +08:00
|
|
|
#endif /* __INCLUDE_DIRENT_H */
|