merged tag ooo/OOO330_m14
[LibreOffice.git] / soldep / bootstrp / minormk.cxx
blob8c08d3a69840348ad7bbcbc532eb1edddfda2c8a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #include "minormk.hxx"
29 #include "prodmap.hxx"
30 #include <appdef.hxx>
31 #include <tools/fsys.hxx>
32 #include <tools/geninfo.hxx>
35 // class MinorMk
38 /*****************************************************************************/
39 MinorMk::MinorMk(
40 GenericInformationList *pList,
41 const ByteString &rVersion,
42 const ByteString &rWorkStamp,
43 const ByteString &rEnvironment,
44 const ByteString &rMinor
46 /*****************************************************************************/
48 String sRoot( ProductMapper::GetVersionRoot( pList, rVersion ));
49 if ( sRoot.Len()) {
50 ByteString sPath( sRoot, RTL_TEXTENCODING_ASCII_US );
51 sPath += "/";
52 sPath += rEnvironment;
53 sPath += "/";
54 sPath += "inc";
55 if ( rMinor.Len()) {
56 sPath += ".";
57 sPath += rMinor;
59 #ifdef UNX
60 sPath.SearchAndReplaceAll( "\\", "/" );
61 while( sPath.SearchAndReplace( "//", "/" ) != STRING_NOTFOUND ) {};
62 #else
63 sPath.SearchAndReplaceAll( "/", "\\" );
64 while( sPath.SearchAndReplace( "\\\\", "\\" ) != STRING_NOTFOUND ) {};
65 #endif
66 DirEntry aPath( String( sPath, RTL_TEXTENCODING_ASCII_US ));
68 ByteString sFile( rWorkStamp );
69 sFile += "minor.mk";
71 DirEntry aFile( aPath );
72 aFile += DirEntry( String( sFile, RTL_TEXTENCODING_ASCII_US ));
73 if ( !aFile.Exists()) {
74 sFile = sFile.Copy( 3 );
75 aFile = aPath;
76 aFile += DirEntry( String( sFile, RTL_TEXTENCODING_ASCII_US ));
78 ReadMinorMk( aFile.GetFull());
82 /*****************************************************************************/
83 MinorMk::MinorMk( GenericInformationList *pList, const ByteString rVersion )
84 /*****************************************************************************/
86 String sRoot( ProductMapper::GetVersionRoot( pList, rVersion ));
87 if ( sRoot.Len()) {
88 ByteString sPath( sRoot, RTL_TEXTENCODING_ASCII_US );
89 sPath += "/src/solenv/inc";
90 #ifdef UNX
91 sPath.SearchAndReplaceAll( "\\", "/" );
92 while( sPath.SearchAndReplace( "//", "/" ) != STRING_NOTFOUND ) {};
93 #else
94 sPath.SearchAndReplaceAll( "/", "\\" );
95 while( sPath.SearchAndReplace( "\\\\", "\\" ) != STRING_NOTFOUND ) {};
96 #endif
97 DirEntry aPath( String( sPath, RTL_TEXTENCODING_ASCII_US ));
99 ByteString sFile( "minor.mk" );
101 DirEntry aFile( aPath );
102 aFile += DirEntry( String( sFile, RTL_TEXTENCODING_ASCII_US ));
104 ReadMinorMk( aFile.GetFull());
108 /*****************************************************************************/
109 MinorMk::MinorMk( const ByteString &rMinor, const ByteString &rEnvironment )
110 /*****************************************************************************/
111 : bExists( FALSE )
113 ByteString sDelimiter( DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US );
116 ByteString sSolver( GetEnv( "SOLARVERSION" ));
117 BOOL bNewEnv = TRUE;
118 if ( !sSolver.Len()) {
119 sSolver = GetEnv( "SOLARVER" );
120 bNewEnv = FALSE;
122 ByteString sUPD( GetEnv( "UPD" ));
124 ByteString sMinorMk( sSolver );
125 sMinorMk += sDelimiter;
126 if ( !bNewEnv ) {
127 sMinorMk += sUPD;
128 sMinorMk += sDelimiter;
131 if ( rEnvironment.Len()) {
132 sMinorMk += rEnvironment;
133 sMinorMk += sDelimiter;
134 sMinorMk += "inc";
135 if( rMinor.Len()) {
136 sMinorMk += ".";
137 sMinorMk += rMinor;
139 sMinorMk += sDelimiter;
142 sMinorMk += sUPD;
143 sMinorMk += "minor.mk";
145 String sFile( sMinorMk, RTL_TEXTENCODING_ASCII_US );
147 ReadMinorMk( sFile );
150 /*****************************************************************************/
151 void MinorMk::ReadMinorMk( const String &rFileName )
152 /*****************************************************************************/
154 if ( DirEntry( rFileName ).Exists()) {
155 bExists = TRUE;
156 SvFileStream aStream( rFileName, STREAM_STD_READ );
157 while ( !aStream.IsOpen())
158 aStream.Open( rFileName, STREAM_STD_READ );
160 ByteString sLine;
161 while ( !aStream.IsEof()) {
162 aStream.ReadLine( sLine );
164 if ( sLine.GetToken( 0, '=' ) == "RSCVERSION" )
165 sRSCVERSION = sLine.GetToken( 1, '=' );
166 else if ( sLine.GetToken( 0, '=' ) == "RSCREVISION" )
167 sRSCREVISION = sLine.GetToken( 1, '=' );
168 else if ( sLine.GetToken( 0, '=' ) == "BUILD" )
169 sBUILD = sLine.GetToken( 1, '=' );
170 else if ( sLine.GetToken( 0, '=' ) == "LAST_MINOR" )
171 sLAST_MINOR = sLine.GetToken( 1, '=' );
173 aStream.Close();
175 sRSCVERSION.EraseTrailingChars();
176 sRSCREVISION.EraseTrailingChars();
177 sBUILD.EraseTrailingChars();
178 sLAST_MINOR.EraseTrailingChars();
182 /*****************************************************************************/
183 MinorMk::~MinorMk()
184 /*****************************************************************************/