coan 4.2.4
filesys.h
Go to the documentation of this file.
00001 #ifndef FILESYS_H
00002 #define FILESYS_H
00003 /***************************************************************************
00004  *   Copyright (C) 2004, 2006 Symbian Software Ltd.                        *
00005  *   All rights reserved.                                                  *
00006  *   Copyright (C) 2007-2011 Mike Kinghan, imk@strudl.org                  *
00007  *   All rights reserved.                                                  *
00008  *                                                                         *
00009  *   Contributed originally by Mike Kinghan, imk@strudl.org                *
00010  *                                                                         *
00011  *   Redistribution and use in source and binary forms, with or without    *
00012  *   modification, are permitted provided that the following conditions    *
00013  *   are met:                                                              *
00014  *                                                                         *
00015  *   Redistributions of source code must retain the above copyright        *
00016  *   notice, this list of conditions and the following disclaimer.         *
00017  *                                                                         *
00018  *   Redistributions in binary form must reproduce the above copyright     *
00019  *   notice, this list of conditions and the following disclaimer in the   *
00020  *   documentation and/or other materials provided with the distribution.  *
00021  *                                                                         *
00022  *   Neither the name of Symbian Software Ltd. nor the names of its        *
00023  *   contributors may be used to endorse or promote products derived from  *
00024  *   this software without specific prior written permission.              *
00025  *                                                                         *
00026  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   *
00027  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     *
00028  *   LIMITED TO, THE IMPLIED WARRANTIES OF  MERCHANTABILITY AND FITNESS    *
00029  *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE        *
00030  *   COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,   *
00031  *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,  *
00032  *   BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS *
00033  *   OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED    *
00034  *   AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,*
00035  *   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF *
00036  *   THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH  *
00037  *   DAMAGE.                                                               *
00038  *                                                                         *
00039  **************************************************************************/
00040 
00041 #include "opts.h"
00042 #include "memory.h"
00043 
00044 
00045 
00053 
00055 typedef void * fs_dir_t;
00056 
00057 
00059 typedef enum {
00060     FS_OBJ_NONE,        
00061     FS_OBJ_SLINK = 1,   
00062     FS_OBJ_FILE = 2,    
00063     FS_OBJ_DIR = 4              
00064 } fs_obj_type_t;
00065 
00067 typedef enum {
00068     FS_ABS_PATH = 1 ,           
00069     FS_UNIX_PATH = 2,           
00070     FS_WIN_PATH = 6,        
00071     FS_DANGLING_PATH = 8,       
00072     FS_ROOT_PATH = 16           
00073 } fs_path_type_t;
00074 
00078 #define fs_absolute_path(pathtype) \
00079         (((pathtype) & FS_ABS_PATH) == FS_ABS_PATH)
00080 
00084 #define fs_unix_path(pathtype) \
00085         (((pathtype) & FS_UNIX_PATH) == FS_UNIX_PATH)
00086 
00090 #define fs_windows_path(pathtype) \
00091         (((pathtype) & FS_WIN_PATH) == FS_WIN_PATH)
00092 
00097 #define fs_dangling_path(pathtype) \
00098         (((pathtype) & FS_DANGLING_PATH) == FS_DANGLING_PATH)
00099 
00105 #define fs_root_path(pathtype) \
00106         (((pathtype) & FS_ROOT_PATH) == FS_ROOT_PATH)
00107 
00111 #define FS_IS_FILE(objtype) (((objtype) & FS_OBJ_FILE) != 0)
00112 
00116 #define FS_IS_DIR(objtype) (((objtype) & FS_OBJ_DIR) != 0)
00117 
00121 #define FS_IS_SLINK(objtype) (((objtype) & FS_OBJ_SLINK) != 0)
00122 
00126 extern fs_obj_type_t
00127 fs_obj_type(char const *name);
00128 
00133 extern
00134 fs_obj_type_t
00135 fs_file_or_dir(char const *name);
00136 
00137 
00150 extern fs_dir_t
00151 fs_open_dir(char const *dirname, fs_dir_t const parent);
00152 
00156 extern void
00157 fs_close_dir(fs_dir_t dir);
00158 
00176 extern char const *
00177 fs_read_dir(fs_dir_t dir, char const ** fullname);
00178 
00179 
00183 extern fs_dir_t
00184 fs_get_parent(fs_dir_t dir);
00185 
00195 extern heap_str
00196 fs_compose_filename(char const *path, char const *leafname);
00197 
00215 extern heap_str
00216 fs_split_filename(char const *path, char **leafname);
00217 
00233 extern heap_str
00234 fs_real_path(char const *relname, size_t *namelen);
00235 
00259 extern char const *
00260 fs_cur_dir_entry(fs_dir_t dir, char const **entry);
00261 
00262 
00264 extern fs_path_type_t
00265 fs_path_type(char const *filename);
00266 
00279 extern char *
00280 fs_tempname(char * template);
00281 
00312 extern char const *
00313 fs_path_comp(char const *first, char const *second, size_t *sharedlen);
00314 
00317 #endif /* EOF*/
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines