xref: /aoo4110/main/sal/osl/os2/uunxapi.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24  #ifndef _LIMITS_H
25  #include <limits.h>
26  #endif
27 
28  #ifndef _RTL_USTRING_HXX_
29  #include <rtl/ustring.hxx>
30  #endif
31 
32  #ifndef _OSL_THREAD_H_
33  #include <osl/thread.h>
34  #endif
35 
36  #ifndef _OSL_UUNXAPI_HXX_
37  #include "uunxapi.hxx"
38  #endif
39 
40  //###########################
41  //access_u
access_u(const rtl_uString * pustrPath,int mode)42  int access_u(const rtl_uString* pustrPath, int mode)
43  {
44 	return access(OUStringToOString(pustrPath).getStr(), mode);
45  }
46 
47  //#########################
48  //realpath_u
realpath_u(const rtl_uString * pustrFileName,rtl_uString ** ppustrResolvedName)49  sal_Bool realpath_u(const rtl_uString* pustrFileName, rtl_uString** ppustrResolvedName)
50  {
51  	rtl::OString fn = rtl::OUStringToOString(
52 		rtl::OUString(const_cast<rtl_uString*>(pustrFileName)),
53 		osl_getThreadTextEncoding());
54 
55 	char  rp[PATH_MAX];
56 	bool  bRet = realpath(fn.getStr(), rp);
57 
58 	if (bRet)
59 	{
60 		rtl::OUString resolved = rtl::OStringToOUString(
61 			rtl::OString(static_cast<sal_Char*>(rp)),
62 			osl_getThreadTextEncoding());
63 
64 		rtl_uString_assign(ppustrResolvedName, resolved.pData);
65 	}
66 	return bRet;
67  }
68 
69  //#########################
70  //lstat_u
lstat_u(const rtl_uString * pustrPath,struct stat * buf)71   int lstat_u(const rtl_uString* pustrPath, struct stat* buf)
72  {
73 	return lstat(OUStringToOString(pustrPath).getStr(), buf);
74  }
75 
76  //#########################
77  // @see mkdir
mkdir_u(const rtl_uString * path,mode_t mode)78  int mkdir_u(const rtl_uString* path, mode_t mode)
79  {
80     return mkdir(OUStringToOString(path).getStr(), mode);
81  }
82 
83