1 /* 2 * wzdftpd - a modular and cool ftp server 3 * Copyright (C) 2002-2004 Pierre Chifflier 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * 19 * As a special exemption, Pierre Chifflier 20 * and other respective copyright holders give permission to link this program 21 * with OpenSSL, and distribute the resulting executable, without including 22 * the source code for OpenSSL in the source distribution. 23 */ 24 25 #ifndef __WZD_FS__ 26 #define __WZD_FS__ 27 28 /** \file wzd_fs.h 29 * \brief Abstraction layer to functions accessing to the filesystem. 30 */ 31 32 typedef struct fs_dir_t fs_dir_t; 33 typedef struct fs_fileinfo_t fs_fileinfo_t; 34 typedef struct fs_filestat_t fs_filestat_t; 35 36 struct fs_filestat_t { 37 u32_t mode; 38 u64_t size; 39 time_t mtime; 40 time_t ctime; 41 int nlink; 42 }; 43 44 /** \brief Create a directory 45 * 46 * pathname should be UTF-8 encoded, or will be converted to unicode. 47 * 48 * \return -1 on error, and set \a err to errno 49 */ 50 int fs_mkdir(const char * pathname, unsigned long mode, int * err); 51 52 /** \brief Open a directory 53 * 54 * pathname should be UTF-8 encoded, or will be converted to unicode. 55 */ 56 int fs_dir_open(const char * pathname, fs_dir_t ** newdir); 57 58 /** \brief Close a directory 59 */ 60 int fs_dir_close(fs_dir_t * dir); 61 62 /** \brief Read a directory 63 * 64 * pathname should be UTF-8 encoded, or will be converted to unicode. 65 */ 66 int fs_dir_read(fs_dir_t * dir, fs_fileinfo_t ** fileinfo); 67 68 /** \brief Get informations on file 69 * 70 * pathname must be an absolute path 71 * pathname should be UTF-8 encoded, or will be converted to unicode. 72 */ 73 int fs_file_stat(const char *pathname, fs_filestat_t * s); 74 75 /** \brief Get informations on file 76 * 77 * pathname must be an absolute path 78 * pathname should be UTF-8 encoded, or will be converted to unicode. 79 */ 80 int fs_file_lstat(const char *pathname, fs_filestat_t * s); 81 82 /** \brief Get informations on file 83 */ 84 int fs_file_fstat(int fd, fs_filestat_t * s); 85 86 87 const char * fs_fileinfo_getname(fs_fileinfo_t * finfo); 88 89 #endif /* __WZD_FS__ */ 90