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 #include <vector>
23 #include <algorithm>
24 #include <rtl/ustring.hxx>
25 #include <tools/string.hxx>
26 
27 #ifdef WNT
28 #else
29 #include <dirent.h>
30 #include <unistd.h>
31 #include <sys/stat.h>
32 #endif
33 
34 #include <stdio.h>
35 
36 #ifndef L10NTOOLS_FILE_HXX
37 #define L10NTOOLS_FILE_HXX
38 #include <l10ntools/file.hxx>
39 #endif
40 
41 namespace transex{
42 
43 class Directory
44 {
45     private:
46     rtl::OUString sDirectoryName;
47     rtl::OUString sFullName;
48     bool bSkipLinks;
49 
50     std::vector<Directory>  aDirVec;
51     std::vector<File>       aFileVec;
52 
53     public:
54     std::vector<Directory>  getSubDirectories()  { return aDirVec;        }
55     std::vector<File>       getFiles()           { return aFileVec;       }
56 
57     void readDirectory();
58     void readDirectory( const rtl::OUString& sFullpath );
59     void scanSubDir( int nLevels = 0 );
60 
61     rtl::OUString getDirectoryName()            { return sDirectoryName; }
62     rtl::OUString getFullName()                 { return sFullName ;     }
63     void setSkipLinks( bool is_skipped );
64 
65     void dump();
66     Directory(){};
67 
68     Directory( const rtl::OUString sFullPath );
69     Directory( const rtl::OUString sFullPath , const rtl::OUString sEntry ) ;
70     Directory( const ByteString sFullPath );
71 
72     static bool lessDir ( const Directory& rKey1, const Directory& rKey2 ) ;
73 };
74 
75 }
76