1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 // -*- c++ -*- 19 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 20 21 // O S C L _ F I L E _ Dir _ utils 22 23 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 24 25 /*! \addtogroup osclio OSCL IO 26 * 27 * @{ 28 */ 29 30 31 /*! \file oscl_file_dir_utils.h 32 \brief The file oscl_file_dir_utils.h defines some unix-style directory ops 33 34 */ 35 36 #ifndef OSCL_FILE_DIR_UTILS_H_INCLUDED 37 #define OSCL_FILE_DIR_UTILS_H_INCLUDED 38 39 #ifndef OSCLCONFIG_IO_H_INCLUDED 40 #include "osclconfig_io.h" 41 #endif 42 43 #ifndef OSCL_BASE_H_INCLUDED 44 #include "oscl_base.h" 45 #endif 46 47 48 49 typedef struct oscl_fsstat 50 { 51 uint64 freebytes; 52 uint64 totalbytes; 53 } OSCL_FSSTAT; 54 55 typedef enum 56 { 57 OSCL_FILEMGMT_PERMS_READ = 0x1, 58 OSCL_FILEMGMT_PERMS_WRITE = 0x2, 59 OSCL_FILEMGMT_PERMS_EXECUTE = 0x4, 60 } OSCL_FILEMGMT_PERMS; 61 62 typedef enum 63 { 64 OSCL_FILEMGMT_MODE_DIR = 0x1 65 } OSCL_FILEMGMT_MODES; 66 67 typedef struct oscl_stat_buf 68 { 69 uint32 mode; 70 uint32 perms; 71 } OSCL_STAT_BUF; 72 73 typedef enum 74 { 75 OSCL_FILEMGMT_E_OK = 0, 76 OSCL_FILEMGMT_E_PATH_TOO_LONG, 77 OSCL_FILEMGMT_E_PATH_NOT_FOUND, 78 OSCL_FILEMGMT_E_ALREADY_EXISTS, 79 OSCL_FILEMGMT_E_NOT_EMPTY, 80 OSCL_FILEMGMT_E_PERMISSION_DENIED, 81 OSCL_FILEMGMT_E_NO_MATCH, 82 OSCL_FILEMGMT_E_UNKNOWN, 83 OSCL_FILEMGMT_E_SYS_SPECIFIC, 84 OSCL_FILEMGMT_E_NOT_IMPLEMENTED 85 } OSCL_FILEMGMT_ERR_TYPE; 86 87 /** 88 * oscl_getcwd function can be used to determine the full path name of the 89 * current directory. 90 * @param pointer to wide character buffer to receive the current directory 91 * @param size size of buffer in wide characters 92 * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. 93 */ 94 OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_getcwd(oscl_wchar *path, uint32 size); 95 96 97 /** 98 * oscl_getcwd function can be used to determine the full path name of the 99 * current directory. 100 * @param pointer to character buffer to receive the current directory 101 * @param size size of buffer in characters 102 * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. 103 */ 104 OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_getcwd(char *path, uint32 size); 105 106 107 108 /** 109 * oscl_stat function can be used to determine the size of a file 110 * in addition to whether the file exists or not 111 * @param wide character path the full path of the file to stat. 112 * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. 113 */ 114 OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_stat(const oscl_wchar *path, OSCL_STAT_BUF *statbuf); 115 116 117 /** 118 * oscl_stat function can be used to determine the size of a file 119 * in addition to whether the file exists or not 120 * @param character path the full path of the file to stat. 121 * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. 122 */ 123 OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_stat(const char *path, OSCL_STAT_BUF *statbuf); 124 125 126 /** 127 * oscl_mkdir function creates a directory in the path given 128 * @param wide character path the full path of the directory to create. if parts 129 * of the path do not exist the function will fail 130 * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. 131 */ 132 OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_mkdir(const oscl_wchar *path); 133 134 /** 135 * oscl_mkdir function creates a directory in the path given 136 * @param character path the full path of the directory to create. if parts 137 * of the path do not exist the function will fail 138 * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. 139 */ 140 OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_mkdir(const char *path); 141 142 /** 143 * oscl_rmdir function removes and empty directory in the path given 144 * @param wide character path the full path of the directory to remove. 145 * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. 146 */ 147 OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_rmdir(const oscl_wchar *path); 148 149 /** 150 * oscl_rmdir removes an empty directory in the path given 151 * @param character path the full path of the directory to remove. 152 * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. 153 */ 154 OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_rmdir(const char *path); 155 156 /** 157 * oscl_chdir changes the current directory to the path given 158 * @param wide character path the full path of the directory to change to. 159 * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. 160 */ 161 OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_chdir(const oscl_wchar *path); 162 163 /** 164 * oscl_chdir changes the current directory to the path given 165 * @param character path the full path of the directory to change to. 166 * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. 167 */ 168 OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_chdir(const char *path); 169 170 /** 171 * oscl_rename function renames a file or directory 172 * @param wide character path the full path of the file or directory 173 * to rename. 174 * @param wide character path the full path the new name for the directory 175 * 176 * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. 177 */ 178 179 OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_rename(const oscl_wchar *oldpath, const oscl_wchar *newpath); 180 181 /** 182 * oscl_rmdir removes an empty directory in the path given 183 * @param character path the full path of the directory to remove. 184 * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. 185 */ 186 187 OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_rename(const char *oldpath, const char *newpath); 188 189 /** 190 * Oscl_StatFS function populates a general structure describing free space available on a filesystem 191 * @param stats pointer to structure to hold information 192 * @param path located in desired filesystem (utf8) 193 * Note: If the OS does not support a particular field in the structure, it is set to -1. 194 * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. 195 */ 196 OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_statfs(OSCL_FSSTAT *stats, const char *path); 197 /** 198 * Oscl_StatFS function populates a general structure describing free space available on a filesystem 199 * @param stats pointer to structure to hold information 200 * @param path located in desired filesystem (utf8) 201 * Note: If the OS does not support a particular field in the structure, it is set to -1. 202 * @return OSCL_FILEMGMT_ERR_TYPE, see enumeration for this type. 203 */ 204 OSCL_IMPORT_REF OSCL_FILEMGMT_ERR_TYPE oscl_statfs(OSCL_FSSTAT *stats, const oscl_wchar *path); 205 206 207 #endif // OSCL_FILE_DIR_UTILS_H_INCLUDED 208 209 /*! @} */ 210 211