1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sal.hxx"
31 #ifndef _OSL_UUNXAPI_H_
35 #ifndef __OSL_SYSTEM_H__
43 #ifndef _RTL_USTRING_HXX_
44 #include <rtl/ustring.hxx>
47 #ifndef _OSL_THREAD_H_
48 #include <osl/thread.h>
51 //###########################
52 inline rtl::OString
OUStringToOString(const rtl_uString
* s
)
54 return rtl::OUStringToOString(
55 rtl::OUString(const_cast<rtl_uString
*>(s
)),
56 osl_getThreadTextEncoding());
59 //###########################
62 * Helper function for resolving Mac native alias files (not the same as unix alias files)
63 * and to return the resolved alias as rtl::OString
65 inline rtl::OString
macxp_resolveAliasAndConvert(const rtl_uString
* s
)
67 rtl::OString p
= OUStringToOString(s
);
68 sal_Char path
[PATH_MAX
];
69 if (p
.getLength() < PATH_MAX
)
71 strcpy(path
, p
.getStr());
72 macxp_resolveAlias(path
, PATH_MAX
);
73 p
= rtl::OString(path
);
79 //###########################
81 int access_u(const rtl_uString
* pustrPath
, int mode
)
83 #ifndef MACOSX // not MACOSX
84 return access(OUStringToOString(pustrPath
).getStr(), mode
);
86 return access(macxp_resolveAliasAndConvert(pustrPath
).getStr(), mode
);
90 //#########################
92 sal_Bool
realpath_u(const rtl_uString
* pustrFileName
, rtl_uString
** ppustrResolvedName
)
94 #ifndef MACOSX // not MACOSX
95 rtl::OString fn
= OUStringToOString(pustrFileName
);
97 rtl::OString fn
= macxp_resolveAliasAndConvert(pustrFileName
);
100 bool bRet
= realpath(fn
.getStr(), rp
);
104 rtl::OUString resolved
= rtl::OStringToOUString(
105 rtl::OString(static_cast<sal_Char
*>(rp
)),
106 osl_getThreadTextEncoding());
108 rtl_uString_assign(ppustrResolvedName
, resolved
.pData
);
113 //#########################
115 int lstat_u(const rtl_uString
* pustrPath
, struct stat
* buf
)
117 #ifndef MACOSX // not MACOSX
118 return lstat(OUStringToOString(pustrPath
).getStr(), buf
);
120 return lstat(macxp_resolveAliasAndConvert(pustrPath
).getStr(), buf
);
124 //#########################
126 int mkdir_u(const rtl_uString
* path
, mode_t mode
)
128 return mkdir(OUStringToOString(path
).getStr(), mode
);