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