1*d9e04f7dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*d9e04f7dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*d9e04f7dSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*d9e04f7dSAndrew Rist * distributed with this work for additional information
6*d9e04f7dSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*d9e04f7dSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*d9e04f7dSAndrew Rist * "License"); you may not use this file except in compliance
9*d9e04f7dSAndrew Rist * with the License. You may obtain a copy of the License at
10*d9e04f7dSAndrew Rist *
11*d9e04f7dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*d9e04f7dSAndrew Rist *
13*d9e04f7dSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*d9e04f7dSAndrew Rist * software distributed under the License is distributed on an
15*d9e04f7dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d9e04f7dSAndrew Rist * KIND, either express or implied. See the License for the
17*d9e04f7dSAndrew Rist * specific language governing permissions and limitations
18*d9e04f7dSAndrew Rist * under the License.
19*d9e04f7dSAndrew Rist *
20*d9e04f7dSAndrew Rist *************************************************************/
21*d9e04f7dSAndrew Rist
22*d9e04f7dSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir #include "minormk.hxx"
25cdf0e10cSrcweir #include "prodmap.hxx"
26cdf0e10cSrcweir #include <soldep/appdef.hxx>
27cdf0e10cSrcweir #include <tools/fsys.hxx>
28cdf0e10cSrcweir #include <tools/geninfo.hxx>
29cdf0e10cSrcweir
30cdf0e10cSrcweir //
31cdf0e10cSrcweir // class MinorMk
32cdf0e10cSrcweir //
33cdf0e10cSrcweir
34cdf0e10cSrcweir /*****************************************************************************/
MinorMk(GenericInformationList * pList,const ByteString & rVersion,const ByteString & rWorkStamp,const ByteString & rEnvironment,const ByteString & rMinor)35cdf0e10cSrcweir MinorMk::MinorMk(
36cdf0e10cSrcweir GenericInformationList *pList,
37cdf0e10cSrcweir const ByteString &rVersion,
38cdf0e10cSrcweir const ByteString &rWorkStamp,
39cdf0e10cSrcweir const ByteString &rEnvironment,
40cdf0e10cSrcweir const ByteString &rMinor
41cdf0e10cSrcweir )
42cdf0e10cSrcweir /*****************************************************************************/
43cdf0e10cSrcweir {
44cdf0e10cSrcweir String sRoot( ProductMapper::GetVersionRoot( pList, rVersion ));
45cdf0e10cSrcweir if ( sRoot.Len()) {
46cdf0e10cSrcweir ByteString sPath( sRoot, RTL_TEXTENCODING_ASCII_US );
47cdf0e10cSrcweir sPath += "/";
48cdf0e10cSrcweir sPath += rEnvironment;
49cdf0e10cSrcweir sPath += "/";
50cdf0e10cSrcweir sPath += "inc";
51cdf0e10cSrcweir if ( rMinor.Len()) {
52cdf0e10cSrcweir sPath += ".";
53cdf0e10cSrcweir sPath += rMinor;
54cdf0e10cSrcweir }
55cdf0e10cSrcweir #ifdef UNX
56cdf0e10cSrcweir sPath.SearchAndReplaceAll( "\\", "/" );
57cdf0e10cSrcweir while( sPath.SearchAndReplace( "//", "/" ) != STRING_NOTFOUND ) {};
58cdf0e10cSrcweir #else
59cdf0e10cSrcweir sPath.SearchAndReplaceAll( "/", "\\" );
60cdf0e10cSrcweir while( sPath.SearchAndReplace( "\\\\", "\\" ) != STRING_NOTFOUND ) {};
61cdf0e10cSrcweir #endif
62cdf0e10cSrcweir DirEntry aPath( String( sPath, RTL_TEXTENCODING_ASCII_US ));
63cdf0e10cSrcweir
64cdf0e10cSrcweir ByteString sFile( rWorkStamp );
65cdf0e10cSrcweir sFile += "minor.mk";
66cdf0e10cSrcweir
67cdf0e10cSrcweir DirEntry aFile( aPath );
68cdf0e10cSrcweir aFile += DirEntry( String( sFile, RTL_TEXTENCODING_ASCII_US ));
69cdf0e10cSrcweir if ( !aFile.Exists()) {
70cdf0e10cSrcweir sFile = sFile.Copy( 3 );
71cdf0e10cSrcweir aFile = aPath;
72cdf0e10cSrcweir aFile += DirEntry( String( sFile, RTL_TEXTENCODING_ASCII_US ));
73cdf0e10cSrcweir }
74cdf0e10cSrcweir ReadMinorMk( aFile.GetFull());
75cdf0e10cSrcweir }
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
78cdf0e10cSrcweir /*****************************************************************************/
MinorMk(GenericInformationList * pList,const ByteString rVersion)79cdf0e10cSrcweir MinorMk::MinorMk( GenericInformationList *pList, const ByteString rVersion )
80cdf0e10cSrcweir /*****************************************************************************/
81cdf0e10cSrcweir {
82cdf0e10cSrcweir String sRoot( ProductMapper::GetVersionRoot( pList, rVersion ));
83cdf0e10cSrcweir if ( sRoot.Len()) {
84cdf0e10cSrcweir ByteString sPath( sRoot, RTL_TEXTENCODING_ASCII_US );
85cdf0e10cSrcweir sPath += "/src/solenv/inc";
86cdf0e10cSrcweir #ifdef UNX
87cdf0e10cSrcweir sPath.SearchAndReplaceAll( "\\", "/" );
88cdf0e10cSrcweir while( sPath.SearchAndReplace( "//", "/" ) != STRING_NOTFOUND ) {};
89cdf0e10cSrcweir #else
90cdf0e10cSrcweir sPath.SearchAndReplaceAll( "/", "\\" );
91cdf0e10cSrcweir while( sPath.SearchAndReplace( "\\\\", "\\" ) != STRING_NOTFOUND ) {};
92cdf0e10cSrcweir #endif
93cdf0e10cSrcweir DirEntry aPath( String( sPath, RTL_TEXTENCODING_ASCII_US ));
94cdf0e10cSrcweir
95cdf0e10cSrcweir ByteString sFile( "minor.mk" );
96cdf0e10cSrcweir
97cdf0e10cSrcweir DirEntry aFile( aPath );
98cdf0e10cSrcweir aFile += DirEntry( String( sFile, RTL_TEXTENCODING_ASCII_US ));
99cdf0e10cSrcweir
100cdf0e10cSrcweir ReadMinorMk( aFile.GetFull());
101cdf0e10cSrcweir }
102cdf0e10cSrcweir }
103cdf0e10cSrcweir
104cdf0e10cSrcweir /*****************************************************************************/
MinorMk(const ByteString & rMinor,const ByteString & rEnvironment)105cdf0e10cSrcweir MinorMk::MinorMk( const ByteString &rMinor, const ByteString &rEnvironment )
106cdf0e10cSrcweir /*****************************************************************************/
107cdf0e10cSrcweir : bExists( sal_False )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir ByteString sDelimiter( DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US );
110cdf0e10cSrcweir
111cdf0e10cSrcweir
112cdf0e10cSrcweir ByteString sSolver( GetEnv( "SOLARVERSION" ));
113cdf0e10cSrcweir sal_Bool bNewEnv = sal_True;
114cdf0e10cSrcweir if ( !sSolver.Len()) {
115cdf0e10cSrcweir sSolver = GetEnv( "SOLARVER" );
116cdf0e10cSrcweir bNewEnv = sal_False;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir ByteString sUPD( GetEnv( "UPD" ));
119cdf0e10cSrcweir
120cdf0e10cSrcweir ByteString sMinorMk( sSolver );
121cdf0e10cSrcweir sMinorMk += sDelimiter;
122cdf0e10cSrcweir if ( !bNewEnv ) {
123cdf0e10cSrcweir sMinorMk += sUPD;
124cdf0e10cSrcweir sMinorMk += sDelimiter;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir
127cdf0e10cSrcweir if ( rEnvironment.Len()) {
128cdf0e10cSrcweir sMinorMk += rEnvironment;
129cdf0e10cSrcweir sMinorMk += sDelimiter;
130cdf0e10cSrcweir sMinorMk += "inc";
131cdf0e10cSrcweir if( rMinor.Len()) {
132cdf0e10cSrcweir sMinorMk += ".";
133cdf0e10cSrcweir sMinorMk += rMinor;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir sMinorMk += sDelimiter;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir
138cdf0e10cSrcweir sMinorMk += sUPD;
139cdf0e10cSrcweir sMinorMk += "minor.mk";
140cdf0e10cSrcweir
141cdf0e10cSrcweir String sFile( sMinorMk, RTL_TEXTENCODING_ASCII_US );
142cdf0e10cSrcweir
143cdf0e10cSrcweir ReadMinorMk( sFile );
144cdf0e10cSrcweir }
145cdf0e10cSrcweir
146cdf0e10cSrcweir /*****************************************************************************/
ReadMinorMk(const String & rFileName)147cdf0e10cSrcweir void MinorMk::ReadMinorMk( const String &rFileName )
148cdf0e10cSrcweir /*****************************************************************************/
149cdf0e10cSrcweir {
150cdf0e10cSrcweir if ( DirEntry( rFileName ).Exists()) {
151cdf0e10cSrcweir bExists = sal_True;
152cdf0e10cSrcweir SvFileStream aStream( rFileName, STREAM_STD_READ );
153cdf0e10cSrcweir while ( !aStream.IsOpen())
154cdf0e10cSrcweir aStream.Open( rFileName, STREAM_STD_READ );
155cdf0e10cSrcweir
156cdf0e10cSrcweir ByteString sLine;
157cdf0e10cSrcweir while ( !aStream.IsEof()) {
158cdf0e10cSrcweir aStream.ReadLine( sLine );
159cdf0e10cSrcweir
160cdf0e10cSrcweir if ( sLine.GetToken( 0, '=' ) == "RSCVERSION" )
161cdf0e10cSrcweir sRSCVERSION = sLine.GetToken( 1, '=' );
162cdf0e10cSrcweir else if ( sLine.GetToken( 0, '=' ) == "RSCREVISION" )
163cdf0e10cSrcweir sRSCREVISION = sLine.GetToken( 1, '=' );
164cdf0e10cSrcweir else if ( sLine.GetToken( 0, '=' ) == "BUILD" )
165cdf0e10cSrcweir sBUILD = sLine.GetToken( 1, '=' );
166cdf0e10cSrcweir else if ( sLine.GetToken( 0, '=' ) == "LAST_MINOR" )
167cdf0e10cSrcweir sLAST_MINOR = sLine.GetToken( 1, '=' );
168cdf0e10cSrcweir }
169cdf0e10cSrcweir aStream.Close();
170cdf0e10cSrcweir
171cdf0e10cSrcweir sRSCVERSION.EraseTrailingChars();
172cdf0e10cSrcweir sRSCREVISION.EraseTrailingChars();
173cdf0e10cSrcweir sBUILD.EraseTrailingChars();
174cdf0e10cSrcweir sLAST_MINOR.EraseTrailingChars();
175cdf0e10cSrcweir }
176cdf0e10cSrcweir }
177cdf0e10cSrcweir
178cdf0e10cSrcweir /*****************************************************************************/
~MinorMk()179cdf0e10cSrcweir MinorMk::~MinorMk()
180cdf0e10cSrcweir /*****************************************************************************/
181cdf0e10cSrcweir {
182cdf0e10cSrcweir }
183cdf0e10cSrcweir
184