1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _OSL_FILE_PATH_HELPER_H_ 29 #define _OSL_FILE_PATH_HELPER_H_ 30 31 32 #ifndef _SAL_TYPES_H_ 33 #include <sal/types.h> 34 #endif 35 36 #ifndef _RTL_USTRING_H_ 37 #include <rtl/ustring.h> 38 #endif 39 40 41 #ifdef __cplusplus 42 extern "C" 43 { 44 #endif 45 46 47 /******************************************* 48 osl_systemPathRemoveSeparator 49 Removes the last separator from the 50 given system path if any and if the path 51 is not the root path '/' 52 53 @param ppustrPath [inout] a system path 54 if the path is not the root path 55 and the last character is a 56 path separator it will be cut off 57 ppustrPath must not be NULL and 58 must point to a valid rtl_uString 59 60 @returns nothing 61 62 ******************************************/ 63 64 void SAL_CALL osl_systemPathRemoveSeparator( 65 /*inout*/ rtl_uString* pustrPath); 66 67 /******************************************* 68 osl_systemPathEnsureSeparator 69 Adds a trailing path separator to the 70 given system path if not already there 71 and if the path is not the root path '/' 72 73 @param pustrPath [inout] a system path 74 if the path is not the root path 75 '/' and has no trailing separator 76 a separator will be added 77 ppustrPath must not be NULL and 78 must point to a valid rtl_uString 79 80 @returns nothing 81 82 ******************************************/ 83 84 void SAL_CALL osl_systemPathEnsureSeparator( 85 /*inout*/ rtl_uString** ppustrPath); 86 87 /******************************************* 88 osl_systemPathIsRelativePath 89 Returns true if the given path is a 90 relative path and so starts not with '/' 91 92 @param pustrPath [in] a system path 93 pustrPath must not be NULL 94 95 @returns sal_True if the given path 96 doesn't start with a separator 97 else sal_False will be returned 98 99 ******************************************/ 100 101 sal_Bool SAL_CALL osl_systemPathIsRelativePath( 102 const rtl_uString* pustrPath); 103 104 /****************************************** 105 osl_systemPathMakeAbsolutePath 106 Append a relative path to a base path 107 108 @param pustrBasePath [in] a system 109 path that will be considered as 110 base path 111 pustrBasePath must not be NULL 112 113 @param pustrRelPath [in] a system path 114 that will be considered as 115 relative path 116 pustrBasePath must not be NULL 117 118 @param ppustrAbsolutePath [out] the 119 resulting path which is a 120 concatination of the base and 121 the relative path 122 if base path is empty the 123 resulting absolute path is the 124 relative path 125 if relative path is empty the 126 resulting absolute path is the 127 base path 128 if base and relative path are 129 empty the resulting absolute 130 path is also empty 131 ppustrAbsolutePath must not be 132 NULL and *ppustrAbsolutePath 133 must be 0 or point to a valid 134 rtl_uString 135 136 *****************************************/ 137 138 void SAL_CALL osl_systemPathMakeAbsolutePath( 139 const rtl_uString* pustrBasePath, 140 const rtl_uString* pustrRelPath, 141 rtl_uString** ppustrAbsolutePath); 142 143 /***************************************** 144 osl_systemPathGetFileOrLastDirectoryPart 145 Returns the file or the directory part 146 of the given path 147 148 @param pustrPath [in] a system path, 149 must not be NULL 150 151 @param ppustrFileOrDirPart [out] on 152 return receives the last part 153 of the given directory or the 154 file name 155 if pustrPath is the root path 156 '/' an empty string will be 157 returned 158 if pustrPath has a trailing 159 '/' the last part before the 160 '/' will be returned else 161 the part after the last '/' 162 will be returned 163 164 @returns nothing 165 166 ****************************************/ 167 void SAL_CALL osl_systemPathGetFileNameOrLastDirectoryPart( 168 const rtl_uString* pustrPath, 169 rtl_uString** ppustrFileNameOrLastDirPart); 170 171 172 /******************************************** 173 osl_systemPathIsHiddenFileOrDirectoryEntry 174 Returns sal_True if the last part of 175 given system path is not '.' or '..' 176 alone and starts with a '.' 177 178 @param pustrPath [in] a system path, 179 must not be NULL 180 181 @returns sal_True if the last part of 182 the given system path starts 183 with '.' or sal_False the last 184 part is '.' or '..' alone or 185 doesn't start with a dot 186 187 *********************************************/ 188 189 sal_Bool SAL_CALL osl_systemPathIsHiddenFileOrDirectoryEntry( 190 const rtl_uString* pustrPath); 191 192 193 /************************************************ 194 osl_systemPathIsLocalOrParentDirectoryEntry 195 Returns sal_True if the last part of the given 196 system path is the local directory entry '.' 197 or the parent directory entry '..' 198 199 @param pustrPath [in] a system path, 200 must not be NULL 201 202 @returns sal_True if the last part of the 203 given system path is '.' or '..' 204 else sal_False 205 206 ************************************************/ 207 208 sal_Bool SAL_CALL osl_systemPathIsLocalOrParentDirectoryEntry( 209 const rtl_uString* pustrPath); 210 211 212 /************************************************ 213 osl_searchPath 214 Searches for a file name or path name in all 215 directories specified by a given path list. 216 Symbolic links in the resulting path will not be 217 resolved, it's up to the caller to do this. 218 219 @param pustrFilePath [in] a file name or 220 directory name to search for, the name must 221 be provided as system path not as a file URL 222 223 @param pustrSearchPathList [in] a ':' 224 separated list of paths in which to search for 225 the file or directory name 226 227 @ppustrPathFound [out] on success receives the 228 complete path of the file or directory found 229 as a system path 230 231 @returns sal_True if the specified file or 232 directory was found else sal_False 233 ***********************************************/ 234 235 sal_Bool SAL_CALL osl_searchPath( 236 const rtl_uString* pustrFilePath, 237 const rtl_uString* pustrSearchPathList, 238 rtl_uString** ppustrPathFound); 239 240 241 #ifdef __cplusplus 242 } 243 #endif 244 245 246 #endif /* #ifndef _OSL_PATH_HELPER_H_ */ 247 248