summaryrefslogtreecommitdiff
path: root/sal/workben/testfile.cxx
blob: 3b3590f3bbce2dcb00fcdabc250b44574045afe0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#define UNICODE

#include <osl/file.hxx>
#include <osl/process.h>
#include <osl/time.h>
#include <rtl/alloc.h>
#include <rtl/ustring.hxx>
#include <stdio.h>
#include <string.h>
#include <time.h>

#ifdef UNX
#include <wchar.h>
#endif

#ifdef _WIN32
#include <windows.h>
#endif

using namespace osl;

rtl::OUString   root;

rtl::OUString   dir1;
rtl::OUString   dir2;
rtl::OUString   dir_on_server;
rtl::OUString   dir_not_exist;
rtl::OUString   dir_not_exist_on_server;
rtl::OUString   dir_wrong_semantic;

rtl::OUString   file1;
rtl::OUString   file2;
rtl::OUString   file3;
rtl::OUString   file_on_server;
rtl::OUString   file_not_exist;

void print_error(const ::rtl::OString& str, FileBase::RC rc);

void PressKey()
{
    printf("\nPress Return !\n");
    getchar();
}

void printFileName(const ::rtl::OUString& str)
{
    rtl::OString aString;

    aString = rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US );

    printf( "%s", aString.getStr() );

    return;
}

// Initialization

sal_Bool testLineBreak( sal_Char *pCount , sal_uInt64 nLen , sal_uInt32 *cLineBreak )
{
    sal_Bool fSuccess=sal_False;
    *cLineBreak=0;

    if (nLen==0)
        return fSuccess;

    if ( *pCount==13 )
    {
        if (nLen>=1 && *(pCount+1)==10)
            *cLineBreak=2;
        else
            *cLineBreak=1;

        if (nLen>=2 && *(pCount+2)==10)
            (*cLineBreak)++;

        fSuccess=sal_True;
    }
    else if ( *pCount==10 )
    {
        *cLineBreak=1;
        fSuccess=sal_True;
    }

    return fSuccess;
}

// Initialization

sal_Bool Initialize()
{
    DirectoryItem   aItem;
    FileStatus      aStatus( osl_FileStatus_Mask_All );
    rtl_uString     *strExeFileURL=NULL;
    oslProcessError ProcessError;

    rtl::OUString   iniFileURL;
    File            *pFile;

    FileBase::RC    rc;

    sal_uInt64      uBytesRequested;
    sal_uInt64      uBytesRead;
    sal_Char        *pBuffer;
    sal_Char        *pBegin;
    sal_Char        *pCount;

    rtl::OUString   dir[12];

    // Open to the ini-file

    ProcessError=osl_getExecutableFile(&strExeFileURL);

    if ( ProcessError == osl_Process_E_None)
    {
        sal_Unicode *pExeFileCount=rtl_uString_getStr(strExeFileURL)+rtl_uString_getLength(strExeFileURL);

        // Search for the last slash in the Path
        while (*pExeFileCount!=L'/' && pExeFileCount>rtl_uString_getStr(strExeFileURL))
            pExeFileCount--;

        // iniFileURL = strExeFileURL without the filename of the exe-File
        iniFileURL=rtl::OUString( rtl_uString_getStr(strExeFileURL) ,(int) (pExeFileCount-rtl_uString_getStr(strExeFileURL)) );

        // add "/testfile.ini" to iniFileURL
        iniFileURL+=rtl::OUString("/testfile.ini");

        // Open the ini-File
        pFile=new File( iniFileURL );
        rc=pFile->open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write );
        if ( rc!=FileBase::E_None )
        {
            rtl_uString_release(strExeFileURL);
            return sal_False;
        }
    }
    else
    {
        rtl_uString_release(strExeFileURL);
        return sal_False;
    }

    // Get filesize of the ini-File

    rc=DirectoryItem::get( iniFileURL, aItem );
    if ( rc!=FileBase::E_None )
        return sal_False;

    rc=aItem.getFileStatus( aStatus );
    if ( rc!=FileBase::E_None )
        return sal_False;

    uBytesRequested=aStatus.getFileSize();

    // read ini-File
    rc=pFile->setPos( osl_Pos_Absolut, 0 );
    pBuffer=(sal_Char*) rtl_allocateMemory( (sal_uInt32) (uBytesRequested+1)*sizeof(sal_Char) );
    memset( pBuffer, 0, (sal_uInt32)(uBytesRequested+1)*sizeof(sal_Char) );

    rc=pFile->read( pBuffer , uBytesRequested , uBytesRead );
    if ( rc!=FileBase::E_None )
        return sal_False;

    pBegin=pBuffer;
    pCount=pBegin;

    for ( int i=0 ; i<12 ; i++ )
    {
        sal_uInt32      cLineBrake=0;
        while ( (static_cast<sal_uInt64>(pCount-pBuffer) < uBytesRead) && *pCount!='=')
            pCount++;

        pCount++;
        pBegin=pCount;

        while ( (static_cast<sal_uInt64>(pCount-pBuffer) < uBytesRead) && !testLineBreak(pCount,uBytesRead-(pCount-pBuffer), &cLineBrake))
            pCount++;

        dir[i]=rtl::OUString(pBegin, pCount-pBegin, RTL_TEXTENCODING_ASCII_US);

        pCount+=cLineBrake;
        pBegin=pCount;
    }

    root=rtl::OUString(dir[0]);
    dir1=rtl::OUString(dir[1]);
    dir2=rtl::OUString(dir[2]);
    dir_on_server=rtl::OUString(dir[3]);
    dir_not_exist=rtl::OUString(dir[4]);
    dir_not_exist_on_server=rtl::OUString(dir[5]);
    dir_wrong_semantic=rtl::OUString(dir[6]);

    file1=rtl::OUString(dir[7]);
    file2=rtl::OUString(dir[8]);
    file3=rtl::OUString(dir[9]);
    file_on_server=rtl::OUString(dir[10]);
    file_not_exist=rtl::OUString(dir[11]);

    // close the ini-file
    rc=pFile->close();

    rtl_freeMemory( pBuffer );

    // Create directories
    rc=Directory::create( dir1 );
    if ( rc!=FileBase::E_None )
        return sal_False;

    rc=Directory::create( dir2 );
    if ( rc!=FileBase::E_None )
        return sal_False;

    rc=Directory::create( dir_on_server );
    if ( rc!=FileBase::E_None )
        return sal_False;

    pFile=new File( file1 );
    rc=pFile->open( osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );
    if ( rc!=FileBase::E_None )
        return sal_False;
    rc=pFile->close();
    delete pFile;

    pFile=new File( file2 );
    rc=pFile->open( osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );
    if ( rc!=FileBase::E_None )
        return sal_False;
    rc=pFile->close();
    delete pFile;

    pFile=new File( file_on_server );
    rc=pFile->open( osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );
    if ( rc!=FileBase::E_None )
        return sal_False;
    rc=pFile->close();
    delete pFile;

    return sal_True;
}

// Shutdown

sal_Bool Shutdown()
{
    sal_Bool        fSuccess=sal_True;
    FileBase::RC    rc;
    File            *pFile;

    // remove created files

    pFile=new File( file1 );
    rc=pFile->remove( file1 );
    if ( rc!=FileBase::E_None )
        fSuccess=sal_False;
    delete pFile;

    pFile=new File( file2 );
    rc=pFile->remove( file2 );
    if ( rc!=FileBase::E_None )
        fSuccess=sal_False;
    delete pFile;

    // remove created directories

    rc=Directory::remove( dir1 );
    if ( rc!=FileBase::E_None )
        fSuccess=sal_False;

    rc=Directory::remove( dir2 );
    if ( rc!=FileBase::E_None )
        fSuccess=sal_False;

    // remove created file on the server

    pFile=new File( file_on_server );
    rc=pFile->remove( file_on_server );
    if ( rc!=FileBase::E_None )
        fSuccess=sal_False;
    delete pFile;

    // remove created directory on the server

    rc=Directory::remove( dir_on_server );
    if ( rc!=FileBase::E_None )
        fSuccess=sal_False;

    return fSuccess;
}

// helper functions

// Show FileType
void showFileType( FileStatus::Type aType )
{
    if ( aType==FileStatus::Directory )
        printf( "FileType: Directory \n" );
    else if ( aType==FileStatus::Volume )
        printf( "FileType: Volume \n" );
    else if ( aType==FileStatus::Regular )
        printf( "FileType: Regular \n" );
    else if ( aType==FileStatus::Unknown )
        printf( "FileType: Unknown \n" );

}

// Show Attributes
void showAttributes( sal_uInt64 uAttributes )
{
    if ( uAttributes==0 )
        printf( "No Attributes \n" );
    if ( uAttributes & osl_File_Attribute_ReadOnly )
        printf( "Attribute: ReadOnly \n" );
    if ( uAttributes & osl_File_Attribute_Hidden )
        printf( "Attribute: Hidden \n" );
    if ( uAttributes & osl_File_Attribute_Executable )
        printf( "Attribute: Executable \n");
    if ( uAttributes & osl_File_Attribute_GrpWrite )
        printf( "Attribute: GrpWrite \n");
    if ( uAttributes & osl_File_Attribute_GrpRead )
        printf( "Attribute: GrpRead \n" );
    if ( uAttributes & osl_File_Attribute_GrpExe )
        printf( "Attribute: GrpExe \n" );
    if ( uAttributes & osl_File_Attribute_OwnWrite )
        printf( "Attribute: OwnWrite \n");
    if ( uAttributes & osl_File_Attribute_OwnRead )
        printf( "Attribute: OwnRead \n" );
    if ( uAttributes & osl_File_Attribute_OwnExe )
        printf( "Attribute: OwnExe \n" );
    if ( uAttributes & osl_File_Attribute_OthWrite )
        printf( "Attribute: OthWrite \n" );
    if ( uAttributes & osl_File_Attribute_OthRead )
        printf( "Attribute: OthRead \n");
    if ( uAttributes & osl_File_Attribute_OthExe )
        printf( "Attribute: OthExe \n" );

    return;
}

// Show Time
void showTime( TimeValue aTime )
{
    TimeValue   aLocalTimeVal, aSystemTimeVal , aSysTimeVal;
    oslDateTime aDateTime, aSystemTime;

    if ( osl_getLocalTimeFromSystemTime( &aTime, &aLocalTimeVal ) )
    {
        if ( osl_getDateTimeFromTimeValue( &aLocalTimeVal, &aDateTime ) )
        {
            printf("\t%02i.%02i.%4i , %02i.%02i.%02i Uhr\n", aDateTime.Day, aDateTime.Month, aDateTime.Year, aDateTime.Hours, aDateTime.Minutes, aDateTime.Seconds);
        }
        else
            printf("Error !\n");
    }

    if ( osl_getDateTimeFromTimeValue( &aTime, &aSystemTime ) )
    {
        printf("SystemTime: \t\t%02i.%02i.%4i , %02i.%02i.%02i Uhr\n", aSystemTime.Day, aSystemTime.Month, aSystemTime.Year, aSystemTime.Hours, aSystemTime.Minutes, aSystemTime.Seconds);
    }
    else
        printf("Error !\n");

    //Verify

    if ( osl_getTimeValueFromDateTime( &aSystemTime, &aSystemTimeVal ) )
    {
        if ( ( aSystemTimeVal.Seconds == aTime.Seconds ) && ( aSystemTimeVal.Nanosec == aTime.Nanosec ))
            printf ("Verify : TimeValue : ok! \n");
        else
        {
            printf ("Verify : TimeValue : Error! \n");
            printf ("aTime : %u \n", aTime.Seconds);
            printf ("aSystemTimeVal : %u \n", aSystemTimeVal.Seconds);
        }
    }
    else
        printf ("Verify : TimeValue : Error! \n");

    if ( osl_getSystemTimeFromLocalTime( &aLocalTimeVal , &aSysTimeVal ) )
    {
        if ( ( aSysTimeVal.Seconds == aTime.Seconds ) && ( aSysTimeVal.Nanosec == aTime.Nanosec ))
            printf ("Verify : SystemTime : ok! \n");
        else
        {
            printf ("Verify : SystemTime : Error! \n");
            printf ("aTime : %u\n", aTime.Seconds);
            printf ("aSystemTimeVal : %u\n", aSysTimeVal.Seconds);
        }
    }
    else
        printf ("Verify : SystemTime : Error! \n");

    return;
}

TimeValue getSystemTime()
{
    TimeValue   aTime;
    time_t ltime;

    time( &ltime );

    aTime.Seconds = ltime;
    aTime.Nanosec = 0;

    return aTime;
}

// DirectoryOpenAndCloseTest

void DirectoryOpenAndCloseTest()
{
    FileBase::RC    rc;
    Directory   *pDir;

    printf( "--------------------------------------------\n");
    printf( "Directory-Open-And-Close-Test\n");
    printf( "--------------------------------------------\n\n");

    // open an existing directory

    pDir=new Directory( dir1 );
    printf( "Open an existing directory: ");
    printFileName( dir1 );
    printf( "\n" );

    rc= pDir->open();
    print_error( rtl::OString( "Open Directory" ), rc );

    if ( pDir->isOpen() )
    {
        print_error( rtl::OString( "Directory is Open" ), rc );
    }

    // Close Directory
    rc=pDir->close();
    print_error( rtl::OString( "Close Directory" ), rc );

    delete pDir;
    printf( "\n" );

    // open a not existing directory

    pDir=new Directory( dir_not_exist );

    printf( "Open a not existing directory: ");
    printFileName( dir_not_exist );
    printf( "\n" );

    rc= pDir->open();

    print_error( rtl::OString( "Open Directory" ), rc );

    delete pDir;

    printf( "\n" );

    // open a directory with a wrong semantic

    pDir=new Directory( dir_wrong_semantic );

    printf( "Open a directory with a wrong semantic: ");
    printFileName( dir_wrong_semantic );
    printf( "\n" );

    rc= pDir->open();
    print_error( rtl::OString( "Open Directory" ), rc );

    delete pDir;

    printf( "\n" );

    // open an existing directory on a server

    pDir=new Directory( dir_on_server );

    printf( "Open an existing directory on a server: ");
    printFileName( dir_on_server );
    printf( "\n" );

    rc= pDir->open();
    print_error( rtl::OString( "Open Directory" ), rc );

    // Close Directory
    rc=pDir->close();
    print_error( rtl::OString( "Close Directory" ), rc );

    delete pDir;
    printf( "\n" );

    // open a not existing directory on a server

    pDir=new Directory( dir_not_exist_on_server );

    printf( "Open a not existing directory on a server: ");
    printFileName( dir_not_exist_on_server );
    printf( "\n" );

    rc= pDir->open();
    print_error( rtl::OString( "Open Directory" ), rc );

    delete pDir;
    printf( "\n" );

    // Close a not existing directory

    pDir=new Directory( dir_not_exist );
    printf( "Close a not existing directory: ");
    printFileName( dir_not_exist );
    printf( "\n" );

    rc=pDir->close();
    print_error( rtl::OString( "Close Directory" ), rc );

    PressKey();
    return;

}

// DirectoryCreateAndRemoveTest

void DirectoryCreateAndRemoveTest()
{
    FileBase::RC    rc,rc1;
    Directory   *pDir;

    printf( "--------------------------------------------\n" );
    printf( "Directory-Create-And-Remove-Test\n" );
    printf( "--------------------------------------------\n\n" );

    // Create directory

    printf( "Create a not existing directory: ");
    printFileName( dir_not_exist );
    printf( "\n" );

    rc=Directory::create( dir_not_exist) ;
    print_error( rtl::OString( "Create Directory" ), rc );

    // Verify
    pDir=new Directory( dir_not_exist );

    rc= pDir->open();
    print_error( rtl::OString( "Verify" ), rc );
    pDir->close();
    delete pDir;

    printf( "\n" );

    // Create a directory on a server

    printf( "Create a not existing directory on a server: ");
    printFileName( dir_not_exist_on_server );
    printf( "\n" );

    rc=Directory::create( dir_not_exist_on_server );
    print_error( rtl::OString( "Create Directory" ), rc );

    // Verify
    pDir=new Directory( dir_not_exist_on_server );
    rc= pDir->open();
    print_error( rtl::OString( "Verify" ), rc );
    pDir->close();
    delete pDir;

    printf( "\n" );

    // Remove Directories

    printf( "Remove the created directories: \n" );

    rc=Directory::remove( dir_not_exist );

    rc1=Directory::remove( dir_not_exist_on_server );

    if ( rc==FileBase::E_None && rc1==FileBase::E_None )
        print_error( rtl::OString( "Remove Directories" ), FileBase::E_None );
    else if ( rc!=FileBase::E_None )
        print_error( rtl::OString( "Remove local Directory" ),rc );
    else
        print_error( rtl::OString( "Remove Directory on a server" ),rc1 );

    printf( "\n" );

    // Remove a not existing directory

    printf( "Remove a not existing directory: ");
    printFileName( dir_not_exist );
    printf( "\n" );

    rc=Directory::remove( dir_not_exist );
    print_error( rtl::OString( "Remove" ),rc );

    PressKey();
    return;
}

// FileOpenAndCloseTest

static void FileOpenAndCloseTest()
{
    FileBase::RC    rc;

    printf( "--------------------------------------------\n" );
    printf( "File-Open-And-Close-Test\n" );
    printf( "--------------------------------------------\n\n" );

    File    *pFile;

    pFile=new File( file1 );

    printf( "Open an existing file: ");
    printFileName( file1 );
    printf( "\n" );

    // open an existing file (Read)

    rc=pFile->open( osl_File_OpenFlag_Read );
    print_error( rtl::OString( "Open File (Read)" ), rc );

    // close the file

    rc=pFile->close();
    print_error( rtl::OString( "Close File" ), rc );

    printf( "\n" );

    // open an existing file (Write)

    rc=pFile->open( osl_File_OpenFlag_Write );
    print_error( rtl::OString( "Open File (Write)" ), rc );

    // close the file

     rc=pFile->close();
    print_error( rtl::OString( "Close File" ), rc );

    printf( "\n" );

    // close the file a second time

     rc=pFile->close();
    print_error( rtl::OString( "Close the file a second time" ), rc );

    delete pFile;
    PressKey();
}

// FileCreateAndRemoveTest

void FileCreateAndRemoveTest()
{
    FileBase::RC    rc;
    File    *pFile;

    printf( "--------------------------------------------\n" );
    printf( "File-Create-And-Remove-Test\n" );
    printf( "--------------------------------------------\n\n" );

    pFile=new File( file_not_exist );

    printf( "Create File: ");
    printFileName( file_not_exist );
    printf( "\n" );

    // open (create) a not existing file (Read and write)

    rc = pFile->open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );

    print_error( rtl::OString( "Create and Open File (Read & Write)" ), rc );

    // close the file

    rc=pFile->close();
    print_error( rtl::OString( "Close File" ), rc );

    // remove the file

    rc=pFile->remove( file_not_exist );
    print_error( rtl::OString(" Remove File" ), rc );

    printf( "\n" );

    // remove the same file a second time

    rc=pFile->remove( file_not_exist );
    print_error( rtl::OString( "Remove a not existing File" ), rc );

    // remove an open file

    pFile->open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );

    rc=pFile->remove( file_not_exist );
    print_error( rtl::OString( "Remove an open File" ), rc );

    pFile->close();
    pFile->remove( file_not_exist );

    PressKey();

    return;
}

// FileWriteAndReadTest

void FileWriteAndReadTest()
{
    FileBase::RC    rc;

    sal_uInt64 uWritten;
    sal_uInt64 uRead;
    const sal_Char *pWriteBuffer="Hier kommt der Osterhase !";
    sal_uInt64  nLen=strlen( pWriteBuffer );
    sal_Char *pReadBuffer;

    printf( "--------------------------------------------\n" );
    printf( "File-Write-And-Read-Test\n" );
    printf( "--------------------------------------------\n\n" );

    File    *pFile;

    pFile=new File( file_not_exist );

    printf( "Create File: ");
    printFileName( file_not_exist );
    printf("\n");

    // open (create) a not existing file (Read and write)

    rc = pFile->open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );

    print_error( rtl::OString( "Create and Open File (Read & Write)" ), rc );

    printf( "\n" );

    // write a string to the file

    rc=pFile->write( pWriteBuffer , nLen , uWritten );
    print_error( rtl::OString( "Write File" ), rc );

    if(uWritten==nLen)
        printf( "Verify: OK! \n" );
    else
        printf( "Verify: Error\n" );

    printf( "\n" );

    // move the filepointer to the beginning

    rc=pFile->setPos( osl_Pos_Absolut , 0 );
    print_error( rtl::OString( "Set FilePointer to the beginning of the file" ), rc );

    printf( "\n" );

    // read the string

    pReadBuffer=(sal_Char*) rtl_allocateMemory( (sal_uInt32)(nLen+1)*sizeof(sal_Char) );
    memset( pReadBuffer, 0, (sal_uInt32)(nLen+1)*sizeof(sal_Char) );
    rc=pFile->read( pReadBuffer , nLen,uRead );
    print_error( rtl::OString( "Read File" ), rc );

    if (strcmp(pWriteBuffer, pReadBuffer)==0)
    {
        printf( "Verify: OK !\n" );
        printf( "Text: %s\n",pReadBuffer );
    }
    else
        printf( "Verify: Error\n" );

    rtl_freeMemory( pReadBuffer );

    printf( "\n" );

    // close the file
    rc=pFile->close();
    print_error( rtl::OString( "Close File" ), rc );

    // remove the file
    rc=pFile->remove( file_not_exist );
    print_error( rtl::OString( "Remove File" ), rc );

    PressKey();

    return;

}

// FileCopyMoveTest

void FileCopyAndMoveTest()
{
    FileBase::RC    rc;

    printf( "--------------------------------------------\n" );
    printf( "File-Copy-Move-Test\n" );
    printf( "--------------------------------------------\n\n" );

    File    *pFile;
    rtl::OUString   destPath(dir2);

    // FileCopyTest

    destPath+=rtl::OUString("/");
    destPath+=file3;

    printf( "Copy the file ");
    printFileName( file1 );
    printf( " to ");
    printFileName( destPath );
    printf( "\n" );

    rc=File::copy( file1 , destPath );
    print_error( rtl::OString( "FileCopy" ), rc );

    pFile=new File( destPath );

    rc=pFile->open( osl_File_OpenFlag_Read );
    if ( rc == FileBase::E_None)
    {
        printf( "Verify: OK!\n" );
        pFile->close();
        File::remove( destPath );
    }
    else
        printf( "Verify: Error!\n" );

    delete pFile;

    printf( "\n" );

    // Copy a file to a not existing directory

    destPath=rtl::OUString( dir_not_exist );
    destPath+=rtl::OUString("/");
    destPath+=file3;

    printf( "Copy a file to a not existing directory \n");
    printf( "Copy the file %s to %s\n",
        rtl::OUStringToOString( file1, RTL_TEXTENCODING_ASCII_US ).getStr(),
        rtl::OUStringToOString( destPath, RTL_TEXTENCODING_ASCII_US ).getStr() );

    rc=File::copy( file1, destPath );
    print_error( rtl::OString( "FileCopy" ), rc );

    printf( "\n" );

    // Copy a directory

    printf( "Copy the directory: ");
    printFileName( dir1 );
    printf( " to ");
    printFileName( dir2 );
    printf( "\n" );

    rc=File::copy( dir1 , dir2 );
    print_error( rtl::OString( "FileCopy" ), rc );

    printf( "\n" );

    // FileMoveTest

    destPath=rtl::OUString( dir2 );
    destPath+=rtl::OUString("/");
    destPath+=file3;

    printf( "Move the file ");
    printFileName( file1 );
    printf( " to ");
    printFileName( destPath );
    printf( "\n" );

    rc=File::move( file1, destPath );
    print_error( rtl::OString( "FileMove" ), rc );

    pFile=new File( destPath );

    rc=pFile->open( osl_File_OpenFlag_Read );
    if ( rc==FileBase::E_None )
    {
        pFile->close();

        delete pFile;
        pFile=new File( file1 );

        rc=pFile->open( osl_File_OpenFlag_Read );

        if ( rc!=FileBase::E_None )
        {
            printf( "Verify: OK!\n" );
            File::move( destPath, file1 );
        }
        else
        {
            printf( "Verify: Error!\n" );
            pFile->close();
            File::remove( destPath );
        }
    }
    else
        printf( "Verify: Error!\n" );

    delete pFile;

    printf( "\n" );

    // Move a file to a not existing directory

    destPath=rtl::OUString( dir_not_exist );
    destPath+=rtl::OUString("/");
    destPath+=file3;

    printf( "Move a file to a not existing directory: \n");
    printf( "Move the file ");
    printFileName( file1 );
    printf( " to ");
    printFileName( destPath );
    printf( "\n" );

    rc=File::move( file1 , destPath );
    print_error( rtl::OString( "FileMove" ), rc );

    printf( "\n" );

    // Move a directory

    printf( "Move a directory: \n");

    printf( "Move the directory ");
    printFileName( dir1 );
    printf( " to ");
    printFileName( dir_not_exist );
    printf( "\n" );

    rc=File::move( dir1 , dir_not_exist);
    print_error( rtl::OString( "FileMove" ), rc );

    if ( rc == FileBase::E_None )
        File::move( dir_not_exist , dir1);

    printf( "\n" );

    PressKey();
    return;
}

// FileSizeTest

void FileSizeTest()
{
    FileBase::RC    rc;
    sal_uInt64      filesize;
    DirectoryItem   aItem;

    printf( "--------------------------------------------\n" );
    printf( "File-Size-Test\n" );
    printf( "--------------------------------------------\n\n" );

    File    aFile( file_not_exist );

    printf( "Create File: ");
    printFileName( file_not_exist );
    printf( "\n\n");

    rc = aFile.open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );
    print_error( rtl::OString( "Create and Open File (Read & Write)" ), rc );
    printf( "\n" );

    if ( rc == FileBase::E_None )
    {

        // Set Filesize to 5000

        printf( "Set FileSize to 5000\n" );
        rc=aFile.setSize( 5000 );
        print_error( rtl::OString( "Set FileSize" ), rc );

        printf( "\n" );
        printf( "Verify:\n" );

        // Check whether Filesize is set to 5000

        rc=DirectoryItem::get( file_not_exist, aItem );
        print_error( rtl::OString( "Get DirectoryItem" ), rc );

        if ( rc == FileBase::E_None )
        {
            FileStatus rStatus( osl_FileStatus_Mask_FileSize  );
            rc=aItem.getFileStatus( rStatus );
            print_error( rtl::OString( "Get FileStatus" ), rc );

            if ( rc == FileBase::E_None )
            {
                filesize=rStatus.getFileSize();

                if ( filesize == 5000 )
                    printf( "\nOK : FileSize: %" SAL_PRIuUINT64 "\n", filesize );
                else
                    printf( "\nError : FileSize: %" SAL_PRIuUINT64 "\n", filesize );
            }
        }

        printf( "\n" );

        // Set Filesize to -1

        printf( "Set FileSize to -1\n" );
        rc=aFile.setSize( -1 );
        print_error( rtl::OString( "Set FileSize" ), rc );

        printf( "\n" );

        // close the file
        rc=aFile.close();
        print_error( rtl::OString( "Close File" ), rc );

        // remove the file
        rc=File::remove( file_not_exist );
        print_error( rtl::OString( "Remove File" ), rc );
    }

    PressKey();

    return;
}

// FilePointerTest

void FilePointerTest()
{
    FileBase::RC    rc;
    sal_uInt64 filepointer;

    printf( "--------------------------------------------\n" );
    printf( "File-Pointer-Test\n" );
    printf( "--------------------------------------------\n\n" );

    File    rFile( file_not_exist );

    printf( "Create File: ");
    printFileName( file_not_exist );
    printf( "\n\n");

    rc = rFile.open( osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );
    print_error( rtl::OString( "Create and Open File (Read & Write) "), rc );
    printf( "\n" );

    if ( rc==FileBase::E_None )
    {

        // get the position of the filepointer

        rc =rFile.getPos( filepointer );
        print_error( rtl::OString( "GetPos" ), rc );
        printf( "Position of the FilePointer: %" SAL_PRIuUINT64 "\n", filepointer );

        printf( "\n" );

        // set the filepointer at the end of a file

        printf( "Set FileSize to 5000\n" );
        rFile.setSize( 5000 );

        printf( "Set the FilePointer at the end of the file (5000)\n" );
        rc=rFile.setPos( osl_Pos_End,0 );
        print_error( rtl::OString( "SetPos" ), rc );

        rc=rFile.getPos( filepointer );

        if ( filepointer==5000 )
        {
            print_error( rtl::OString( "GetPos" ), rc );
            printf( "\nVerify: OK !\n" );
            printf( "Filepointer-Position: %" SAL_PRIuUINT64 "\n",filepointer );
        }
        else
        {
            print_error( rtl::OString( "GetPos" ), rc );
            printf( "\nFilePointer-Test: Error\n" );
            printf( "Filepointer-Position: %" SAL_PRIuUINT64 " != 5000 \n",filepointer );
        }

        printf( "\n" );

        // close the file
        rc=rFile.close();
        print_error( rtl::OString( "Close File" ), rc );

        // remove the file
        rc=File::remove( file_not_exist );
        print_error( rtl::OString( "Remove File" ), rc );
    }

    PressKey();

    return;
}

// FileAttributesTest

void verifyFileAttributes()
{
    FileBase::RC    rc;
    DirectoryItem   aItem;
    FileStatus rStatus( osl_FileStatus_Mask_Attributes  );

    printf( "\nVerify:\n" );

    rc=DirectoryItem::get( file1, aItem );

    if ( rc==FileBase::E_None )
    {
        rc=aItem.getFileStatus( rStatus );

        if ( rc==FileBase::E_None )
        {
            sal_uInt64 uAttributes=rStatus.getAttributes();
            showAttributes(uAttributes);
            printf( "\n" );
        }
        else
            print_error( rtl::OString( "Get FileStatus" ), rc );
    }
    else
        print_error( rtl::OString( "Get DirectoryItem" ), rc );

    return;
}

#ifdef UNX
void FileAttributesTest()
{
    FileBase::RC    rc;

    printf( "--------------------------------------------\n" );
    printf( "File-Attributes-Test\n" );
    printf( "--------------------------------------------\n\n" );

    printf( "File: ");
    printFileName( file1 );
    printf( "\n\n" );

    rc=File::setAttributes( file1, osl_File_Attribute_GrpWrite );
    print_error( rtl::OString( "Set Attribute: GrpWrite" ), rc );

    verifyFileAttributes();

    rc=File::setAttributes( file1, 0 );
    if ( rc!=FileBase::E_None )
        print_error( rtl::OString( "Reset Attributes" ), rc );

    rc=File::setAttributes( file1, osl_File_Attribute_GrpRead );
    print_error( rtl::OString( "Set Attribute: GrpRead" ), rc );

    verifyFileAttributes();

    rc=File::setAttributes( file1, 0 );
    if ( rc!=FileBase::E_None )
        print_error( rtl::OString( "Reset Attributes" ), rc );

    rc=File::setAttributes( file1, osl_File_Attribute_GrpExe );
    print_error( rtl::OString( "Set Attribute: GrpExe" ), rc );

    verifyFileAttributes();

    rc=File::setAttributes( file1, 0 );
    if ( rc!=FileBase::E_None )
        print_error( rtl::OString( "Reset Attributes" ), rc );

    rc=File::setAttributes( file1, osl_File_Attribute_OwnWrite );
    print_error( rtl::OString( "Set Attribute: OwnWrite" ), rc );

    verifyFileAttributes();

    rc=File::setAttributes( file1, 0 );
    if ( rc!=FileBase::E_None )
        print_error( rtl::OString( "Reset Attributes" ), rc );

    rc=File::setAttributes( file1, osl_File_Attribute_OwnRead );
    print_error( rtl::OString( "Set Attribute: OwnRead" ), rc );

    verifyFileAttributes();

    rc=File::setAttributes( file1, 0 );
    if ( rc!=FileBase::E_None )
        print_error( rtl::OString( "Reset Attributes" ), rc );

    rc=File::setAttributes( file1, osl_File_Attribute_OwnExe );
    print_error( rtl::OString( "Set Attribute: OwnExe" ), rc );

    verifyFileAttributes();

    rc=File::setAttributes( file1, 0 );
    if ( rc!=FileBase::E_None )
        print_error( rtl::OString( "Reset Attributes" ), rc );

    rc=File::setAttributes( file1, osl_File_Attribute_OthWrite );
    print_error( rtl::OString( "Set Attribute: OthWrite" ), rc );

    verifyFileAttributes();

    rc=File::setAttributes( file1, 0 );
    if ( rc!=FileBase::E_None )
        print_error( rtl::OString( "Reset Attributes" ), rc );

    rc=File::setAttributes( file1, osl_File_Attribute_OthRead );
    print_error( rtl::OString( "Set Attribute: OthRead" ), rc );

    verifyFileAttributes();

    rc=File::setAttributes( file1, 0 );
    if ( rc!=FileBase::E_None )
        print_error( rtl::OString( "Reset Attributes" ), rc );

    rc=File::setAttributes( file1, osl_File_Attribute_OthExe );
    print_error( rtl::OString( "Set Attribute: OthExe" ), rc );

    verifyFileAttributes();

    rc=File::setAttributes( file1, 0 );
    if ( rc!=FileBase::E_None )
        print_error( rtl::OString( "Reset Attributes" ), rc );

    rc=File::setAttributes( file1, osl_File_Attribute_GrpWrite | osl_File_Attribute_GrpRead | osl_File_Attribute_GrpExe | osl_File_Attribute_OwnWrite | osl_File_Attribute_OwnRead | osl_File_Attribute_OwnExe | osl_File_Attribute_OthWrite | osl_File_Attribute_OthRead | osl_File_Attribute_OthExe );
    print_error( rtl::OString( "Set all Attributes" ), rc );

    verifyFileAttributes();

    PressKey();

    return;
}
#endif

#ifdef _WIN32
void FileAttributesTest()
{
    FileBase::RC    rc;

    printf( "--------------------------------------------\n" );
    printf( "File-Attributes-Test\n" );
    printf( "--------------------------------------------\n\n" );

    printf( "File: ");
    printFileName( file1 );
    printf( "\n\n" );

    rc=File::setAttributes( file1, osl_File_Attribute_ReadOnly );
    print_error( rtl::OString( "Set Attribute: ReadOnly" ), rc );

    verifyFileAttributes();

    rc=File::setAttributes( file1, 0 );
    print_error( rtl::OString( "Reset Attributes" ), rc );

    verifyFileAttributes();

    rc=File::setAttributes( file1, osl_File_Attribute_Hidden );
    print_error( rtl::OString( "Set Attribute: Hidden" ), rc );

    verifyFileAttributes();

    rc=File::setAttributes( file1, 0 );
    print_error( rtl::OString( "Reset Attributes" ), rc );

    verifyFileAttributes();

    rc=File::setAttributes( file1, osl_File_Attribute_Hidden | osl_File_Attribute_ReadOnly );
    print_error( rtl::OString( "Set Attribute: Hidden & ReadOnly" ), rc );

    verifyFileAttributes();

    rc=File::setAttributes( file1, 0 );
    print_error( rtl::OString( "Reset Attributes") , rc );

    verifyFileAttributes();

    PressKey();

    return;
}
#endif

// FileTimeTest

void FileTimeTest()
{
    FileBase::RC    rc;

    DirectoryItem   aItem;

    struct tm sSysCreationTime;
    sSysCreationTime.tm_sec = 0;
    sSysCreationTime.tm_min = 20;
    sSysCreationTime.tm_hour = 12;
    sSysCreationTime.tm_mday = 4;
    sSysCreationTime.tm_mon = 9;
    sSysCreationTime.tm_year = 99;

    struct tm sSysAccessTime;
    sSysAccessTime.tm_sec = 0;
    sSysAccessTime.tm_min = 40;
    sSysAccessTime.tm_hour = 1;
    sSysAccessTime.tm_mday = 6;
    sSysAccessTime.tm_mon = 5;
    sSysAccessTime.tm_year = 98;

    struct tm sSysModifyTime;
    sSysModifyTime.tm_sec = 0;
    sSysModifyTime.tm_min = 1;
    sSysModifyTime.tm_hour = 24;
    sSysModifyTime.tm_mday = 13;
    sSysModifyTime.tm_mon = 11;
    sSysModifyTime.tm_year = 95;

    sal_uInt32 aSysCreationTime = mktime( &sSysCreationTime );
    sal_uInt32 aSysAccessTime =  mktime( &sSysAccessTime );
    sal_uInt32 aSysModifyTime =  mktime( &sSysModifyTime );

    TimeValue       aCreationTime   = { aSysCreationTime, 0};
    TimeValue       aAccessTime = { aSysAccessTime, 0};
    TimeValue       aModifyTime = { aSysModifyTime, 0};

    TimeValue       aCreationTimeRead;
    TimeValue       aAccessTimeRead;
    TimeValue       aModifyTimeRead;

    printf( "--------------------------------------------\n" );
    printf( "File-Time-Test\n" );
    printf( "--------------------------------------------\n\n" );

    printf( "File: ");
    printFileName( file1 );
    printf( "\n\n" );

    printf( "CreationTime \t : ");
    showTime( aCreationTime );

    printf( "\nAccessTime \t : ");
    showTime( aAccessTime );

    printf( "\nModifyTime \t : ");
    showTime( aModifyTime );

    // setTime

    printf( "\n" );
    rc=File::setTime( file1 , aCreationTime , aAccessTime , aModifyTime );
    print_error( rtl::OString( "SetTime" ), rc );

    // Verify

    FileStatus rStatus( osl_FileStatus_Mask_CreationTime | osl_FileStatus_Mask_AccessTime | osl_FileStatus_Mask_ModifyTime);

    printf( "\nVerify:\n" );

    rc=DirectoryItem::get( file1, aItem );
    print_error( rtl::OString( "Get DirectoryItem" ), rc );

    if ( rc==FileBase::E_None )
    {
        rc=aItem.getFileStatus( rStatus );
        print_error( rtl::OString( "Get FileStatus" ), rc );
        printf( "\n" );

        if ( rc==FileBase::E_None )
        {

            // GetCreationTime

            aCreationTimeRead=rStatus.getCreationTime();
#ifdef _WIN32
            if ( aCreationTime.Seconds == aCreationTimeRead.Seconds && aCreationTime.Nanosec == aCreationTimeRead.Nanosec )
                printf( "GetCreationTime: ok : " );
            else
                printf( "GetCreationTime: Error : " );

            showTime( aCreationTimeRead );
            printf( "\n" );
#endif

            // GetAccessTime

            aAccessTimeRead=rStatus.getAccessTime();

            if ( aAccessTime.Seconds == aAccessTimeRead.Seconds && aAccessTime.Nanosec == aAccessTimeRead.Nanosec )
                printf( "GetAccessTime: ok : " );
            else
                printf( "GetAccessTime: Error : " );

            showTime( aAccessTimeRead );
            printf( "\n" );

            // GetModifyTime

            aModifyTimeRead=rStatus.getModifyTime();

            if ( aModifyTime.Seconds == aModifyTimeRead.Seconds && aModifyTime.Nanosec == aModifyTimeRead.Nanosec )
                printf( "GetModifyTime: ok : " );
            else
                printf( "GetModifyTime: Error : " );

            showTime( aModifyTimeRead );
            printf( "\n" );
        }
    }

    PressKey();
    return;
}

// DirectoryItemTest

void DirectoryItemTest()
{
    FileBase::RC    rc;
    Directory       *pDir;
    DirectoryItem   aItem;
    FileStatus      *pStatus;
    File            *pFile;

    printf( "--------------------------------------------\n" );
    printf( "Directory-Item-Test\n" );
    printf( "--------------------------------------------\n\n" );

    // get DirectoryItem from an existing directory

    printf( "Get DirectoryItem from an existing Directory: ");
    printFileName( dir1 );
    printf( "\n");

    rc=DirectoryItem::get( dir1 , aItem );
    print_error( rtl::OString( "GetDirectoryItem" ), rc );

    pStatus=new FileStatus( osl_FileStatus_Mask_All );
    rc=aItem.getFileStatus( *pStatus );

    if ( rc==FileBase::E_None )
    {
        printf( "GetFileStatus: FileURL: ");
        printFileName(pStatus->getFileURL() );
        printf( "\n" );
    }

    delete pStatus;

    printf( "\n" );

    // get DirectoryItem from a not existing directory

    printf( "Get DirectoryItem from a not existing Directory: ");
    printFileName( dir_not_exist );
    printf( "\n" );

    rc=DirectoryItem::get( dir_not_exist , aItem );
    print_error( rtl::OString( "Get DirectoryItem" ), rc );

    printf( "\n" );

    // get DirectoryItem from an existing file

    printf( "Get DirectoryItem from an existing File: ");
    printFileName( file1 );
    printf( "\n" );

    rc=DirectoryItem::get( file1 , aItem );
    print_error( rtl::OString( "GetDirectoryItem" ), rc );

    pStatus=new FileStatus( osl_FileStatus_Mask_All );
    rc=aItem.getFileStatus( *pStatus );

    if ( rc==FileBase::E_None )
    {
        printf( "GetFileStatus: FileURL: ");
        printFileName( pStatus->getFileURL() );
        printf( "\n" );
    }

    delete pStatus;

    printf( "\n" );

    // get DirectoryItem from a not existing file

    printf( "Get DirectoryItem from a not existing File: ");
    printFileName( file_not_exist );
    printf( "\n" );

    rc=DirectoryItem::get( file_not_exist , aItem );
    print_error( rtl::OString( "Get DirectoryItem" ), rc );

    printf( "\n" );

    // get DirectoryItem from a directory with a wrong semantic

    printf( "Get DirectoryItem from a Directory with a wrong semantic: ");
    printFileName( dir_not_exist );
    printf( "\n" );

    rc=DirectoryItem::get( dir_wrong_semantic, aItem );
    print_error( rtl::OString( "Get DirectoryItem" ),rc );

    printf( "\n" );

    // get DirectoryItem from a file-handle

    pFile=new File( file1 );

    rc=pFile->open( osl_File_OpenFlag_Read );
    if ( rc==FileBase::E_None )
    {
        printf( "Get DirectoryItem from a File-Handle: ");
        printFileName( file1 );
        printf( "\n" );

        rc=DirectoryItem::get( file1 , aItem );
        print_error( rtl::OString( "GetDirectoryItem" ), rc );

        pStatus=new FileStatus( osl_FileStatus_Mask_All );
        rc=aItem.getFileStatus( *pStatus );

        if ( rc==FileBase::E_None )
        {
            printf( "GetFileStatus: FileURL:  ");
            printFileName( pStatus->getFileURL() );
            printf( "\n");
        }

        delete pStatus;

        pFile->close();
    }

    delete pFile;

    printf( "\n" );

    // get DirectoryItem

    printf( "Get DirectoryItem from an empty File-Handle\n" );
    rc=DirectoryItem::get( file1 , aItem );
    print_error( rtl::OString( "GetDirectoryItem" ), rc );

    printf( "\n" );

    // GetNextItem from a directory

    pDir=new Directory( dir1 );
    printf( "Get next DirectoryItem from a directory: ");
    printFileName( dir1);
    printf( "\n" );

    rc= pDir->open();
    print_error( rtl::OString( "Open Directory" ), rc );

    printf( "\n" );

    if ( pDir->isOpen() )
    {

        // get all files from the directory

        rtl::OUString   str;
        rtl::OUString   str1[2];

        aItem=DirectoryItem();
        rc=pDir->getNextItem( aItem );
        print_error( rtl::OString( "GetNextItem" ),rc );

        while( rc==FileBase::E_None )
        {

            FileStatus rStatus( osl_FileStatus_Mask_All );
            aItem.getFileStatus( rStatus );

            str=rStatus.getFileName();
            printf( "Filename: ");
            printFileName( str );
            printf( "\n");

            aItem=DirectoryItem();
            rc=pDir->getNextItem( aItem );
            print_error( rtl::OString( "GetNextItem" ),rc );
        }

        printf( "\n" );

        // Reset-Test

        for (int i=0; i<2; i++)
        {
            aItem=DirectoryItem();
            rc=pDir->reset();
            rc=pDir->getNextItem( aItem );

            FileStatus rStatus( osl_FileStatus_Mask_All );
            aItem.getFileStatus( rStatus );

            str1[i]=rStatus.getFileName();
        }

        if ( str1[0] == str1[1] )
            print_error( rtl::OString( "Reset" ),FileBase::E_None );
        else
            print_error( rtl::OString( "Reset" ),FileBase::E_invalidError );

        printf( "\n" );

        // Close Directory
        rc=pDir->close();
        print_error( rtl::OString( "Close Directory" ), rc );
    }

    printf( "\n");

    // GetNextItem from a closed directory

    printf( "Get next DirectoryItem from a closed directory: ");
    printFileName( dir1 );
    printf( "\n" );

    aItem=DirectoryItem();
    rc=pDir->getNextItem( aItem );
    print_error( rtl::OString( "GetNextItem" ),rc );

    delete pDir;

    PressKey();
    return;
}

// FileStatusTest (for different types)

void FileStatusTest( FileStatus *pStatus )
{

    // GetFileType of the directory

    FileStatus::Type    aType;

    printf( "\ngetFileType:\n" );
    aType=pStatus->getFileType();
    showFileType( aType );

    // GetAttributes

    sal_uInt64          uAttributes;

    printf( "\ngetAttributes:\n" );
    uAttributes=pStatus->getAttributes();
    showAttributes( uAttributes );

    // GetCreationTime

    TimeValue   aCreationTime;

    printf( "\ngetCreationTime:\n" );
    aCreationTime=pStatus->getCreationTime();

    printf( "CreationTime: " );
    showTime( aCreationTime );

    // GetAccessTime

    TimeValue   aAccessTime;

    printf( "\ngetAccessTime:\n" );
    aAccessTime=pStatus->getAccessTime();

    printf( "AccessTime: " );
    showTime( aAccessTime );

    // GetModifyTime

    TimeValue   aModifyTime;

    printf( "\ngetModifyTime:\n" );
    aModifyTime=pStatus->getModifyTime();

    printf( "ModifyTime: " );
    showTime( aModifyTime );

    // GetFileSize

    sal_uInt64          FileSize;

    printf( "\ngetFileSize:\n" );

    FileSize=pStatus->getFileSize();
    printf( "FileSize: %" SAL_PRIuUINT64 "\n", FileSize);

    // GetFileName

    rtl::OUString           FileName;

    printf( "\ngetFileName:\n" );

    FileName=pStatus->getFileName();
    printf( "FileName: ");
    printFileName( FileName );
    printf( "\n" );

    // GetFileURL

    rtl::OUString           FileURL;

    printf( "\ngetFileURL:\n" );

    FileURL=pStatus->getFileURL();
    printf( "FileURL: ");
    printFileName( FileURL );
    printf( "\n" );

    // GetLinkTargetURL

    rtl::OUString           LinkTargetURL;

    printf( "\ngetLinkTargetURL:\n");

    LinkTargetURL=pStatus->getLinkTargetURL();
    printf( "LinkTargetURL: ");
    printFileName( LinkTargetURL );
    printf( "\n" );

    return;
}

// DirectoryFileStatusTest

void DirectoryFileStatusTest()
{
    FileBase::RC    rc;
    DirectoryItem   aItem;

    printf( "--------------------------------------------\n" );
    printf( "Directory-FileStatus-Test\n" );
    printf( "--------------------------------------------\n\n" );

    printf( "FileStatus of the directory: ");
    printFileName( dir1 );
    printf( "\n" );

    aItem=DirectoryItem();

    rc=DirectoryItem::get( dir1, aItem );
    print_error( rtl::OString( "Get DirectoryItem" ), rc );

    if ( rc==FileBase::E_None )
    {
        FileStatus *pStatus=new FileStatus( osl_FileStatus_Mask_All );
        rc=aItem.getFileStatus( *pStatus );

        FileStatusTest( pStatus );

        delete pStatus;
    }

    printf( "\n" );

    PressKey();
    return;
}

// FileFileStatusTest

void FileFileStatusTest()
{
    FileBase::RC    rc;
    DirectoryItem   aItem;

    printf( "--------------------------------------------\n" );
    printf( "File-FileStatus-Test\n" );
    printf( "--------------------------------------------\n\n" );

    printf( "FileStatus of the file: ");
    printFileName( file1 );
    printf( "\n" );

    aItem=DirectoryItem();

    rc=DirectoryItem::get( file1 , aItem );
    print_error( rtl::OString( "Get DirectoryItem" ), rc );

    if ( rc==FileBase::E_None )
    {
        FileStatus *pStatus=new FileStatus( osl_FileStatus_Mask_All );
        rc=aItem.getFileStatus( *pStatus );

        FileStatusTest( pStatus );

        delete pStatus;
    }

    printf( "\n" );

    PressKey();
    return;
}

// VolumeFileStatusTest

void VolumeFileStatusTest()
{
    FileBase::RC    rc;
    DirectoryItem   aItem;

    printf( "--------------------------------------------\n" );
    printf( "Volume-FileStatus-Test\n" );
    printf( "--------------------------------------------\n\n" );

    printf( "FileStatus of the Volume: ");
    printFileName( root );
    printf( "\n" );

    aItem=DirectoryItem();

    rc=DirectoryItem::get( root , aItem );
    print_error( rtl::OString( "Get DirectoryItem" ), rc );

    if ( rc==FileBase::E_None )
    {
        FileStatus *pStatus=new FileStatus( osl_FileStatus_Mask_All) ;
        rc=aItem.getFileStatus( *pStatus );

        FileStatusTest( pStatus );

        delete pStatus;
    }

    printf( "\n" );

    PressKey();
    return;
}

// VolumeInfoTest

void VolumeInfoTest()
{
    FileBase::RC    rc;

    printf( "--------------------------------------------\n" );
    printf( "Volume-Info-Test\n" );
    printf( "--------------------------------------------\n\n" );

    printf( "VolumeInfo of the volume ");
    printFileName( root );

    printf( "\n" );

    VolumeInfo rInfo( osl_VolumeInfo_Mask_FreeSpace );
    rc=Directory::getVolumeInfo( root , rInfo );
    print_error( rtl::OString( "GetVolumeInfo" ),rc );

    printf( "\n" );

    // getRemoteFlag

    if ( rInfo.getRemoteFlag() )
        printf( "RemoteFlag: Yes\n" );
    else
        printf( "RemoteFlag: No\n" );

    // getRemoveableFlag

    if ( rInfo.getRemoveableFlag() )
        printf( "RemoveableFlag: Yes\n" );
    else
        printf( "RemoveableFlag: No\n" );

    // getTotalSpace

    sal_uInt64  TotalSpace;
    TotalSpace=rInfo.getTotalSpace();
    printf( "Total Space: %" SAL_PRIuUINT64 "\n",TotalSpace );

    // getFreeSpace

    sal_uInt64  FreeSpace;
    FreeSpace=rInfo.getFreeSpace();
    printf( "Free Space: %" SAL_PRIuUINT64 "\n",FreeSpace );

    // getUsedSpace

    sal_uInt64  UsedSpace;
    UsedSpace=rInfo.getUsedSpace();
    printf( "Used Space: %" SAL_PRIuUINT64 "\n",UsedSpace );

    // getMaxNameLength

    sal_uInt32  MaxNameLength;
    MaxNameLength=rInfo.getMaxNameLength();
    printf( "MaxNameLength: %" SAL_PRIuUINT32 "\n",MaxNameLength );

    // getMaxPathLength

    sal_uInt32  MaxPathLength;
    MaxPathLength=rInfo.getMaxPathLength();
    printf( "MaxPathLength: %" SAL_PRIuUINT32 "\n",MaxPathLength );

    // getFileSystemName

    rtl::OUString   FileSystemName;
    FileSystemName=rInfo.getFileSystemName();
    printf( "File-System-Name: ");
    printFileName( FileSystemName );
    printf( "\n" );

    PressKey();
    return;
}

// FileBaseTest

void ConvertPathTest(rtl::OUString& strPath)
{
    FileBase::RC    rc;

    rtl::OUString       strNormPath;
    rtl::OUString       strFileURL;
    rtl::OUString       strNormPathFromFileURL;
    rtl::OUString       strSystemPath;

    // normalizePath

    rc=FileBase::getFileURLFromSystemPath( strPath, strNormPath );

    if ( rc == FileBase::E_None )
    {
        printf( "Normalized Path: \t\t");
        printFileName( strNormPath );
        printf( "\n" );
    }
    else
        printf( "normalizePath: Error \n" );

    // getFileURLFromSystemPath

    if ( !strNormPath.isEmpty() )
    {
        rc=FileBase::getFileURLFromSystemPath( strNormPath, strFileURL );

        if ( rc == FileBase::E_None )
        {
            printf( "File-URL: \t\t\t");
            printFileName( strFileURL );
            printf( "\n" );
        }
        else
            printf( "getFileURLFromSystemPath: Error \n" );
    }
    else
        printf( "getFileURLFromSystemPath: not tested \n" );

    // getNormalizedPathFromFileURL

    if ( !strFileURL.isEmpty() )
    {
        rc=FileBase::getSystemPathFromFileURL( strFileURL, strNormPathFromFileURL );

        if ( rc == FileBase::E_None )
        {
            printf( "Normalized Path from File-URL: \t");
            printFileName( strNormPathFromFileURL );
            printf( "\n" );
        }
        else
            printf( "getNormalizedPathFromFileURL: Error \n" );
    }
    else
        printf( "getNormalizedPathFromFileURL: not tested \n" );

    // getSystemPathFromFileURL

    if ( !strNormPath.isEmpty() )
    {
        rc=FileBase::getSystemPathFromFileURL( strNormPath, strSystemPath );

        if ( rc == FileBase::E_None )
        {
            printf( "System-Path: \t\t\t");
            printFileName( strSystemPath );
            printf( "\n");
        }
        else
            printf( "getSystemPathFromFileURL: Error \n" );
    }
    else
        printf( "getSystemPathFromFileURL: not tested \n" );

    // Verify

    if ( strNormPathFromFileURL == strNormPath )
        printf( "\nVerify: OK ! ( Normalized-Path == Normalized-Path-From-File-URL )\n" );
    else
        printf( "\nVerify: Error ! ( Normalized-Path != Normalized-Path-From-File-URL )\n" );

    return;
}

void FileBaseTest()
{
    printf( "--------------------------------------------\n" );
    printf( "FileBase-Test\n" );
    printf( "--------------------------------------------\n\n" );

    // ConvertPath-Test (Local File)

    printf( "- Local File: ");
    printFileName( file1 );
    printf( "\n\n" );

    ConvertPathTest(file1);

    // ConvertPath-Test (File on a server)

    printf( "\n- File on server: ");
    printFileName( file_on_server );
    printf( "\n\n" );
    ConvertPathTest(file_on_server);

    PressKey();

    return;
}

// AbsolutePathTest

void DoAbsolutePathTest(rtl::OUString strDirBase, rtl::OUString strRelative)
{
    FileBase::RC    rc;

    rtl::OUString       strAbsolute;

    printf( "Base-Directory: \t");
    printFileName( strDirBase );
    printf( "\n" );
    printf( "Relative-Path: \t\t");
    printFileName ( strRelative );
    printf( "\n" );

    rc=FileBase::getAbsoluteFileURL( strDirBase, strRelative, strAbsolute );

    if ( rc == FileBase::E_None )
    {
        printf( "Absolute-Path: \t\t");
        printFileName ( strAbsolute );
        printf( "\n" );
    }
    else
        printf( "Absolute-Path: Error \n" );

    printf( "\n" );
    return;
}

void AbsolutePathTest()
{
    printf( "--------------------------------------------\n" );
    printf( "AbsolutePath-Test\n" );
    printf( "--------------------------------------------\n\n" );

    DoAbsolutePathTest(dir1, rtl::OUString("."));
    DoAbsolutePathTest(dir1, rtl::OUString(".."));
    DoAbsolutePathTest(dir1, rtl::OUString("../.."));
    DoAbsolutePathTest(dir1, rtl::OUString("../HUHU"));

    DoAbsolutePathTest(dir_on_server, rtl::OUString("."));
    DoAbsolutePathTest(dir_on_server, rtl::OUString(".."));
    DoAbsolutePathTest(dir_on_server, rtl::OUString("../.."));
    DoAbsolutePathTest(dir_on_server, rtl::OUString("../HUHU"));

    PressKey();
    return;
}

// searchPathTest

void SearchPathTest()
{
    FileBase::RC    rc;

    rtl::OUString       strNormPath(file1);
    rtl::OUString       strFileURL;
    rtl::OUString       strSystemPath;
    rtl::OUString       strResultPath;

    printf( "--------------------------------------------\n" );
    printf( "SearchPath-Test\n" );
    printf( "--------------------------------------------\n\n" );

    rc=FileBase::getFileURLFromSystemPath( strNormPath, strFileURL );
    print_error( rtl::OString( "getFileURLFromSystemPath" ), rc );
    rc=FileBase::getSystemPathFromFileURL( strNormPath, strSystemPath );
    print_error( rtl::OString( "getSystemPathFromFileURL" ), rc );

    // searchFileURL (with a normalized path)

    if ( !strNormPath.isEmpty() )
    {
        printf( "\nSearch-Normalized-Path (with a normalized path) : ");
        printFileName ( strNormPath );
        printf( "\n" );

        rc=FileBase::searchFileURL( strNormPath , rtl::OUString() , strResultPath );

        if ( rc == FileBase::E_None )
        {
            printf( "Result: \t\t\t");
            printFileName ( strResultPath );
            printf( "\n" );
        }
        else
            printf( "searchFileURL (with a normalized path): Error\n" );
    }
    else
        printf( "searchFileURL (with a normalized path): not tested\n" );

    // searchFileURL (with a File-URL)

    if ( !strFileURL.isEmpty() )
    {
        printf( "\nSearch-Normalized-Path (with a FileURL) : ");
        printFileName( strFileURL );
        printf( "\n" );

        rc=FileBase::searchFileURL( strFileURL , rtl::OUString() , strResultPath );

        if ( rc == FileBase::E_None )
        {
            printf( "Result: \t\t\t");
            printFileName ( strResultPath );
            printf( "\n" );
        }
        else
            printf( "searchFileURL (with a FileURL path): Error\n" );
    }
    else
        printf( "searchFileURL (with a FileURL path): not tested\n" );

    // searchFileURL (with a systempath)

    if ( !strSystemPath.isEmpty() )
    {
        printf( "\nSearch-Normalized-Path (with a SystemPath) : ");
        printFileName( strSystemPath );
        printf( "\n" );

        rc=FileBase::searchFileURL( strSystemPath , rtl::OUString() , strResultPath );

        if ( rc == FileBase::E_None )
        {
            printf( "Result: \t\t\t");
            printFileName( strResultPath );
            printf( "\n" );
        }
        else
            printf( "searchFileURL (with a systempath): Error\n" );
    }
    else
        printf( "searchFileURL (with a systempath): not tested\n" );

    // searchFileURL (File and no searchpath)

    printf( "\nsearchFileURL:  File (no searchpath) : ");
    printFileName( file3 );
    printf( "\n" );

    rc=FileBase::searchFileURL( file3 , rtl::OUString("") , strResultPath );

    if ( rc == FileBase::E_None )
    {
        printf( "Result: \t\t\t");
        printFileName( strResultPath );
        printf( "\n" );
    }
    else
        printf( "searchFileURL:  File not found: OK ! \n" );

    // searchFileURL (File and Path)

    printf( "\nsearchFileURL:  File : ");
    printFileName( file3 );
    printf( "\tSearchPath ");
    printFileName( dir1 );
    printf( "\n");

    rc=FileBase::searchFileURL( file3 , dir1 , strResultPath );

    if ( rc == FileBase::E_None )
    {
        printf( "Result: \t\t\t");
        printFileName( strResultPath );
        printf( "\n");
    }
    else
        printf( "searchFileURL:  File not found: Error\n" );

    // searchFileURL (File and searchpath with two entries)

    rtl::OUString       strSearchPath( dir_not_exist );
    strSearchPath+=rtl::OUString(";");
    strSearchPath+=dir_on_server;

    printf( "\nsearchFileURL:  File : ");
    printFileName( file3 );
    printf( "SearchPath ");
    printFileName( strSearchPath );
    printf( "\n");

    rc=FileBase::searchFileURL( file3 , strSearchPath , strResultPath );

    if ( rc == FileBase::E_None )
    {
        printf( "Result: \t\t\t");
        printFileName( strResultPath );
        printf( "\n" );
    }
    else
        printf( "searchFileURL:  File not found: Error\n" );

    // searchFileURL (File and searchpath (with a wrong semantic))

    strSearchPath=rtl::OUString( dir_wrong_semantic );

    printf( "\nsearchFileURL:  File : ");
    printFileName( file3 );
    printf( "SearchPath ");
    printFileName( strSearchPath );
    printf( "\n");

    rc=FileBase::searchFileURL( file3 , strSearchPath , strResultPath );

    if ( rc == FileBase::E_None )
        printf( "Error: Wrong Semantich but no error occurs !\n" );
    else
        printf( "searchFileURL:  File not found: OK !\n" );

    return;
}

// CanonicalNameTest

void getCanonicalNameTest(rtl::OUString strPath)
{
    FileBase::RC    rc;

    rtl::OUString   strValid;

    printf( "Original-Name: \t\t");
    printFileName( strPath );
    printf( "\n" );

    rc=FileBase::getCanonicalName( strPath, strValid );

    if ( rc == FileBase::E_None)
    {
        printf( "Canonical-Name: \t");
        printFileName( strValid );
        printf( "\n");

    }
    else
        printf( "Canonical-Name: Error \n" );

    printf( "\n" );
    return;
}

void CanonicalNameTest()
{
    printf( "--------------------------------------------\n" );
    printf( "CanonicalName-Test\n" );
    printf( "--------------------------------------------\n\n" );

    getCanonicalNameTest( dir1 );
    getCanonicalNameTest( dir_on_server );
    getCanonicalNameTest( file1 );
    getCanonicalNameTest( file_on_server );

    PressKey();
    return;
}

// print_error

void print_error( const ::rtl::OString& str, FileBase::RC rc )
{

    printf( "%s : ", str.getStr() );
    switch(rc)
    {
    case FileBase::E_None:
        printf("OK !\n");
        break;
    case FileBase::E_PERM:
        printf("E_PERM\n");
        break;
    case FileBase::E_NOENT:
        printf("E_NOENT\n");
        break;
    case FileBase::E_SRCH:
        printf("E_SRCH\n");
        break;
    case FileBase::E_INTR:
        printf("E_INTR\n");
        break;
    case FileBase::E_IO:
        printf("E_IO\n");
        break;
    case FileBase::E_NXIO:
        printf("E_NXIO\n");
        break;
    case FileBase::E_2BIG:
        printf("E_2BIG\n");
        break;
    case FileBase::E_NOEXEC:
        printf("E_NOEXEC\n");
        break;
    case FileBase::E_BADF:
        printf("E_BADF\n");
        break;
    case FileBase::E_CHILD:
        printf("E_CHILD\n");
        break;
    case FileBase::E_AGAIN:
        printf("E_AGAIN\n");
        break;
    case FileBase::E_NOMEM:
        printf("E_NOMEM\n");
        break;
    case FileBase::E_ACCES:
        printf("E_ACCES\n");
        break;
    case FileBase::E_FAULT:
        printf("E_FAULT\n");
        break;
    case FileBase::E_BUSY:
        printf("E_BUSY\n");
        break;
    case FileBase::E_EXIST:
        printf("E_EXIST\n");
        break;
    case FileBase::E_XDEV:
        printf("E_XDEV\n");
        break;
    case FileBase::E_NODEV:
        printf("E_NODEV\n");
        break;
    case FileBase::E_NOTDIR:
        printf("E_NOTDIR\n");
        break;
    case FileBase::E_ISDIR:
        printf("E_ISDIR\n");
        break;
    case FileBase::E_INVAL:
        printf("E_INVAL\n");
        break;
    case FileBase::E_NFILE:
        printf("E_NFILE\n");
        break;
    case FileBase::E_MFILE:
        printf("E_MFILE\n");
        break;
    case FileBase::E_NOTTY:
        printf("E_NOTTY\n");
        break;
    case FileBase::E_FBIG:
        printf("E_FBIG\n");
        break;
    case FileBase::E_NOSPC:
        printf("E_NOSPC\n");
        break;
    case FileBase::E_SPIPE:
        printf("E_SPIPE\n");
        break;
    case FileBase::E_ROFS:
        printf("E_ROFS\n");
        break;
    case FileBase::E_MLINK:
        printf("E_MLINK\n");
        break;
    case FileBase::E_PIPE:
        printf("E_PIPE\n");
        break;
    case FileBase::E_DOM:
        printf("E_DOM\n");
        break;
    case FileBase::E_RANGE:
        printf("E_RANGE\n");
        break;
    case FileBase::E_DEADLK:
        printf("E_DEADLK\n");
        break;
    case FileBase::E_NAMETOOLONG:
        printf("E_NAMETOOLONG\n");
        break;
    case FileBase::E_NOLCK:
        printf("E_NOLCK\n");
        break;
    case FileBase::E_NOSYS:
        printf("E_NOSYS\n");
        break;
    case FileBase::E_NOTEMPTY:
        printf("E_NOTEMPTY\n");
        break;
    case FileBase::E_LOOP:
        printf("E_LOOP\n");
        break;
    case FileBase::E_ILSEQ:
        printf("E_ILSEQ\n");
        break;
    case FileBase::E_NOLINK:
        printf("E_NOLINK\n");
        break;
    case FileBase::E_MULTIHOP:
        printf("E_MULTIHOP\n");
        break;
    case FileBase::E_USERS:
        printf("E_USERS\n");
        break;
    case FileBase::E_OVERFLOW:
        printf("E_OVERFLOW\n");
        break;
    default:
        printf("E_Unknown\n");
        break;
    }
    return;
}

// main

#if defined(_WIN32)
        #define MAIN _cdecl main
#else
        #define MAIN main
#endif

int MAIN( int argc, char* argv[] )
{
    //Initialization
    sal_Bool fSuccess=Initialize();
    if ( !fSuccess )
    {
        printf("Error during Initialization");
        return -1;
    }

    if (argc==1)
    {
        DirectoryOpenAndCloseTest();
        DirectoryCreateAndRemoveTest();

        FileOpenAndCloseTest();
        FileCreateAndRemoveTest();
        FileWriteAndReadTest();
        FileCopyAndMoveTest();
        FileSizeTest();
        FilePointerTest();
        FileAttributesTest();
        FileTimeTest();
        DirectoryItemTest();
        DirectoryFileStatusTest();
        VolumeFileStatusTest();
        FileFileStatusTest();
        VolumeInfoTest();
        FileBaseTest();
        SearchPathTest();
        AbsolutePathTest();
        CanonicalNameTest();
    }
    // command line arguments ?
    else
    {
        int i=1;

        while (i<argc)
        {
            if (strcmp(argv[i], "doc")==0)
                DirectoryOpenAndCloseTest();
            else if (strcmp(argv[i], "dcr")==0)
                DirectoryCreateAndRemoveTest();
            else if (strcmp(argv[i], "foc")==0)
                FileOpenAndCloseTest();
            else if (strcmp(argv[i], "fcr")==0)
                FileCreateAndRemoveTest();
            else if (strcmp(argv[i], "fwr")==0)
                FileWriteAndReadTest();
            else if (strcmp(argv[i], "fcm")==0)
                FileCopyAndMoveTest();
            else if (strcmp(argv[i], "fs")==0)
                FileSizeTest();
            else if (strcmp(argv[i], "fp")==0)
                FilePointerTest();
            else if (strcmp(argv[i], "fa")==0)
                FileAttributesTest();
            else if (strcmp(argv[i], "ft")==0)
                FileTimeTest();
            else if (strcmp(argv[i], "di")==0)
                DirectoryItemTest();
            else if (strcmp(argv[i], "dfs")==0)
                DirectoryFileStatusTest();
            else if (strcmp(argv[i], "vfs")==0)
                VolumeFileStatusTest();
            else if (strcmp(argv[i], "ffs")==0)
                FileFileStatusTest();
            else if (strcmp(argv[i], "vi")==0)
                VolumeInfoTest();
            else if (strcmp(argv[i], "fb")==0)
                FileBaseTest();
            else if (strcmp(argv[i], "sp")==0)
                SearchPathTest();
            else if (strcmp(argv[i], "ap")==0)
                AbsolutePathTest();
            else if (strcmp(argv[i], "cn")==0)
                CanonicalNameTest();

            i++;
        }
    }

    // Shutdown
    fSuccess=Shutdown();
    if ( !fSuccess )
    {
        printf("Error during Shutdown");
        return -1;
    }

    return 0;
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */