1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <store/store.h>
23 #include <sal/types.h>
24 #include <rtl/ustring.hxx>
25 #include <store/types.h>
40 (void) store_releaseHandle (m_hImpl
);
43 OStoreStream (OStoreStream
const & rhs
)
44 : m_hImpl (rhs
.m_hImpl
)
47 (void) store_acquireHandle (m_hImpl
);
50 OStoreStream
& operator= (OStoreStream
const & rhs
)
53 (void) store_acquireHandle (rhs
.m_hImpl
);
55 (void) store_releaseHandle (m_hImpl
);
56 m_hImpl
= rhs
.m_hImpl
;
61 @see store_openStream()
64 storeFileHandle hFile
,
65 OUString
const & rPath
,
66 OUString
const & rName
,
67 storeAccessMode eMode
)
71 (void) store_releaseHandle (m_hImpl
);
74 return store_openStream (hFile
, rPath
.pData
, rName
.pData
, eMode
, &m_hImpl
);
77 /** Read from the stream.
78 @see store_readStream()
87 return store_E_InvalidHandle
;
89 return store_readStream (m_hImpl
, nOffset
, pBuffer
, nBytes
, &rnDone
);
92 /** Write to the stream.
93 @see store_writeStream()
102 return store_E_InvalidHandle
;
104 return store_writeStream (m_hImpl
, nOffset
, pBuffer
, nBytes
, &rnDone
);
108 storeStreamHandle m_hImpl
;
111 class OStoreDirectory
121 (void) store_releaseHandle (m_hImpl
);
124 OStoreDirectory (OStoreDirectory
const & rhs
)
125 : m_hImpl (rhs
.m_hImpl
)
128 (void) store_acquireHandle (m_hImpl
);
131 OStoreDirectory (OStoreDirectory
&& rhs
) noexcept
132 : m_hImpl (rhs
.m_hImpl
)
134 rhs
.m_hImpl
= nullptr;
137 OStoreDirectory
& operator= (OStoreDirectory
const & rhs
)
140 (void) store_acquireHandle (rhs
.m_hImpl
);
142 (void) store_releaseHandle (m_hImpl
);
143 m_hImpl
= rhs
.m_hImpl
;
147 OStoreDirectory
& operator= (OStoreDirectory
&& rhs
) noexcept
150 (void) store_releaseHandle (m_hImpl
);
151 m_hImpl
= rhs
.m_hImpl
;
152 rhs
.m_hImpl
= nullptr;
156 /** Open the directory.
157 @see store_openDirectory()
160 storeFileHandle hFile
,
161 OUString
const & rPath
,
162 OUString
const & rName
,
163 storeAccessMode eMode
)
167 (void) store_releaseHandle (m_hImpl
);
170 return store_openDirectory (hFile
, rPath
.pData
, rName
.pData
, eMode
, &m_hImpl
);
173 /** Directory iterator type.
177 typedef storeFindData iterator
;
179 /** Find first directory entry.
180 @see store_findFirst()
182 storeError
first (iterator
& it
)
185 return store_E_InvalidHandle
;
187 return store_findFirst (m_hImpl
, &it
);
190 /** Find next directory entry.
191 @see store_findNext()
193 storeError
next (iterator
& it
)
196 return store_E_InvalidHandle
;
198 return store_findNext (m_hImpl
, &it
);
202 storeDirectoryHandle m_hImpl
;
215 (void) store_releaseHandle (m_hImpl
);
218 OStoreFile (OStoreFile
const & rhs
)
219 : m_hImpl (rhs
.m_hImpl
)
222 (void) store_acquireHandle (m_hImpl
);
225 OStoreFile
& operator= (OStoreFile
const & rhs
)
228 (void) store_acquireHandle (rhs
.m_hImpl
);
230 (void) store_releaseHandle (m_hImpl
);
231 m_hImpl
= rhs
.m_hImpl
;
235 operator storeFileHandle() const
240 /** Check for a valid File Handle.
241 @return sal_True if valid, sal_False otherwise.
245 return (m_hImpl
!= nullptr);
249 @see store_openFile()
252 OUString
const & rFilename
,
253 storeAccessMode eAccessMode
)
257 (void) store_releaseHandle (m_hImpl
);
260 return store_openFile (rFilename
.pData
, eAccessMode
, STORE_DEFAULT_PAGESIZE
, &m_hImpl
);
263 /** Open the temporary file in memory.
264 @see store_createMemoryFile()
266 storeError
createInMemory ()
270 (void) store_releaseHandle (m_hImpl
);
273 return store_createMemoryFile (STORE_DEFAULT_PAGESIZE
, &m_hImpl
);
277 @see store_closeFile()
283 (void) store_closeFile (m_hImpl
);
289 @see store_flushFile()
291 storeError
flush() const
294 return store_E_InvalidHandle
;
296 return store_flushFile (m_hImpl
);
299 /** Remove a file entry.
303 OUString
const & rPath
, OUString
const & rName
)
306 return store_E_InvalidHandle
;
308 return store_remove (m_hImpl
, rPath
.pData
, rName
.pData
);
312 storeFileHandle m_hImpl
;
317 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */