1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #ifndef _OSL_UUNXAPI_H_
34 #ifndef __OSL_SYSTEM_H__
42 #ifndef _RTL_USTRING_HXX_
43 #include <rtl/ustring.hxx>
46 #ifndef _OSL_THREAD_H_
47 #include <osl/thread.h>
51 #include <osl/detail/android-bootstrap.h>
54 //###########################
55 inline rtl::OString
OUStringToOString(const rtl_uString
* s
)
57 return rtl::OUStringToOString(
58 rtl::OUString(const_cast<rtl_uString
*>(s
)),
59 osl_getThreadTextEncoding());
62 //###########################
65 * Helper function for resolving Mac native alias files (not the same as unix alias files)
66 * and to return the resolved alias as rtl::OString
68 inline rtl::OString
macxp_resolveAliasAndConvert(const rtl_uString
* s
)
70 rtl::OString p
= OUStringToOString(s
);
71 sal_Char path
[PATH_MAX
];
72 if (p
.getLength() < PATH_MAX
)
74 strcpy(path
, p
.getStr());
75 macxp_resolveAlias(path
, PATH_MAX
);
76 p
= rtl::OString(path
);
82 //###########################
84 int access_u(const rtl_uString
* pustrPath
, int mode
)
86 #ifndef MACOSX // not MACOSX
87 rtl::OString fn
= OUStringToOString(pustrPath
);
89 if (strncmp(fn
.getStr(), "/assets", sizeof("/assets")-1) == 0 &&
90 (fn
.getStr()[sizeof("/assets")-1] == '\0' ||
91 fn
.getStr()[sizeof("/assets")-1] == '/'))
94 if (lo_apk_lstat(fn
.getStr(), &stat
) == -1)
104 return access(fn
.getStr(), mode
);
106 return access(macxp_resolveAliasAndConvert(pustrPath
).getStr(), mode
);
110 //#########################
112 sal_Bool
realpath_u(const rtl_uString
* pustrFileName
, rtl_uString
** ppustrResolvedName
)
114 #ifndef MACOSX // not MACOSX
115 rtl::OString fn
= OUStringToOString(pustrFileName
);
117 if (strncmp(fn
.getStr(), "/assets", sizeof("/assets")-1) == 0 &&
118 (fn
.getStr()[sizeof("/assets")-1] == '\0' ||
119 fn
.getStr()[sizeof("/assets")-1] == '/'))
121 if (access_u(pustrFileName
, F_OK
) == -1)
124 rtl_uString
silly(*pustrFileName
);
125 rtl_uString_assign(ppustrResolvedName
, &silly
);
131 rtl::OString fn
= macxp_resolveAliasAndConvert(pustrFileName
);
134 bool bRet
= realpath(fn
.getStr(), rp
);
138 rtl::OUString resolved
= rtl::OStringToOUString(
139 rtl::OString(static_cast<sal_Char
*>(rp
)),
140 osl_getThreadTextEncoding());
142 rtl_uString_assign(ppustrResolvedName
, resolved
.pData
);
147 //#########################
149 int stat_c(const char* cpPath
, struct stat
* buf
)
152 if (strncmp(cpPath
, "/assets", sizeof("/assets")-1) == 0 &&
153 (cpPath
[sizeof("/assets")-1] == '\0' ||
154 cpPath
[sizeof("/assets")-1] == '/'))
155 return lo_apk_lstat(cpPath
, buf
);
157 return stat(cpPath
, buf
);
160 //#########################
162 int lstat_c(const char* cpPath
, struct stat
* buf
)
165 if (strncmp(cpPath
, "/assets", sizeof("/assets")-1) == 0 &&
166 (cpPath
[sizeof("/assets")-1] == '\0' ||
167 cpPath
[sizeof("/assets")-1] == '/'))
168 return lo_apk_lstat(cpPath
, buf
);
170 return lstat(cpPath
, buf
);
173 //#########################
175 int lstat_u(const rtl_uString
* pustrPath
, struct stat
* buf
)
177 #ifndef MACOSX // not MACOSX
178 rtl::OString fn
= OUStringToOString(pustrPath
);
179 return lstat_c(fn
.getStr(), buf
);
181 return lstat(macxp_resolveAliasAndConvert(pustrPath
).getStr(), buf
);
185 //#########################
187 int mkdir_u(const rtl_uString
* path
, mode_t mode
)
189 return mkdir(OUStringToOString(path
).getStr(), mode
);
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */