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 #ifndef L10NTOOLS_DIRECTORY_HXX
23 #define L10NTOOLS_DIRECTORY_HXX
24 
25 #include <vector>
26 #include <algorithm>
27 #include <rtl/ustring.hxx>
28 #include <tools/string.hxx>
29 
30 #ifdef WNT
31 #else
32 #include <dirent.h>
33 #include <unistd.h>
34 #include <sys/stat.h>
35 #endif
36 
37 #include <stdio.h>
38 
39 #include <l10ntools/file.hxx>
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:
getSubDirectories()54     std::vector<Directory>  getSubDirectories()  { return aDirVec;        }
getFiles()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 
getDirectoryName()61     rtl::OUString getDirectoryName()            { return sDirectoryName; }
getFullName()62     rtl::OUString getFullName()                 { return sFullName ;     }
63     void setSkipLinks( bool is_skipped );
64 
65     void dump();
Directory()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 
77 #endif // L10NTOOLS_DIRECTORY_HXX
78 
79