xref: /aoo42x/main/l10ntools/source/srciter.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_l10ntools.hxx"
30 
31 #include "srciter.hxx"
32 #include <stdio.h>
33 #include <tools/fsys.hxx>
34 
35 //
36 // class SourceTreeIterator
37 //
38 
39 /*****************************************************************************/
40 SourceTreeIterator::SourceTreeIterator(
41 	const ByteString &rRootDirectory, const ByteString &rVersion , bool bLocal_in )
42 /*****************************************************************************/
43 				: bInExecute( sal_False ) , bLocal( bLocal_in )
44 {
45 	(void) rVersion ;
46 
47     if(!bLocal){
48         rtl::OUString sRootDirectory( rRootDirectory.GetBuffer() , rRootDirectory.Len() , RTL_TEXTENCODING_UTF8 );
49         aRootDirectory = transex::Directory( sRootDirectory );
50 	}
51 }
52 
53 /*****************************************************************************/
54 SourceTreeIterator::~SourceTreeIterator()
55 /*****************************************************************************/
56 {
57 }
58 
59 /*****************************************************************************/
60 void SourceTreeIterator::ExecuteDirectory( transex::Directory& aDirectory )
61 /*****************************************************************************/
62 {
63     if ( bInExecute ) {
64 		rtl::OUString sDirName = aDirectory.getDirectoryName();
65 
66 		static rtl::OUString WCARD1 ( rtl::OUString::createFromAscii( "unxlng" ) );
67 		static rtl::OUString WCARD2 ( rtl::OUString::createFromAscii( "unxsol" ) );
68 		static rtl::OUString WCARD3 ( rtl::OUString::createFromAscii( "wntmsc" ) );
69 		static rtl::OUString WCARD4 ( rtl::OUString::createFromAscii( "common" ) );
70 		static rtl::OUString WCARD5 ( rtl::OUString::createFromAscii( "unxmac" ) );
71 		static rtl::OUString WCARD6 ( rtl::OUString::createFromAscii( "unxubt" ) );
72 		static rtl::OUString WCARD7 ( rtl::OUString::createFromAscii( ".svn" ) );
73 		static rtl::OUString WCARD8 ( rtl::OUString::createFromAscii( ".hg" ) );
74 
75 
76 		if( sDirName.indexOf( WCARD1 , 0 ) > -1 ||
77 			sDirName.indexOf( WCARD2 , 0 ) > -1 ||
78 			sDirName.indexOf( WCARD3 , 0 ) > -1 ||
79 			sDirName.indexOf( WCARD4 , 0 ) > -1 ||
80 			sDirName.indexOf( WCARD5 , 0 ) > -1 ||
81 			sDirName.indexOf( WCARD6 , 0 ) > -1 ||
82 			sDirName.indexOf( WCARD7 , 0 ) > -1 ||
83 			sDirName.indexOf( WCARD8 , 0 ) > -1
84 		   )	return;
85 		//printf("**** %s \n", OUStringToOString( sDirName , RTL_TEXTENCODING_UTF8 , sDirName.getLength() ).getStr() );
86 
87         rtl::OUString sDirNameTmp = aDirectory.getFullName();
88         ByteString sDirNameTmpB( rtl::OUStringToOString( sDirNameTmp , RTL_TEXTENCODING_UTF8 , sDirName.getLength() ).getStr() );
89 
90 #ifdef WNT
91         sDirNameTmpB.Append( ByteString("\\no_localization") );
92 #else
93         sDirNameTmpB.Append( ByteString("/no_localization") );
94 #endif
95         //printf("**** %s \n", OUStringToOString( sDirNameTmp , RTL_TEXTENCODING_UTF8 , sDirName.getLength() ).getStr() );
96 
97         DirEntry aDE( sDirNameTmpB.GetBuffer() );
98         if( aDE.Exists() )
99         {
100             //printf("#### no_localization file found ... skipping");
101             return;
102         }
103 
104         aDirectory.setSkipLinks( bSkipLinks );
105         aDirectory.readDirectory();
106         OnExecuteDirectory( aDirectory.getFullName() );
107         if ( aDirectory.getSubDirectories().size() )
108 			for ( sal_uLong i=0;i < aDirectory.getSubDirectories().size();i++ )
109 				ExecuteDirectory( aDirectory.getSubDirectories()[ i ] );
110 	}
111 }
112 
113 /*****************************************************************************/
114 sal_Bool SourceTreeIterator::StartExecute()
115 /*****************************************************************************/
116 {
117 
118 	bInExecute = sal_True;                  // FIXME
119 	ExecuteDirectory( aRootDirectory );
120 
121 	if ( bInExecute ) {                 // FIXME
122 		bInExecute = sal_False;
123 		return sal_True;
124 	}
125 	return sal_False;
126 }
127 
128 /*****************************************************************************/
129 void SourceTreeIterator::EndExecute()
130 /*****************************************************************************/
131 {
132 	bInExecute = sal_False;
133 }
134 
135 /*****************************************************************************/
136 void SourceTreeIterator::OnExecuteDirectory( const rtl::OUString &rDirectory )
137 /*****************************************************************************/
138 {
139 	fprintf( stdout, "%s\n", rtl::OUStringToOString( rDirectory, RTL_TEXTENCODING_UTF8, rDirectory.getLength() ).getStr() );
140 }
141