1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: nippondir.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_testshl2.hxx"
35 #include<osl/file.hxx>
37 #include<osl/thread.hxx>
38 #include <tools/string.hxx>
40 // -----------------------------------------------------------------------------
41 // ---------------------------------- defines ----------------------------------
42 // -----------------------------------------------------------------------------
44 #define ASCII(x) OUString::createFromAscii(x)
52 ostream
& operator << (ostream
& out
, rtl::OUString
const& aStr
)
54 sal_Unicode
const* const pStr
= aStr
.getStr();
55 sal_Unicode
const* const pEnd
= pStr
+ aStr
.getLength();
56 for (sal_Unicode
const* p
= pStr
; p
< pEnd
; ++p
)
57 if (0 < *p
&& *p
< 127) // ASCII
60 out
<< "[\\u" << hex
<< *p
<< "]";
65 inline void operator <<= (::rtl::OUString
& _rUnicodeString
, const sal_Char
* _pAsciiString
)
67 _rUnicodeString
= ::rtl::OUString::createFromAscii(_pAsciiString
);
70 inline void operator <<= (::rtl::OUString
& _rUnicodeString
, const ::rtl::OString
& _rAsciiString
)
72 _rUnicodeString
<<= _rAsciiString
.getStr();
76 inline void operator <<= (Any& _rUnoValue, const sal_Char* _pAsciiString)
78 _rUnoValue <<= ::rtl::OUString::createFromAscii(_pAsciiString);
81 inline void operator <<= (Any& _rUnoValue, const ::rtl::OString& _rAsciiString)
83 _rUnoValue <<= _rAsciiString.getStr();
87 inline void operator <<= (::rtl::OString
& _rAsciiString
, ::rtl::OUString
const& _rUnicodeString
)
89 _rAsciiString
= rtl::OUStringToOString(_rUnicodeString
, RTL_TEXTENCODING_ASCII_US
).getStr();
91 // -----------------------------------------------------------------------------
95 rtl::OUString
createOSLErrorString(FileBase::RC eError
)
100 case osl_File_E_None
:
103 case osl_File_E_PERM
:
104 aRet
= ASCII("Operation not permitted");
107 case osl_File_E_NOENT
:
108 aRet
= ASCII("No such file or directory");
111 case osl_File_E_SRCH
:
112 aRet
= ASCII("unknown error: osl_File_E_SRCH");
115 case osl_File_E_INTR
:
116 aRet
= ASCII("function call was interrupted");
120 aRet
= ASCII("I/O error");
123 case osl_File_E_NXIO
:
124 aRet
= ASCII("No such device or address");
127 case osl_File_E_2BIG
:
128 aRet
= ASCII("unknown error: osl_File_E_2BIG");
131 case osl_File_E_NOEXEC
:
132 aRet
= ASCII("unknown error: osl_File_E_NOEXEC");
135 case osl_File_E_BADF
:
136 aRet
= ASCII("Bad file");
139 case osl_File_E_CHILD
:
140 aRet
= ASCII("unknown error: osl_File_E_CHILD");
143 case osl_File_E_AGAIN
:
144 aRet
= ASCII("Operation would block");
147 case osl_File_E_NOMEM
:
148 aRet
= ASCII("not enough memory for allocating structures");
151 case osl_File_E_ACCES
:
152 aRet
= ASCII("Permission denied");
155 case osl_File_E_FAULT
:
156 aRet
= ASCII("Bad address");
159 case osl_File_E_BUSY
:
160 aRet
= ASCII("Text file busy");
163 case osl_File_E_EXIST
:
164 aRet
= ASCII("File exists");
167 case osl_File_E_XDEV
:
168 aRet
= ASCII("unknown error: osl_File_E_XDEV");
171 case osl_File_E_NODEV
:
172 aRet
= ASCII("No such device");
175 case osl_File_E_NOTDIR
:
176 aRet
= ASCII("Not a directory");
179 case osl_File_E_ISDIR
:
180 aRet
= ASCII("Is a director");
183 case osl_File_E_INVAL
:
184 aRet
= ASCII("the format of the parameters was not valid");
187 case osl_File_E_NFILE
:
188 aRet
= ASCII("too many open files in the system");
191 case osl_File_E_MFILE
:
192 aRet
= ASCII("too many open files used by the process");
195 case osl_File_E_NOTTY
:
196 aRet
= ASCII("unknown error: osl_File_E_NOTTY");
199 case osl_File_E_FBIG
:
200 aRet
= ASCII("File too large");
203 case osl_File_E_NOSPC
:
204 aRet
= ASCII("No space left on device");
207 case osl_File_E_SPIPE
:
208 aRet
= ASCII("unknown error: osl_File_E_SPIPE");
211 case osl_File_E_ROFS
:
212 aRet
= ASCII("Read-only file system");
215 case osl_File_E_MLINK
:
216 aRet
= ASCII("Too many links");
219 case osl_File_E_PIPE
:
220 aRet
= ASCII("unknown error: osl_File_E_PIPE");
224 aRet
= ASCII("unknown error: osl_File_E_DOM");
227 case osl_File_E_RANGE
:
228 aRet
= ASCII("unknown error: osl_File_E_RANGE");
231 case osl_File_E_DEADLK
:
232 aRet
= ASCII("unknown error: osl_File_E_DEADLK");
235 case osl_File_E_NAMETOOLONG
:
236 aRet
= ASCII("File name too long");
239 case osl_File_E_NOLCK
:
240 aRet
= ASCII("No record locks available");
243 case osl_File_E_NOSYS
:
244 aRet
= ASCII("Function not implemente");
247 case osl_File_E_NOTEMPTY
:
248 aRet
= ASCII("Directory not empt");
251 case osl_File_E_LOOP
:
252 aRet
= ASCII("Too many symbolic links encountered");
255 case osl_File_E_ILSEQ
:
256 aRet
= ASCII("unknown error: osl_File_E_ILSEQ");
259 case osl_File_E_NOLINK
:
260 aRet
= ASCII("Link has been severed");
263 case osl_File_E_MULTIHOP
:
264 aRet
= ASCII("Multihop attempted");
267 case osl_File_E_USERS
:
268 aRet
= ASCII("unknown error: osl_File_E_USERS");
271 case osl_File_E_OVERFLOW
:
272 aRet
= ASCII("Value too large for defined data type");
275 /* unmapped error: always last entry in enum! */
276 case osl_File_E_invalidError
:
277 aRet
= ASCII("unmapped Error");
282 } // namespace FileHelper
285 #if (defined UNX) || (defined OS2)
286 void main( int argc
, char * argv
[] )
288 void _cdecl
main( int argc
, char * argv
[] )
292 OUString
aDirectory(OUString::createFromAscii("file:///C:/%E6%96%B0%E3%81%97%E3%81%84%E3%83%95%E3%82%A9%E3%83%AB%E3%83%80"));
293 // OUString aDirex(OUString::createFromAscii("file:///C:/%C2%90V%E2%80%9A%C2%B5%E2%80%9A%C2%A2%C6%92t%C6%92H%C6%92%E2%80%B9%C6%92_"));
295 osl::FileBase::RC eError
= osl::Directory::create(aDirectory
);
296 if (eError
!= osl::FileBase::E_None
)
298 OUString aUStr
= FileHelper::createOSLErrorString(eError
);
301 OSL_ENSURE(false, aStr
.getStr());
304 // OUString suSystemPath, aTmp;
305 // FileBase::RC aRC = FileBase::getSystemPathFromFileURL( aDirectory, suSystemPath );
307 // String suSystemPathAsString(suSystemPath);
308 // ByteString sSystemPath(suSystemPathAsString, osl_getThreadTextEncoding());
311 // ByteString sSystemPathNew = sSystemPath;
312 // UniString suSystemPathNew(sSystemPathNew, osl_getThreadTextEncoding());
313 // FileBase::RC aRC2 = FileBase::getFileURLFromSystemPath( suSystemPathNew, aTmp );
316 // aRC = FileBase::getSystemPathFromFileURL( aDirex, aTmp );
317 // aRC2 = FileBase::getFileURLFromSystemPath( aTmp, aTmp2 );