1*9eab2a37SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9eab2a37SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9eab2a37SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9eab2a37SAndrew Rist * distributed with this work for additional information 6*9eab2a37SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9eab2a37SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9eab2a37SAndrew Rist * "License"); you may not use this file except in compliance 9*9eab2a37SAndrew Rist * with the License. You may obtain a copy of the License at 10*9eab2a37SAndrew Rist * 11*9eab2a37SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*9eab2a37SAndrew Rist * 13*9eab2a37SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9eab2a37SAndrew Rist * software distributed under the License is distributed on an 15*9eab2a37SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9eab2a37SAndrew Rist * KIND, either express or implied. See the License for the 17*9eab2a37SAndrew Rist * specific language governing permissions and limitations 18*9eab2a37SAndrew Rist * under the License. 19*9eab2a37SAndrew Rist * 20*9eab2a37SAndrew Rist *************************************************************/ 21*9eab2a37SAndrew Rist 22*9eab2a37SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _OSL_FILE_PATH_HELPER_H_ 25cdf0e10cSrcweir #define _OSL_FILE_PATH_HELPER_H_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #ifndef _SAL_TYPES_H_ 29cdf0e10cSrcweir #include <sal/types.h> 30cdf0e10cSrcweir #endif 31cdf0e10cSrcweir 32cdf0e10cSrcweir #ifndef _RTL_USTRING_H_ 33cdf0e10cSrcweir #include <rtl/ustring.h> 34cdf0e10cSrcweir #endif 35cdf0e10cSrcweir 36cdf0e10cSrcweir 37cdf0e10cSrcweir #ifdef __cplusplus 38cdf0e10cSrcweir extern "C" 39cdf0e10cSrcweir { 40cdf0e10cSrcweir #endif 41cdf0e10cSrcweir 42cdf0e10cSrcweir 43cdf0e10cSrcweir /******************************************* 44cdf0e10cSrcweir osl_systemPathRemoveSeparator 45cdf0e10cSrcweir Removes the last separator from the 46cdf0e10cSrcweir given system path if any and if the path 47cdf0e10cSrcweir is not the root path '/' 48cdf0e10cSrcweir 49cdf0e10cSrcweir @param ppustrPath [inout] a system path 50cdf0e10cSrcweir if the path is not the root path 51cdf0e10cSrcweir and the last character is a 52cdf0e10cSrcweir path separator it will be cut off 53cdf0e10cSrcweir ppustrPath must not be NULL and 54cdf0e10cSrcweir must point to a valid rtl_uString 55cdf0e10cSrcweir 56cdf0e10cSrcweir @returns nothing 57cdf0e10cSrcweir 58cdf0e10cSrcweir ******************************************/ 59cdf0e10cSrcweir 60cdf0e10cSrcweir void SAL_CALL osl_systemPathRemoveSeparator( 61cdf0e10cSrcweir /*inout*/ rtl_uString* pustrPath); 62cdf0e10cSrcweir 63cdf0e10cSrcweir /******************************************* 64cdf0e10cSrcweir osl_systemPathEnsureSeparator 65cdf0e10cSrcweir Adds a trailing path separator to the 66cdf0e10cSrcweir given system path if not already there 67cdf0e10cSrcweir and if the path is not the root path '/' 68cdf0e10cSrcweir 69cdf0e10cSrcweir @param pustrPath [inout] a system path 70cdf0e10cSrcweir if the path is not the root path 71cdf0e10cSrcweir '/' and has no trailing separator 72cdf0e10cSrcweir a separator will be added 73cdf0e10cSrcweir ppustrPath must not be NULL and 74cdf0e10cSrcweir must point to a valid rtl_uString 75cdf0e10cSrcweir 76cdf0e10cSrcweir @returns nothing 77cdf0e10cSrcweir 78cdf0e10cSrcweir ******************************************/ 79cdf0e10cSrcweir 80cdf0e10cSrcweir void SAL_CALL osl_systemPathEnsureSeparator( 81cdf0e10cSrcweir /*inout*/ rtl_uString** ppustrPath); 82cdf0e10cSrcweir 83cdf0e10cSrcweir /******************************************* 84cdf0e10cSrcweir osl_systemPathIsRelativePath 85cdf0e10cSrcweir Returns true if the given path is a 86cdf0e10cSrcweir relative path and so starts not with '/' 87cdf0e10cSrcweir 88cdf0e10cSrcweir @param pustrPath [in] a system path 89cdf0e10cSrcweir pustrPath must not be NULL 90cdf0e10cSrcweir 91cdf0e10cSrcweir @returns sal_True if the given path 92cdf0e10cSrcweir doesn't start with a separator 93cdf0e10cSrcweir else sal_False will be returned 94cdf0e10cSrcweir 95cdf0e10cSrcweir ******************************************/ 96cdf0e10cSrcweir 97cdf0e10cSrcweir sal_Bool SAL_CALL osl_systemPathIsRelativePath( 98cdf0e10cSrcweir const rtl_uString* pustrPath); 99cdf0e10cSrcweir 100cdf0e10cSrcweir /****************************************** 101cdf0e10cSrcweir osl_systemPathMakeAbsolutePath 102cdf0e10cSrcweir Append a relative path to a base path 103cdf0e10cSrcweir 104cdf0e10cSrcweir @param pustrBasePath [in] a system 105cdf0e10cSrcweir path that will be considered as 106cdf0e10cSrcweir base path 107cdf0e10cSrcweir pustrBasePath must not be NULL 108cdf0e10cSrcweir 109cdf0e10cSrcweir @param pustrRelPath [in] a system path 110cdf0e10cSrcweir that will be considered as 111cdf0e10cSrcweir relative path 112cdf0e10cSrcweir pustrBasePath must not be NULL 113cdf0e10cSrcweir 114cdf0e10cSrcweir @param ppustrAbsolutePath [out] the 115cdf0e10cSrcweir resulting path which is a 116cdf0e10cSrcweir concatination of the base and 117cdf0e10cSrcweir the relative path 118cdf0e10cSrcweir if base path is empty the 119cdf0e10cSrcweir resulting absolute path is the 120cdf0e10cSrcweir relative path 121cdf0e10cSrcweir if relative path is empty the 122cdf0e10cSrcweir resulting absolute path is the 123cdf0e10cSrcweir base path 124cdf0e10cSrcweir if base and relative path are 125cdf0e10cSrcweir empty the resulting absolute 126cdf0e10cSrcweir path is also empty 127cdf0e10cSrcweir ppustrAbsolutePath must not be 128cdf0e10cSrcweir NULL and *ppustrAbsolutePath 129cdf0e10cSrcweir must be 0 or point to a valid 130cdf0e10cSrcweir rtl_uString 131cdf0e10cSrcweir 132cdf0e10cSrcweir *****************************************/ 133cdf0e10cSrcweir 134cdf0e10cSrcweir void SAL_CALL osl_systemPathMakeAbsolutePath( 135cdf0e10cSrcweir const rtl_uString* pustrBasePath, 136cdf0e10cSrcweir const rtl_uString* pustrRelPath, 137cdf0e10cSrcweir rtl_uString** ppustrAbsolutePath); 138cdf0e10cSrcweir 139cdf0e10cSrcweir /***************************************** 140cdf0e10cSrcweir osl_systemPathGetFileOrLastDirectoryPart 141cdf0e10cSrcweir Returns the file or the directory part 142cdf0e10cSrcweir of the given path 143cdf0e10cSrcweir 144cdf0e10cSrcweir @param pustrPath [in] a system path, 145cdf0e10cSrcweir must not be NULL 146cdf0e10cSrcweir 147cdf0e10cSrcweir @param ppustrFileOrDirPart [out] on 148cdf0e10cSrcweir return receives the last part 149cdf0e10cSrcweir of the given directory or the 150cdf0e10cSrcweir file name 151cdf0e10cSrcweir if pustrPath is the root path 152cdf0e10cSrcweir '/' an empty string will be 153cdf0e10cSrcweir returned 154cdf0e10cSrcweir if pustrPath has a trailing 155cdf0e10cSrcweir '/' the last part before the 156cdf0e10cSrcweir '/' will be returned else 157cdf0e10cSrcweir the part after the last '/' 158cdf0e10cSrcweir will be returned 159cdf0e10cSrcweir 160cdf0e10cSrcweir @returns nothing 161cdf0e10cSrcweir 162cdf0e10cSrcweir ****************************************/ 163cdf0e10cSrcweir void SAL_CALL osl_systemPathGetFileNameOrLastDirectoryPart( 164cdf0e10cSrcweir const rtl_uString* pustrPath, 165cdf0e10cSrcweir rtl_uString** ppustrFileNameOrLastDirPart); 166cdf0e10cSrcweir 167cdf0e10cSrcweir 168cdf0e10cSrcweir /******************************************** 169cdf0e10cSrcweir osl_systemPathIsHiddenFileOrDirectoryEntry 170cdf0e10cSrcweir Returns sal_True if the last part of 171cdf0e10cSrcweir given system path is not '.' or '..' 172cdf0e10cSrcweir alone and starts with a '.' 173cdf0e10cSrcweir 174cdf0e10cSrcweir @param pustrPath [in] a system path, 175cdf0e10cSrcweir must not be NULL 176cdf0e10cSrcweir 177cdf0e10cSrcweir @returns sal_True if the last part of 178cdf0e10cSrcweir the given system path starts 179cdf0e10cSrcweir with '.' or sal_False the last 180cdf0e10cSrcweir part is '.' or '..' alone or 181cdf0e10cSrcweir doesn't start with a dot 182cdf0e10cSrcweir 183cdf0e10cSrcweir *********************************************/ 184cdf0e10cSrcweir 185cdf0e10cSrcweir sal_Bool SAL_CALL osl_systemPathIsHiddenFileOrDirectoryEntry( 186cdf0e10cSrcweir const rtl_uString* pustrPath); 187cdf0e10cSrcweir 188cdf0e10cSrcweir 189cdf0e10cSrcweir /************************************************ 190cdf0e10cSrcweir osl_systemPathIsLocalOrParentDirectoryEntry 191cdf0e10cSrcweir Returns sal_True if the last part of the given 192cdf0e10cSrcweir system path is the local directory entry '.' 193cdf0e10cSrcweir or the parent directory entry '..' 194cdf0e10cSrcweir 195cdf0e10cSrcweir @param pustrPath [in] a system path, 196cdf0e10cSrcweir must not be NULL 197cdf0e10cSrcweir 198cdf0e10cSrcweir @returns sal_True if the last part of the 199cdf0e10cSrcweir given system path is '.' or '..' 200cdf0e10cSrcweir else sal_False 201cdf0e10cSrcweir 202cdf0e10cSrcweir ************************************************/ 203cdf0e10cSrcweir 204cdf0e10cSrcweir sal_Bool SAL_CALL osl_systemPathIsLocalOrParentDirectoryEntry( 205cdf0e10cSrcweir const rtl_uString* pustrPath); 206cdf0e10cSrcweir 207cdf0e10cSrcweir 208cdf0e10cSrcweir /************************************************ 209cdf0e10cSrcweir osl_searchPath 210cdf0e10cSrcweir Searches for a file name or path name in all 211cdf0e10cSrcweir directories specified by a given path list. 212cdf0e10cSrcweir Symbolic links in the resulting path will not be 213cdf0e10cSrcweir resolved, it's up to the caller to do this. 214cdf0e10cSrcweir 215cdf0e10cSrcweir @param pustrFilePath [in] a file name or 216cdf0e10cSrcweir directory name to search for, the name must 217cdf0e10cSrcweir be provided as system path not as a file URL 218cdf0e10cSrcweir 219cdf0e10cSrcweir @param pustrSearchPathList [in] a ':' 220cdf0e10cSrcweir separated list of paths in which to search for 221cdf0e10cSrcweir the file or directory name 222cdf0e10cSrcweir 223cdf0e10cSrcweir @ppustrPathFound [out] on success receives the 224cdf0e10cSrcweir complete path of the file or directory found 225cdf0e10cSrcweir as a system path 226cdf0e10cSrcweir 227cdf0e10cSrcweir @returns sal_True if the specified file or 228cdf0e10cSrcweir directory was found else sal_False 229cdf0e10cSrcweir ***********************************************/ 230cdf0e10cSrcweir 231cdf0e10cSrcweir sal_Bool SAL_CALL osl_searchPath( 232cdf0e10cSrcweir const rtl_uString* pustrFilePath, 233cdf0e10cSrcweir const rtl_uString* pustrSearchPathList, 234cdf0e10cSrcweir rtl_uString** ppustrPathFound); 235cdf0e10cSrcweir 236cdf0e10cSrcweir 237cdf0e10cSrcweir #ifdef __cplusplus 238cdf0e10cSrcweir } 239cdf0e10cSrcweir #endif 240cdf0e10cSrcweir 241cdf0e10cSrcweir 242cdf0e10cSrcweir #endif /* #ifndef _OSL_PATH_HELPER_H_ */ 243cdf0e10cSrcweir 244