xref: /aoo4110/main/l10ntools/source/srciter.cxx (revision b1cdbd2c)
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 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_l10ntools.hxx"
26 
27 #include "srciter.hxx"
28 #include <stdio.h>
29 #include <tools/fsys.hxx>
30 
31 //
32 // class SourceTreeIterator
33 //
34 
35 /*****************************************************************************/
SourceTreeIterator(const ByteString & rRootDirectory,const ByteString & rVersion,bool bLocal_in)36 SourceTreeIterator::SourceTreeIterator(
37 	const ByteString &rRootDirectory, const ByteString &rVersion , bool bLocal_in )
38 /*****************************************************************************/
39 				: bInExecute( sal_False ) , bLocal( bLocal_in )
40 {
41 	(void) rVersion ;
42 
43     if(!bLocal){
44         rtl::OUString sRootDirectory( rRootDirectory.GetBuffer() , rRootDirectory.Len() , RTL_TEXTENCODING_UTF8 );
45         aRootDirectory = transex::Directory( sRootDirectory );
46 	}
47 }
48 
49 /*****************************************************************************/
~SourceTreeIterator()50 SourceTreeIterator::~SourceTreeIterator()
51 /*****************************************************************************/
52 {
53 }
54 
55 /*****************************************************************************/
ExecuteDirectory(transex::Directory & aDirectory)56 void SourceTreeIterator::ExecuteDirectory( transex::Directory& aDirectory )
57 /*****************************************************************************/
58 {
59     if ( bInExecute ) {
60 		rtl::OUString sDirName = aDirectory.getDirectoryName();
61 
62 		static rtl::OUString WCARD1 ( rtl::OUString::createFromAscii( "unxlng" ) );
63 		static rtl::OUString WCARD2 ( rtl::OUString::createFromAscii( "unxsol" ) );
64 		static rtl::OUString WCARD3 ( rtl::OUString::createFromAscii( "wntmsc" ) );
65 		static rtl::OUString WCARD4 ( rtl::OUString::createFromAscii( "common" ) );
66 		static rtl::OUString WCARD5 ( rtl::OUString::createFromAscii( "unxmac" ) );
67 		static rtl::OUString WCARD6 ( rtl::OUString::createFromAscii( "unxubt" ) );
68 		static rtl::OUString WCARD7 ( rtl::OUString::createFromAscii( ".svn" ) );
69 		static rtl::OUString WCARD8 ( rtl::OUString::createFromAscii( ".hg" ) );
70 
71 
72 		if( sDirName.indexOf( WCARD1 , 0 ) > -1 ||
73 			sDirName.indexOf( WCARD2 , 0 ) > -1 ||
74 			sDirName.indexOf( WCARD3 , 0 ) > -1 ||
75 			sDirName.indexOf( WCARD4 , 0 ) > -1 ||
76 			sDirName.indexOf( WCARD5 , 0 ) > -1 ||
77 			sDirName.indexOf( WCARD6 , 0 ) > -1 ||
78 			sDirName.indexOf( WCARD7 , 0 ) > -1 ||
79 			sDirName.indexOf( WCARD8 , 0 ) > -1
80 		   )	return;
81 		//printf("**** %s \n", OUStringToOString( sDirName , RTL_TEXTENCODING_UTF8 , sDirName.getLength() ).getStr() );
82 
83         rtl::OUString sDirNameTmp = aDirectory.getFullName();
84         ByteString sDirNameTmpB( rtl::OUStringToOString( sDirNameTmp , RTL_TEXTENCODING_UTF8 , sDirName.getLength() ).getStr() );
85 
86 #ifdef WNT
87         sDirNameTmpB.Append( ByteString("\\no_localization") );
88 #else
89         sDirNameTmpB.Append( ByteString("/no_localization") );
90 #endif
91         //printf("**** %s \n", OUStringToOString( sDirNameTmp , RTL_TEXTENCODING_UTF8 , sDirName.getLength() ).getStr() );
92 
93         DirEntry aDE( sDirNameTmpB.GetBuffer() );
94         if( aDE.Exists() )
95         {
96             //printf("#### no_localization file found ... skipping");
97             return;
98         }
99 
100         aDirectory.setSkipLinks( bSkipLinks );
101         aDirectory.readDirectory();
102         OnExecuteDirectory( aDirectory.getFullName() );
103         if ( aDirectory.getSubDirectories().size() )
104 			for ( sal_uLong i=0;i < aDirectory.getSubDirectories().size();i++ )
105 				ExecuteDirectory( aDirectory.getSubDirectories()[ i ] );
106 	}
107 }
108 
109 /*****************************************************************************/
StartExecute()110 sal_Bool SourceTreeIterator::StartExecute()
111 /*****************************************************************************/
112 {
113 
114 	bInExecute = sal_True;                  // FIXME
115 	ExecuteDirectory( aRootDirectory );
116 
117 	if ( bInExecute ) {                 // FIXME
118 		bInExecute = sal_False;
119 		return sal_True;
120 	}
121 	return sal_False;
122 }
123 
124 /*****************************************************************************/
EndExecute()125 void SourceTreeIterator::EndExecute()
126 /*****************************************************************************/
127 {
128 	bInExecute = sal_False;
129 }
130 
131 /*****************************************************************************/
OnExecuteDirectory(const rtl::OUString & rDirectory)132 void SourceTreeIterator::OnExecuteDirectory( const rtl::OUString &rDirectory )
133 /*****************************************************************************/
134 {
135 	fprintf( stdout, "%s\n", rtl::OUStringToOString( rDirectory, RTL_TEXTENCODING_UTF8, rDirectory.getLength() ).getStr() );
136 }
137