xref: /aoo41x/main/sal/osl/os2/uunxapi.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28  #ifndef _LIMITS_H
29  #include <limits.h>
30  #endif
31 
32  #ifndef _RTL_USTRING_HXX_
33  #include <rtl/ustring.hxx>
34  #endif
35 
36  #ifndef _OSL_THREAD_H_
37  #include <osl/thread.h>
38  #endif
39 
40  #ifndef _OSL_UUNXAPI_HXX_
41  #include "uunxapi.hxx"
42  #endif
43 
44  //###########################
45  //access_u
46  int access_u(const rtl_uString* pustrPath, int mode)
47  {
48 	return access(OUStringToOString(pustrPath).getStr(), mode);
49  }
50 
51  //#########################
52  //realpath_u
53  sal_Bool realpath_u(const rtl_uString* pustrFileName, rtl_uString** ppustrResolvedName)
54  {
55  	rtl::OString fn = rtl::OUStringToOString(
56 		rtl::OUString(const_cast<rtl_uString*>(pustrFileName)),
57 		osl_getThreadTextEncoding());
58 
59 	char  rp[PATH_MAX];
60 	bool  bRet = realpath(fn.getStr(), rp);
61 
62 	if (bRet)
63 	{
64 		rtl::OUString resolved = rtl::OStringToOUString(
65 			rtl::OString(static_cast<sal_Char*>(rp)),
66 			osl_getThreadTextEncoding());
67 
68 		rtl_uString_assign(ppustrResolvedName, resolved.pData);
69 	}
70 	return bRet;
71  }
72 
73  //#########################
74  //lstat_u
75   int lstat_u(const rtl_uString* pustrPath, struct stat* buf)
76  {
77 	return lstat(OUStringToOString(pustrPath).getStr(), buf);
78  }
79 
80  //#########################
81  // @see mkdir
82  int mkdir_u(const rtl_uString* path, mode_t mode)
83  {
84     return mkdir(OUStringToOString(path).getStr(), mode);
85  }
86 
87