Home | History | Annotate | Download | only in utils
      1 /* Copyright (C) 2007-2008 The Android Open Source Project
      2 **
      3 ** This software is licensed under the terms of the GNU General Public
      4 ** License version 2, as published by the Free Software Foundation, and
      5 ** may be copied, distributed, and modified under those terms.
      6 **
      7 ** This program is distributed in the hope that it will be useful,
      8 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
      9 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     10 ** GNU General Public License for more details.
     11 */
     12 #ifndef _ANDROID_UTILS_DIR_H
     13 #define _ANDROID_UTILS_DIR_H
     14 
     15 #include "android/utils/compiler.h"
     16 
     17 ANDROID_BEGIN_HEADER
     18 
     19 /* simple utility to parse directories for files            */
     20 /* needed because Unix and Windows don't use the same stuff */
     21 
     22 typedef struct DirScanner  DirScanner;
     23 
     24 /* Create a new directory scanner object from a given rootPath.
     25  * returns NULL in case of failure (error code in errno)
     26  */
     27 DirScanner*    dirScanner_new ( const char*  rootPath );
     28 
     29 /* Destroy a given directory scanner. You must always call
     30  * this function to release proper system resources.
     31  */
     32 void           dirScanner_free( DirScanner*  s );
     33 
     34 /* Get the name of the next file from a directory scanner.
     35  * Returns NULL when there is no more elements in the list.
     36  *
     37  * This is only the file name, use dirScanner_nextFull to
     38  * get its full path.
     39  *
     40  * This will never return '.' and '..'.
     41  *
     42  * The returned string is owned by the scanner, and will
     43  * change on the next call to this function or when the
     44  * scanner is destroyed.
     45  */
     46 const char*    dirScanner_next( DirScanner*  s );
     47 
     48 /* A variant of dirScanner_next() which returns the full path
     49  * to the next directory element.
     50  */
     51 const char*    dirScanner_nextFull( DirScanner*  s );
     52 
     53 ANDROID_END_HEADER
     54 
     55 #endif /* _ANDROID_UTILS_DIR_H */
     56