1*87d2adbcSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*87d2adbcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*87d2adbcSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*87d2adbcSAndrew Rist * distributed with this work for additional information 6*87d2adbcSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*87d2adbcSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*87d2adbcSAndrew Rist * "License"); you may not use this file except in compliance 9*87d2adbcSAndrew Rist * with the License. You may obtain a copy of the License at 10*87d2adbcSAndrew Rist * 11*87d2adbcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*87d2adbcSAndrew Rist * 13*87d2adbcSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*87d2adbcSAndrew Rist * software distributed under the License is distributed on an 15*87d2adbcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*87d2adbcSAndrew Rist * KIND, either express or implied. See the License for the 17*87d2adbcSAndrew Rist * specific language governing permissions and limitations 18*87d2adbcSAndrew Rist * under the License. 19*87d2adbcSAndrew Rist * 20*87d2adbcSAndrew Rist *************************************************************/ 21*87d2adbcSAndrew Rist 22*87d2adbcSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sal.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifndef _OSL_UUNXAPI_H_ 28cdf0e10cSrcweir #include "uunxapi.h" 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir 31cdf0e10cSrcweir #ifndef __OSL_SYSTEM_H__ 32cdf0e10cSrcweir #include "system.h" 33cdf0e10cSrcweir #endif 34cdf0e10cSrcweir 35cdf0e10cSrcweir #ifndef _LIMITS_H 36cdf0e10cSrcweir #include <limits.h> 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir 39cdf0e10cSrcweir #ifndef _RTL_USTRING_HXX_ 40cdf0e10cSrcweir #include <rtl/ustring.hxx> 41cdf0e10cSrcweir #endif 42cdf0e10cSrcweir 43cdf0e10cSrcweir #ifndef _OSL_THREAD_H_ 44cdf0e10cSrcweir #include <osl/thread.h> 45cdf0e10cSrcweir #endif 46cdf0e10cSrcweir 47cdf0e10cSrcweir //########################### OUStringToOString(const rtl_uString * s)48cdf0e10cSrcweir inline rtl::OString OUStringToOString(const rtl_uString* s) 49cdf0e10cSrcweir { 50cdf0e10cSrcweir return rtl::OUStringToOString( 51cdf0e10cSrcweir rtl::OUString(const_cast<rtl_uString*>(s)), 52cdf0e10cSrcweir osl_getThreadTextEncoding()); 53cdf0e10cSrcweir } 54cdf0e10cSrcweir 55cdf0e10cSrcweir //########################### 56cdf0e10cSrcweir #ifdef MACOSX 57cdf0e10cSrcweir /* 58cdf0e10cSrcweir * Helper function for resolving Mac native alias files (not the same as unix alias files) 59cdf0e10cSrcweir * and to return the resolved alias as rtl::OString 60cdf0e10cSrcweir */ macxp_resolveAliasAndConvert(const rtl_uString * s)61cdf0e10cSrcweir inline rtl::OString macxp_resolveAliasAndConvert(const rtl_uString* s) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir rtl::OString p = OUStringToOString(s); 64cdf0e10cSrcweir sal_Char path[PATH_MAX]; 65cdf0e10cSrcweir if (p.getLength() < PATH_MAX) 66cdf0e10cSrcweir { 67cdf0e10cSrcweir strcpy(path, p.getStr()); 68cdf0e10cSrcweir macxp_resolveAlias(path, PATH_MAX); 69cdf0e10cSrcweir p = rtl::OString(path); 70cdf0e10cSrcweir } 71cdf0e10cSrcweir return p; 72cdf0e10cSrcweir } 73cdf0e10cSrcweir #endif /* MACOSX */ 74cdf0e10cSrcweir 75cdf0e10cSrcweir //########################### 76cdf0e10cSrcweir //access_u access_u(const rtl_uString * pustrPath,int mode)77cdf0e10cSrcweir int access_u(const rtl_uString* pustrPath, int mode) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir #ifndef MACOSX // not MACOSX 80cdf0e10cSrcweir return access(OUStringToOString(pustrPath).getStr(), mode); 81cdf0e10cSrcweir #else 82cdf0e10cSrcweir return access(macxp_resolveAliasAndConvert(pustrPath).getStr(), mode); 83cdf0e10cSrcweir #endif 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir //######################### 87cdf0e10cSrcweir //realpath_u realpath_u(const rtl_uString * pustrFileName,rtl_uString ** ppustrResolvedName)88cdf0e10cSrcweir sal_Bool realpath_u(const rtl_uString* pustrFileName, rtl_uString** ppustrResolvedName) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir #ifndef MACOSX // not MACOSX 91cdf0e10cSrcweir rtl::OString fn = OUStringToOString(pustrFileName); 92cdf0e10cSrcweir #else 93cdf0e10cSrcweir rtl::OString fn = macxp_resolveAliasAndConvert(pustrFileName); 94cdf0e10cSrcweir #endif 95cdf0e10cSrcweir char rp[PATH_MAX]; 96cdf0e10cSrcweir bool bRet = realpath(fn.getStr(), rp); 97cdf0e10cSrcweir 98cdf0e10cSrcweir if (bRet) 99cdf0e10cSrcweir { 100cdf0e10cSrcweir rtl::OUString resolved = rtl::OStringToOUString( 101cdf0e10cSrcweir rtl::OString(static_cast<sal_Char*>(rp)), 102cdf0e10cSrcweir osl_getThreadTextEncoding()); 103cdf0e10cSrcweir 104cdf0e10cSrcweir rtl_uString_assign(ppustrResolvedName, resolved.pData); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir return bRet; 107cdf0e10cSrcweir } 108cdf0e10cSrcweir 109cdf0e10cSrcweir //######################### 110cdf0e10cSrcweir //lstat_u lstat_u(const rtl_uString * pustrPath,struct stat * buf)111cdf0e10cSrcweir int lstat_u(const rtl_uString* pustrPath, struct stat* buf) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir #ifndef MACOSX // not MACOSX 114cdf0e10cSrcweir return lstat(OUStringToOString(pustrPath).getStr(), buf); 115cdf0e10cSrcweir #else 116cdf0e10cSrcweir return lstat(macxp_resolveAliasAndConvert(pustrPath).getStr(), buf); 117cdf0e10cSrcweir #endif 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir //######################### 121cdf0e10cSrcweir // @see mkdir mkdir_u(const rtl_uString * path,mode_t mode)122cdf0e10cSrcweir int mkdir_u(const rtl_uString* path, mode_t mode) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir return mkdir(OUStringToOString(path).getStr(), mode); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127