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: tlog.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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_soltools.hxx"
41 // <method_initialize>
42 void tLog::initialize( const ::rtl::OString
& name
) {
43 m_logname
= cnvrtPth( name
);
44 m_logfile
= new ::osl::File( m_logname
);
45 } // </method_initialize>
48 ::osl::FileBase::RC
tLog::open( sal_Bool append
) {
51 ::osl::FileBase::RC ret
;
54 ret
= ::osl::File::remove( m_logname
);
57 if( m_logfile
->open( OpenFlag_Write
) == ::osl::FileBase::E_NOENT
) {
58 ret
= m_logfile
->open( OpenFlag_Write
| OpenFlag_Create
);
61 ret
= m_logfile
->setPos( Pos_End
, 0 );
65 return ( ::osl::FileBase::E_INVAL
);
69 ::osl::FileBase::RC
tLog::close() {
71 return m_logfile
->close();
73 return ( ::osl::FileBase::E_INVAL
);
77 ::osl::FileBase::RC
tLog::writeRes( ::rtl::TestResult
& oRes
, sal_Bool v
, sal_Bool xml
) {
78 ::osl::FileBase::RC ret
;
80 sal_Char
* ptr
= oRes
.getName();
81 ptr
= cat( ptr
, ";" );
82 ptr
= cat( ptr
, oRes
.getResult() );
83 ret
= write( cat( ptr
, "\n" ), v
);
87 } // </method_writeRes>
90 ::osl::FileBase::RC
tLog::write( const sal_Char
* buf
, sal_Bool v
) {
93 fprintf( stderr
, "%s", buf
);
94 return ( ::osl::FileBase::E_NOENT
);
97 sal_uInt32 len
= ln( buf
);
98 const sal_Char
* ptr
= buf
;
101 fprintf( stderr
, "%s", buf
);
103 return m_logfile
->write( buf
, len
, uBytes
);
106 } // </namespace_tstutl>