xref: /trunk/main/ucb/source/ucp/file/filrec.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 #ifndef _FILREC_HXX_
29 #define _FILREC_HXX_
30 
31 #include <osl/file.hxx>
32 
33 namespace fileaccess {
34 
35 class ReconnectingFile
36 {
37     ::osl::File     m_aFile;
38 
39     sal_uInt32      m_nFlags;
40     sal_Bool        m_bFlagsSet;
41 
42     sal_Bool        m_bDisconnect;
43 
44 	ReconnectingFile( ReconnectingFile& );
45 
46 	ReconnectingFile& operator=( ReconnectingFile& );
47 
48 public:
49 
50     ReconnectingFile( const ::rtl::OUString& aFileURL )
51         : m_aFile( aFileURL )
52         , m_nFlags( 0 )
53         , m_bFlagsSet( sal_False )
54         , m_bDisconnect( sal_False )
55     {}
56 
57 	~ReconnectingFile()
58 	{
59 		close();
60 	}
61 
62     void disconnect();
63     sal_Bool reconnect();
64 
65     ::osl::FileBase::RC open( sal_uInt32 uFlags );
66 
67     ::osl::FileBase::RC close();
68 
69     ::osl::FileBase::RC setPos( sal_uInt32 uHow, sal_Int64 uPos );
70 
71     ::osl::FileBase::RC getPos( sal_uInt64& uPos );
72 
73     ::osl::FileBase::RC setSize( sal_uInt64 uSize );
74 
75     ::osl::FileBase::RC getSize( sal_uInt64 &rSize );
76 
77     ::osl::FileBase::RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead );
78 
79     ::osl::FileBase::RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten);
80 
81     ::osl::FileBase::RC sync() const;
82 };
83 
84 } // namespace fileaccess
85 #endif	// _FILREC_HXX_
86 
87