update dev300-m58
[ooovba.git] / soldep / bootstrp / minormk.cxx
blobecd34d577c7ea30042c41b384bad7856b7d84afe
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: minormk.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "minormk.hxx"
32 #include <appdef.hxx>
33 #include <tools/fsys.hxx>
34 #include <tools/geninfo.hxx>
35 #include "prodmap.hxx"
38 // class MinorMk
41 /*****************************************************************************/
42 MinorMk::MinorMk(
43 GenericInformationList *pList,
44 const ByteString &rVersion,
45 const ByteString &rWorkStamp,
46 const ByteString &rEnvironment,
47 const ByteString &rMinor
49 /*****************************************************************************/
51 String sRoot( ProductMapper::GetVersionRoot( pList, rVersion ));
52 if ( sRoot.Len()) {
53 ByteString sPath( sRoot, RTL_TEXTENCODING_ASCII_US );
54 sPath += "/";
55 sPath += rEnvironment;
56 sPath += "/";
57 sPath += "inc";
58 if ( rMinor.Len()) {
59 sPath += ".";
60 sPath += rMinor;
62 #ifdef UNX
63 sPath.SearchAndReplaceAll( "\\", "/" );
64 while( sPath.SearchAndReplace( "//", "/" ) != STRING_NOTFOUND ) {};
65 #else
66 sPath.SearchAndReplaceAll( "/", "\\" );
67 while( sPath.SearchAndReplace( "\\\\", "\\" ) != STRING_NOTFOUND ) {};
68 #endif
69 DirEntry aPath( String( sPath, RTL_TEXTENCODING_ASCII_US ));
71 ByteString sFile( rWorkStamp );
72 sFile += "minor.mk";
74 DirEntry aFile( aPath );
75 aFile += DirEntry( String( sFile, RTL_TEXTENCODING_ASCII_US ));
76 if ( !aFile.Exists()) {
77 sFile = sFile.Copy( 3 );
78 aFile = aPath;
79 aFile += DirEntry( String( sFile, RTL_TEXTENCODING_ASCII_US ));
81 ReadMinorMk( aFile.GetFull());
85 /*****************************************************************************/
86 MinorMk::MinorMk( GenericInformationList *pList, const ByteString rVersion )
87 /*****************************************************************************/
89 String sRoot( ProductMapper::GetVersionRoot( pList, rVersion ));
90 if ( sRoot.Len()) {
91 ByteString sPath( sRoot, RTL_TEXTENCODING_ASCII_US );
92 sPath += "/src/solenv/inc";
93 #ifdef UNX
94 sPath.SearchAndReplaceAll( "\\", "/" );
95 while( sPath.SearchAndReplace( "//", "/" ) != STRING_NOTFOUND ) {};
96 #else
97 sPath.SearchAndReplaceAll( "/", "\\" );
98 while( sPath.SearchAndReplace( "\\\\", "\\" ) != STRING_NOTFOUND ) {};
99 #endif
100 DirEntry aPath( String( sPath, RTL_TEXTENCODING_ASCII_US ));
102 ByteString sFile( "minor.mk" );
104 DirEntry aFile( aPath );
105 aFile += DirEntry( String( sFile, RTL_TEXTENCODING_ASCII_US ));
107 ReadMinorMk( aFile.GetFull());
111 /*****************************************************************************/
112 MinorMk::MinorMk( const ByteString &rMinor, const ByteString &rEnvironment )
113 /*****************************************************************************/
114 : bExists( FALSE )
116 ByteString sDelimiter( DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US );
119 ByteString sSolver( GetEnv( "SOLARVERSION" ));
120 BOOL bNewEnv = TRUE;
121 if ( !sSolver.Len()) {
122 sSolver = GetEnv( "SOLARVER" );
123 bNewEnv = FALSE;
125 ByteString sUPD( GetEnv( "UPD" ));
127 ByteString sMinorMk( sSolver );
128 sMinorMk += sDelimiter;
129 if ( !bNewEnv ) {
130 sMinorMk += sUPD;
131 sMinorMk += sDelimiter;
134 if ( rEnvironment.Len()) {
135 sMinorMk += rEnvironment;
136 sMinorMk += sDelimiter;
137 sMinorMk += "inc";
138 if( rMinor.Len()) {
139 sMinorMk += ".";
140 sMinorMk += rMinor;
142 sMinorMk += sDelimiter;
145 sMinorMk += sUPD;
146 sMinorMk += "minor.mk";
148 String sFile( sMinorMk, RTL_TEXTENCODING_ASCII_US );
150 ReadMinorMk( sFile );
153 /*****************************************************************************/
154 void MinorMk::ReadMinorMk( const String &rFileName )
155 /*****************************************************************************/
157 if ( DirEntry( rFileName ).Exists()) {
158 bExists = TRUE;
159 SvFileStream aStream( rFileName, STREAM_STD_READ );
160 while ( !aStream.IsOpen())
161 aStream.Open( rFileName, STREAM_STD_READ );
163 ByteString sLine;
164 while ( !aStream.IsEof()) {
165 aStream.ReadLine( sLine );
167 if ( sLine.GetToken( 0, '=' ) == "RSCVERSION" )
168 sRSCVERSION = sLine.GetToken( 1, '=' );
169 else if ( sLine.GetToken( 0, '=' ) == "RSCREVISION" )
170 sRSCREVISION = sLine.GetToken( 1, '=' );
171 else if ( sLine.GetToken( 0, '=' ) == "BUILD" )
172 sBUILD = sLine.GetToken( 1, '=' );
173 else if ( sLine.GetToken( 0, '=' ) == "LAST_MINOR" )
174 sLAST_MINOR = sLine.GetToken( 1, '=' );
176 aStream.Close();
178 sRSCVERSION.EraseTrailingChars();
179 sRSCREVISION.EraseTrailingChars();
180 sBUILD.EraseTrailingChars();
181 sLAST_MINOR.EraseTrailingChars();
185 /*****************************************************************************/
186 MinorMk::~MinorMk()
187 /*****************************************************************************/