xref: /trunk/main/l10ntools/source/srciter.cxx (revision 3cd96b95)
1*3cd96b95SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*3cd96b95SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*3cd96b95SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*3cd96b95SAndrew Rist  * distributed with this work for additional information
6*3cd96b95SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*3cd96b95SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*3cd96b95SAndrew Rist  * "License"); you may not use this file except in compliance
9*3cd96b95SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*3cd96b95SAndrew Rist  *
11*3cd96b95SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*3cd96b95SAndrew Rist  *
13*3cd96b95SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*3cd96b95SAndrew Rist  * software distributed under the License is distributed on an
15*3cd96b95SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*3cd96b95SAndrew Rist  * KIND, either express or implied.  See the License for the
17*3cd96b95SAndrew Rist  * specific language governing permissions and limitations
18*3cd96b95SAndrew Rist  * under the License.
19*3cd96b95SAndrew Rist  *
20*3cd96b95SAndrew Rist  *************************************************************/
21*3cd96b95SAndrew Rist 
22*3cd96b95SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_l10ntools.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "srciter.hxx"
28cdf0e10cSrcweir #include <stdio.h>
29cdf0e10cSrcweir #include <tools/fsys.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir //
32cdf0e10cSrcweir // class SourceTreeIterator
33cdf0e10cSrcweir //
34cdf0e10cSrcweir 
35cdf0e10cSrcweir /*****************************************************************************/
SourceTreeIterator(const ByteString & rRootDirectory,const ByteString & rVersion,bool bLocal_in)36cdf0e10cSrcweir SourceTreeIterator::SourceTreeIterator(
37cdf0e10cSrcweir 	const ByteString &rRootDirectory, const ByteString &rVersion , bool bLocal_in )
38cdf0e10cSrcweir /*****************************************************************************/
39cdf0e10cSrcweir 				: bInExecute( sal_False ) , bLocal( bLocal_in )
40cdf0e10cSrcweir {
41cdf0e10cSrcweir 	(void) rVersion ;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir     if(!bLocal){
44cdf0e10cSrcweir         rtl::OUString sRootDirectory( rRootDirectory.GetBuffer() , rRootDirectory.Len() , RTL_TEXTENCODING_UTF8 );
45cdf0e10cSrcweir         aRootDirectory = transex::Directory( sRootDirectory );
46cdf0e10cSrcweir 	}
47cdf0e10cSrcweir }
48cdf0e10cSrcweir 
49cdf0e10cSrcweir /*****************************************************************************/
~SourceTreeIterator()50cdf0e10cSrcweir SourceTreeIterator::~SourceTreeIterator()
51cdf0e10cSrcweir /*****************************************************************************/
52cdf0e10cSrcweir {
53cdf0e10cSrcweir }
54cdf0e10cSrcweir 
55cdf0e10cSrcweir /*****************************************************************************/
ExecuteDirectory(transex::Directory & aDirectory)56cdf0e10cSrcweir void SourceTreeIterator::ExecuteDirectory( transex::Directory& aDirectory )
57cdf0e10cSrcweir /*****************************************************************************/
58cdf0e10cSrcweir {
59cdf0e10cSrcweir     if ( bInExecute ) {
60cdf0e10cSrcweir 		rtl::OUString sDirName = aDirectory.getDirectoryName();
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 		static rtl::OUString WCARD1 ( rtl::OUString::createFromAscii( "unxlng" ) );
63cdf0e10cSrcweir 		static rtl::OUString WCARD2 ( rtl::OUString::createFromAscii( "unxsol" ) );
64cdf0e10cSrcweir 		static rtl::OUString WCARD3 ( rtl::OUString::createFromAscii( "wntmsc" ) );
65cdf0e10cSrcweir 		static rtl::OUString WCARD4 ( rtl::OUString::createFromAscii( "common" ) );
66cdf0e10cSrcweir 		static rtl::OUString WCARD5 ( rtl::OUString::createFromAscii( "unxmac" ) );
67cdf0e10cSrcweir 		static rtl::OUString WCARD6 ( rtl::OUString::createFromAscii( "unxubt" ) );
68cdf0e10cSrcweir 		static rtl::OUString WCARD7 ( rtl::OUString::createFromAscii( ".svn" ) );
69cdf0e10cSrcweir 		static rtl::OUString WCARD8 ( rtl::OUString::createFromAscii( ".hg" ) );
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 		if( sDirName.indexOf( WCARD1 , 0 ) > -1 ||
73cdf0e10cSrcweir 			sDirName.indexOf( WCARD2 , 0 ) > -1 ||
74cdf0e10cSrcweir 			sDirName.indexOf( WCARD3 , 0 ) > -1 ||
75cdf0e10cSrcweir 			sDirName.indexOf( WCARD4 , 0 ) > -1 ||
76cdf0e10cSrcweir 			sDirName.indexOf( WCARD5 , 0 ) > -1 ||
77cdf0e10cSrcweir 			sDirName.indexOf( WCARD6 , 0 ) > -1 ||
78cdf0e10cSrcweir 			sDirName.indexOf( WCARD7 , 0 ) > -1 ||
79cdf0e10cSrcweir 			sDirName.indexOf( WCARD8 , 0 ) > -1
80cdf0e10cSrcweir 		   )	return;
81cdf0e10cSrcweir 		//printf("**** %s \n", OUStringToOString( sDirName , RTL_TEXTENCODING_UTF8 , sDirName.getLength() ).getStr() );
82cdf0e10cSrcweir 
83cdf0e10cSrcweir         rtl::OUString sDirNameTmp = aDirectory.getFullName();
84cdf0e10cSrcweir         ByteString sDirNameTmpB( rtl::OUStringToOString( sDirNameTmp , RTL_TEXTENCODING_UTF8 , sDirName.getLength() ).getStr() );
85cdf0e10cSrcweir 
86cdf0e10cSrcweir #ifdef WNT
87cdf0e10cSrcweir         sDirNameTmpB.Append( ByteString("\\no_localization") );
88cdf0e10cSrcweir #else
89cdf0e10cSrcweir         sDirNameTmpB.Append( ByteString("/no_localization") );
90cdf0e10cSrcweir #endif
91cdf0e10cSrcweir         //printf("**** %s \n", OUStringToOString( sDirNameTmp , RTL_TEXTENCODING_UTF8 , sDirName.getLength() ).getStr() );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir         DirEntry aDE( sDirNameTmpB.GetBuffer() );
94cdf0e10cSrcweir         if( aDE.Exists() )
95cdf0e10cSrcweir         {
96cdf0e10cSrcweir             //printf("#### no_localization file found ... skipping");
97cdf0e10cSrcweir             return;
98cdf0e10cSrcweir         }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir         aDirectory.setSkipLinks( bSkipLinks );
101cdf0e10cSrcweir         aDirectory.readDirectory();
102cdf0e10cSrcweir         OnExecuteDirectory( aDirectory.getFullName() );
103cdf0e10cSrcweir         if ( aDirectory.getSubDirectories().size() )
104cdf0e10cSrcweir 			for ( sal_uLong i=0;i < aDirectory.getSubDirectories().size();i++ )
105cdf0e10cSrcweir 				ExecuteDirectory( aDirectory.getSubDirectories()[ i ] );
106cdf0e10cSrcweir 	}
107cdf0e10cSrcweir }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir /*****************************************************************************/
StartExecute()110cdf0e10cSrcweir sal_Bool SourceTreeIterator::StartExecute()
111cdf0e10cSrcweir /*****************************************************************************/
112cdf0e10cSrcweir {
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	bInExecute = sal_True;                  // FIXME
115cdf0e10cSrcweir 	ExecuteDirectory( aRootDirectory );
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	if ( bInExecute ) {                 // FIXME
118cdf0e10cSrcweir 		bInExecute = sal_False;
119cdf0e10cSrcweir 		return sal_True;
120cdf0e10cSrcweir 	}
121cdf0e10cSrcweir 	return sal_False;
122cdf0e10cSrcweir }
123cdf0e10cSrcweir 
124cdf0e10cSrcweir /*****************************************************************************/
EndExecute()125cdf0e10cSrcweir void SourceTreeIterator::EndExecute()
126cdf0e10cSrcweir /*****************************************************************************/
127cdf0e10cSrcweir {
128cdf0e10cSrcweir 	bInExecute = sal_False;
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir /*****************************************************************************/
OnExecuteDirectory(const rtl::OUString & rDirectory)132cdf0e10cSrcweir void SourceTreeIterator::OnExecuteDirectory( const rtl::OUString &rDirectory )
133cdf0e10cSrcweir /*****************************************************************************/
134cdf0e10cSrcweir {
135cdf0e10cSrcweir 	fprintf( stdout, "%s\n", rtl::OUStringToOString( rDirectory, RTL_TEXTENCODING_UTF8, rDirectory.getLength() ).getStr() );
136cdf0e10cSrcweir }
137