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