1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: minormk.cxx,v $
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"
33 #include <tools/fsys.hxx>
34 #include <tools/geninfo.hxx>
35 #include "prodmap.hxx"
41 /*****************************************************************************/
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
));
53 ByteString
sPath( sRoot
, RTL_TEXTENCODING_ASCII_US
);
55 sPath
+= rEnvironment
;
63 sPath
.SearchAndReplaceAll( "\\", "/" );
64 while( sPath
.SearchAndReplace( "//", "/" ) != STRING_NOTFOUND
) {};
66 sPath
.SearchAndReplaceAll( "/", "\\" );
67 while( sPath
.SearchAndReplace( "\\\\", "\\" ) != STRING_NOTFOUND
) {};
69 DirEntry
aPath( String( sPath
, RTL_TEXTENCODING_ASCII_US
));
71 ByteString
sFile( rWorkStamp
);
74 DirEntry
aFile( aPath
);
75 aFile
+= DirEntry( String( sFile
, RTL_TEXTENCODING_ASCII_US
));
76 if ( !aFile
.Exists()) {
77 sFile
= sFile
.Copy( 3 );
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
));
91 ByteString
sPath( sRoot
, RTL_TEXTENCODING_ASCII_US
);
92 sPath
+= "/src/solenv/inc";
94 sPath
.SearchAndReplaceAll( "\\", "/" );
95 while( sPath
.SearchAndReplace( "//", "/" ) != STRING_NOTFOUND
) {};
97 sPath
.SearchAndReplaceAll( "/", "\\" );
98 while( sPath
.SearchAndReplace( "\\\\", "\\" ) != STRING_NOTFOUND
) {};
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 /*****************************************************************************/
116 ByteString
sDelimiter( DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US
);
119 ByteString
sSolver( GetEnv( "SOLARVERSION" ));
121 if ( !sSolver
.Len()) {
122 sSolver
= GetEnv( "SOLARVER" );
125 ByteString
sUPD( GetEnv( "UPD" ));
127 ByteString
sMinorMk( sSolver
);
128 sMinorMk
+= sDelimiter
;
131 sMinorMk
+= sDelimiter
;
134 if ( rEnvironment
.Len()) {
135 sMinorMk
+= rEnvironment
;
136 sMinorMk
+= sDelimiter
;
142 sMinorMk
+= sDelimiter
;
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()) {
159 SvFileStream
aStream( rFileName
, STREAM_STD_READ
);
160 while ( !aStream
.IsOpen())
161 aStream
.Open( rFileName
, STREAM_STD_READ
);
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, '=' );
178 sRSCVERSION
.EraseTrailingChars();
179 sRSCREVISION
.EraseTrailingChars();
180 sBUILD
.EraseTrailingChars();
181 sLAST_MINOR
.EraseTrailingChars();
185 /*****************************************************************************/
187 /*****************************************************************************/