xref: /trunk/main/ucb/source/ucp/file/filrec.hxx (revision 6df1ea1f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _FILREC_HXX_
25 #define _FILREC_HXX_
26 
27 #include <osl/file.hxx>
28 
29 namespace fileaccess {
30 
31 class ReconnectingFile
32 {
33     ::osl::File     m_aFile;
34 
35     sal_uInt32      m_nFlags;
36     sal_Bool        m_bFlagsSet;
37 
38     sal_Bool        m_bDisconnect;
39 
40 	ReconnectingFile( ReconnectingFile& );
41 
42 	ReconnectingFile& operator=( ReconnectingFile& );
43 
44 public:
45 
ReconnectingFile(const::rtl::OUString & aFileURL)46     ReconnectingFile( const ::rtl::OUString& aFileURL )
47         : m_aFile( aFileURL )
48         , m_nFlags( 0 )
49         , m_bFlagsSet( sal_False )
50         , m_bDisconnect( sal_False )
51     {}
52 
~ReconnectingFile()53 	~ReconnectingFile()
54 	{
55 		close();
56 	}
57 
58     void disconnect();
59     sal_Bool reconnect();
60 
61     ::osl::FileBase::RC open( sal_uInt32 uFlags );
62 
63     ::osl::FileBase::RC close();
64 
65     ::osl::FileBase::RC setPos( sal_uInt32 uHow, sal_Int64 uPos );
66 
67     ::osl::FileBase::RC getPos( sal_uInt64& uPos );
68 
69     ::osl::FileBase::RC setSize( sal_uInt64 uSize );
70 
71     ::osl::FileBase::RC getSize( sal_uInt64 &rSize );
72 
73     ::osl::FileBase::RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead );
74 
75     ::osl::FileBase::RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten);
76 
77     ::osl::FileBase::RC sync() const;
78 };
79 
80 } // namespace fileaccess
81 #endif	// _FILREC_HXX_
82 
83