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/* simple utility to parse directories for files */ 16/* needed because Unix and Windows don't use the same stuff */ 17 18typedef struct DirScanner DirScanner; 19 20/* Create a new directory scanner object from a given rootPath. 21 * returns NULL in case of failure (error code in errno) 22 */ 23DirScanner* dirScanner_new ( const char* rootPath ); 24 25/* Destroy a given directory scanner. You must always call 26 * this function to release proper system resources. 27 */ 28void dirScanner_free( DirScanner* s ); 29 30/* Get the name of the next file from a directory scanner. 31 * Returns NULL when there is no more elements in the list. 32 * 33 * This is only the file name, use dirScanner_nextFull to 34 * get its full path. 35 * 36 * This will never return '.' and '..'. 37 * 38 * The returned string is owned by the scanner, and will 39 * change on the next call to this function or when the 40 * scanner is destroyed. 41 */ 42const char* dirScanner_next( DirScanner* s ); 43 44/* A variant of dirScanner_next() which returns the full path 45 * to the next directory element. 46 */ 47const char* dirScanner_nextFull( DirScanner* s ); 48 49/* */ 50 51#endif /* _ANDROID_UTILS_DIR_H */ 52