1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _UNOTOOLS_LOCALFILEHELPER_HXX
24 #define _UNOTOOLS_LOCALFILEHELPER_HXX
25 
26 #include <com/sun/star/uno/Sequence.hxx>
27 #include "unotools/unotoolsdllapi.h"
28 
29 #include <rtl/ustring.hxx>
30 #include <tools/string.hxx>
31 
32 namespace utl
33 {
34 
35 class UNOTOOLS_DLLPUBLIC LocalFileHelper
36 {
37 public:
38                     /**
39                     Converts a "physical" file name into a "UCB compatible" URL ( if possible ).
40                     If no UCP is available for the local file system, sal_False and an empty URL is returned.
41                     Returning sal_True and an empty URL means that the URL doesn't point to a local file.
42                     */
43     static sal_Bool ConvertPhysicalNameToURL( const String& rName, String& rReturn );
44     static sal_Bool ConvertSystemPathToURL( const String& rName, const String& rBaseURL, String& rReturn );
45 
46                     /**
47                     Converts a "UCB compatible" URL into a "physical" file name.
48                     If no UCP is available for the local file system, sal_False and an empty file name is returned,
49                     otherwise sal_True and a valid URL, because a file name can always be converted if a UCP for the local
50                     file system is present ( watch: this doesn't mean that this file really exists! )
51                     */
52     static sal_Bool ConvertURLToPhysicalName( const String& rName, String& rReturn );
53     static sal_Bool ConvertURLToSystemPath( const String& rName, String& rReturn );
54 
55     static sal_Bool IsLocalFile( const String& rName );
56     static sal_Bool IsFileContent( const String& rName );
57 
58     static          ::com::sun::star::uno::Sequence< ::rtl::OUString >
59                             GetFolderContents( const ::rtl::OUString& rFolder, sal_Bool bFolder );
60 };
61 
62 }
63 
64 #endif
65