update dev300-m58
[ooovba.git] / testshl2 / workben / garbage_dump / nippondir.cxx
blob6afb1bc2d99f86b187fbaee9adb5b522f14dd842
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: nippondir.cxx,v $
10 * $Revision: 1.5 $
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"
34 #include <iostream>
35 #include<osl/file.hxx>
37 #include<osl/thread.hxx>
38 #include <tools/string.hxx>
40 // -----------------------------------------------------------------------------
41 // ---------------------------------- defines ----------------------------------
42 // -----------------------------------------------------------------------------
43 #ifndef ASCII
44 #define ASCII(x) OUString::createFromAscii(x)
45 #endif
47 using namespace osl;
48 using namespace rtl;
49 using namespace std;
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
58 out << char(*p);
59 else
60 out << "[\\u" << hex << *p << "]";
61 return out;
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 // -----------------------------------------------------------------------------
93 namespace FileHelper
95 rtl::OUString createOSLErrorString(FileBase::RC eError)
97 rtl::OUString aRet;
98 switch(eError)
100 case osl_File_E_None:
101 break;
103 case osl_File_E_PERM:
104 aRet = ASCII("Operation not permitted");
105 break;
107 case osl_File_E_NOENT:
108 aRet = ASCII("No such file or directory");
109 break;
111 case osl_File_E_SRCH:
112 aRet = ASCII("unknown error: osl_File_E_SRCH");
113 break;
115 case osl_File_E_INTR:
116 aRet = ASCII("function call was interrupted");
117 break;
119 case osl_File_E_IO:
120 aRet = ASCII("I/O error");
121 break;
123 case osl_File_E_NXIO:
124 aRet = ASCII("No such device or address");
125 break;
127 case osl_File_E_2BIG:
128 aRet = ASCII("unknown error: osl_File_E_2BIG");
129 break;
131 case osl_File_E_NOEXEC:
132 aRet = ASCII("unknown error: osl_File_E_NOEXEC");
133 break;
135 case osl_File_E_BADF:
136 aRet = ASCII("Bad file");
137 break;
139 case osl_File_E_CHILD:
140 aRet = ASCII("unknown error: osl_File_E_CHILD");
141 break;
143 case osl_File_E_AGAIN:
144 aRet = ASCII("Operation would block");
145 break;
147 case osl_File_E_NOMEM:
148 aRet = ASCII("not enough memory for allocating structures");
149 break;
151 case osl_File_E_ACCES:
152 aRet = ASCII("Permission denied");
153 break;
155 case osl_File_E_FAULT:
156 aRet = ASCII("Bad address");
157 break;
159 case osl_File_E_BUSY:
160 aRet = ASCII("Text file busy");
161 break;
163 case osl_File_E_EXIST:
164 aRet = ASCII("File exists");
165 break;
167 case osl_File_E_XDEV:
168 aRet = ASCII("unknown error: osl_File_E_XDEV");
169 break;
171 case osl_File_E_NODEV:
172 aRet = ASCII("No such device");
173 break;
175 case osl_File_E_NOTDIR:
176 aRet = ASCII("Not a directory");
177 break;
179 case osl_File_E_ISDIR:
180 aRet = ASCII("Is a director");
181 break;
183 case osl_File_E_INVAL:
184 aRet = ASCII("the format of the parameters was not valid");
185 break;
187 case osl_File_E_NFILE:
188 aRet = ASCII("too many open files in the system");
189 break;
191 case osl_File_E_MFILE:
192 aRet = ASCII("too many open files used by the process");
193 break;
195 case osl_File_E_NOTTY:
196 aRet = ASCII("unknown error: osl_File_E_NOTTY");
197 break;
199 case osl_File_E_FBIG:
200 aRet = ASCII("File too large");
201 break;
203 case osl_File_E_NOSPC:
204 aRet = ASCII("No space left on device");
205 break;
207 case osl_File_E_SPIPE:
208 aRet = ASCII("unknown error: osl_File_E_SPIPE");
209 break;
211 case osl_File_E_ROFS:
212 aRet = ASCII("Read-only file system");
213 break;
215 case osl_File_E_MLINK:
216 aRet = ASCII("Too many links");
217 break;
219 case osl_File_E_PIPE:
220 aRet = ASCII("unknown error: osl_File_E_PIPE");
221 break;
223 case osl_File_E_DOM:
224 aRet = ASCII("unknown error: osl_File_E_DOM");
225 break;
227 case osl_File_E_RANGE:
228 aRet = ASCII("unknown error: osl_File_E_RANGE");
229 break;
231 case osl_File_E_DEADLK:
232 aRet = ASCII("unknown error: osl_File_E_DEADLK");
233 break;
235 case osl_File_E_NAMETOOLONG:
236 aRet = ASCII("File name too long");
237 break;
239 case osl_File_E_NOLCK:
240 aRet = ASCII("No record locks available");
241 break;
243 case osl_File_E_NOSYS:
244 aRet = ASCII("Function not implemente");
245 break;
247 case osl_File_E_NOTEMPTY:
248 aRet = ASCII("Directory not empt");
249 break;
251 case osl_File_E_LOOP:
252 aRet = ASCII("Too many symbolic links encountered");
253 break;
255 case osl_File_E_ILSEQ:
256 aRet = ASCII("unknown error: osl_File_E_ILSEQ");
257 break;
259 case osl_File_E_NOLINK:
260 aRet = ASCII("Link has been severed");
261 break;
263 case osl_File_E_MULTIHOP:
264 aRet = ASCII("Multihop attempted");
265 break;
267 case osl_File_E_USERS:
268 aRet = ASCII("unknown error: osl_File_E_USERS");
269 break;
271 case osl_File_E_OVERFLOW:
272 aRet = ASCII("Value too large for defined data type");
273 break;
275 /* unmapped error: always last entry in enum! */
276 case osl_File_E_invalidError:
277 aRet = ASCII("unmapped Error");
278 break;
280 return aRet;
282 } // namespace FileHelper
285 #if (defined UNX) || (defined OS2)
286 void main( int argc, char * argv[] )
287 #else
288 void _cdecl main( int argc, char * argv[] )
289 #endif
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);
299 OString aStr;
300 aStr <<= aUStr;
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 );