xref: /trunk/main/store/inc/store/store.h (revision e4baec4c)
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 _STORE_STORE_H_
25 #define _STORE_STORE_H_ "$Revision$"
26 
27 #include <store/types.h>
28 #include <store/dllapi.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /** Handle opaque type.
35  */
36 typedef void* storeHandle;
37 
38 
39 /** Acquire a Handle.
40     @param  Handle [in] the Handle.
41     @return store_E_None upon success
42  */
43 STORE_DLLPUBLIC storeError SAL_CALL store_acquireHandle (
44 	storeHandle Handle
45 ) SAL_THROW_EXTERN_C();
46 
47 
48 /** Release a Handle.
49     @param  Handle [in] the Handle.
50     @return store_E_None          upon success,
51             store_E_InvalidHandle otherwise.
52  */
53 STORE_DLLPUBLIC storeError SAL_CALL store_releaseHandle (
54 	storeHandle Handle
55 ) SAL_THROW_EXTERN_C();
56 
57 
58 
59 /** File Handle opaque type.
60  */
61 typedef void* storeFileHandle;
62 
63 
64 /** Open a temporary file in memory.
65     @param  nPageSize [in] the creation page size,
66             integer multiple of minimum page size.
67     @param  phFile [out] the File Handle.
68     @return store_E_None upon success
69  */
70 STORE_DLLPUBLIC storeError SAL_CALL store_createMemoryFile (
71 	sal_uInt16       nPageSize,
72 	storeFileHandle *phFile
73 ) SAL_THROW_EXTERN_C();
74 
75 
76 /** Open a file.
77     @param  pFilename [in] the filename as URL or system path.
78     @param  eAccessMode [in] the access mode.
79             store_AccessCreate     truncate existing and create,
80             store_AccessReadCreate create not existing,
81             store_AccessReadWrite  write existing,
82             store_AccessReadOnly   never modifies.
83     @param  nPageSize [in] the creation page size,
84             integer multiple of minimum page size.
85 	@param  phFile [out] the File Handle.
86     @return store_E_None upon success
87  */
88 STORE_DLLPUBLIC storeError SAL_CALL store_openFile (
89 	rtl_uString     *pFilename,
90 	storeAccessMode  eAccessMode,
91 	sal_uInt16       nPageSize,
92 	storeFileHandle *phFile
93 ) SAL_THROW_EXTERN_C();
94 
95 
96 /** Close a file.
97     @param  hFile [in] the File Handle.
98     @return store_E_None upon     success,
99             store_E_InvalidHandle otherwise.
100  */
101 STORE_DLLPUBLIC storeError SAL_CALL store_closeFile (
102 	storeFileHandle hFile
103 ) SAL_THROW_EXTERN_C();
104 
105 
106 /** Flush a file.
107     @param  hFile [in] the File Handle.
108     @return store_E_None upon success
109  */
110 STORE_DLLPUBLIC storeError SAL_CALL store_flushFile (
111 	storeFileHandle hFile
112 ) SAL_THROW_EXTERN_C();
113 
114 
115 /** Get the number of referers to a file.
116     @param  hFile [in] the File Handle.
117     @param  pnRefCount [out] number of open directories and streams.
118     @return store_E_None upon success
119  */
120 STORE_DLLPUBLIC storeError SAL_CALL store_getFileRefererCount (
121 	storeFileHandle  hFile,
122 	sal_uInt32      *pnRefCount
123 ) SAL_THROW_EXTERN_C();
124 
125 
126 /** Get the size of a file.
127     @param  hFile [in] the File Handle.
128     @param  pnSize [out] the file size in bytes.
129     @return store_E_None upon success
130  */
131 STORE_DLLPUBLIC storeError SAL_CALL store_getFileSize (
132 	storeFileHandle  hFile,
133 	sal_uInt32      *pnSize
134 ) SAL_THROW_EXTERN_C();
135 
136 
137 /** Recover and Compact a file into another file.
138     @see store_openFile()
139 
140     @param  pSrcFilename [in] opened with store_AccessReadOnly.
141     @param  pDstFilename [in] created with store_AccessCreate.
142     @return store_E_None upon success
143  */
144 STORE_DLLPUBLIC storeError SAL_CALL store_rebuildFile (
145 	rtl_uString *pSrcFilename,
146 	rtl_uString *pDstFilename
147 ) SAL_THROW_EXTERN_C();
148 
149 
150 
151 /** Directory Handle opaque type.
152  */
153 typedef void* storeDirectoryHandle;
154 
155 
156 /** Open a directory.
157     @see store_openFile()
158 
159     @param  hFile [in] the File Handle.
160     @param  pPath [in] the directory path.
161     @param  pName [in] the directory name.
162     @param  eAccessMode [in] the access mode.
163     @param  phDirectory [out] the Directory Handle.
164     @return store_E_None upon success
165  */
166 STORE_DLLPUBLIC storeError SAL_CALL store_openDirectory (
167 	storeFileHandle       hFile,
168 	rtl_uString          *pPath,
169 	rtl_uString          *pName,
170 	storeAccessMode       eAccessMode,
171 	storeDirectoryHandle *phDirectory
172 ) SAL_THROW_EXTERN_C();
173 
174 
175 /** Close a directory.
176     @param  hDirectory [in] the Directory Handle.
177     @return store_E_None          upon success,
178             store_E_InvalidHandle otherwise.
179  */
180 STORE_DLLPUBLIC storeError SAL_CALL store_closeDirectory (
181 	storeDirectoryHandle hDirectory
182 ) SAL_THROW_EXTERN_C();
183 
184 
185 /** Find first directory entry.
186     @param  hDirectory [in] the Directory Handle.
187     @param  pFindData [out] the Find Data structure.
188     @return store_E_None       upon success,
189             store_E_NoMoreFile upon end of iteration.
190  */
191 STORE_DLLPUBLIC storeError SAL_CALL store_findFirst (
192 	storeDirectoryHandle  hDirectory,
193 	storeFindData        *pFindData
194 ) SAL_THROW_EXTERN_C();
195 
196 
197 /** Find next directory entry.
198     @param  hDirectory [in] the Directory Handle.
199     @param  pFindData [out] the Find Data structure.
200     @return store_E_None       upon success,
201             store_E_NoMoreFile upon end of iteration.
202  */
203 STORE_DLLPUBLIC storeError SAL_CALL store_findNext (
204 	storeDirectoryHandle  hDirectory,
205 	storeFindData        *pFindData
206 ) SAL_THROW_EXTERN_C();
207 
208 
209 
210 /** Stream Handle opaque type.
211  */
212 typedef void* storeStreamHandle;
213 
214 
215 /** Open a stream.
216     @see store_openFile()
217 
218     @param  hFile [in] the File Handle.
219     @param  pPath [in] the stream path.
220     @param  pName [in] the stream name.
221     @param  eAccessMode [in] the access mode.
222     @param  phStrm [out] the Stream Handle.
223     @return store_E_None upon success
224  */
225 STORE_DLLPUBLIC storeError SAL_CALL store_openStream (
226 	storeFileHandle    hFile,
227 	rtl_uString       *pPath,
228 	rtl_uString       *pName,
229 	storeAccessMode    eMode,
230 	storeStreamHandle *phStrm
231 ) SAL_THROW_EXTERN_C();
232 
233 
234 /** Close a stream.
235     @param  hStrm [in] the Stream Handle.
236     @return store_E_None          upon success,
237             store_E_InvalidHandle otherwise.
238  */
239 STORE_DLLPUBLIC storeError SAL_CALL store_closeStream (
240 	storeStreamHandle hStrm
241 ) SAL_THROW_EXTERN_C();
242 
243 
244 /** Read from a stream.
245     @param  hStrm [in] the Stream Handle.
246     @param  nOffset [in] the offset of the first byte to read.
247     @param  pBuffer [out] the buffer.
248     @param  nBytes [in] the number of bytes to read.
249     @param  pnDone [out] the number of bytes actually read.
250     @return store_E_None upon success
251  */
252 STORE_DLLPUBLIC storeError SAL_CALL store_readStream (
253 	storeStreamHandle  hStrm,
254 	sal_uInt32         nOffset,
255 	void              *pBuffer,
256 	sal_uInt32         nBytes,
257 	sal_uInt32        *pnDone
258 ) SAL_THROW_EXTERN_C();
259 
260 
261 /** Write to a stream.
262     @param  hStrm [in] the Stream Handle.
263     @param  nOffset [in] the offset of the first byte to write.
264     @param  pBuffer [in] the buffer.
265     @param  nBytes [in] the number of bytes to write.
266     @param  pnDone [out] the number of bytes actually written.
267     @return store_E_None upon success
268  */
269 STORE_DLLPUBLIC storeError SAL_CALL store_writeStream (
270 	storeStreamHandle  hStrm,
271 	sal_uInt32         nOffset,
272 	const void        *pBuffer,
273 	sal_uInt32         nBytes,
274 	sal_uInt32        *pnDone
275 ) SAL_THROW_EXTERN_C();
276 
277 
278 /** Flush a stream.
279     @param  hStrm [in] the Stream Handle.
280     @return store_E_None upon success
281  */
282 STORE_DLLPUBLIC storeError SAL_CALL store_flushStream (
283 	storeStreamHandle hStrm
284 ) SAL_THROW_EXTERN_C();
285 
286 
287 /** Get the size of a stream.
288     @param  hStrm [in] the Stream Handle.
289     @param  pnSize [out] the stream size in bytes.
290     @return store_E_None upon success
291  */
292 STORE_DLLPUBLIC storeError SAL_CALL store_getStreamSize (
293 	storeStreamHandle  hStrm,
294 	sal_uInt32        *pnSize
295 ) SAL_THROW_EXTERN_C();
296 
297 
298 /** Set the size of a stream.
299     @param  hStrm [in] the Stream Handle.
300     @param  nSize [in] the new stream size in bytes.
301     @return store_E_None upon success
302  */
303 STORE_DLLPUBLIC storeError SAL_CALL store_setStreamSize (
304 	storeStreamHandle hStrm,
305 	sal_uInt32        nSize
306 ) SAL_THROW_EXTERN_C();
307 
308 
309 
310 /** Set attributes of a file entry.
311     @param  hFile [in] the File Handle.
312     @param  pPath [in] the entry path.
313     @param  pName [in] the entry name.
314     @param  nMask1 [in] the attributes to be cleared.
315     @param  nMask2 [in] the attributes to be set.
316     @param  pnAttrib [out] the resulting attributes, may be NULL.
317     @return store_E_None upon success
318  */
319 STORE_DLLPUBLIC storeError SAL_CALL store_attrib (
320 	storeFileHandle hFile,
321 	rtl_uString    *pPath,
322 	rtl_uString    *pName,
323 	sal_uInt32      nMask1,
324 	sal_uInt32      nMask2,
325 	sal_uInt32     *pnAttrib
326 ) SAL_THROW_EXTERN_C();
327 
328 
329 /** Insert a file entry as 'hard link' to another file entry.
330 	@precond  Source must not exist, Destination must exist.
331 	@postcond Source has attribute STORE_ATTRIB_ISLINK.
332 	@see      store_attrib()
333 
334     @param  hFile [in] the File Handle
335     @param  pSrcPath [in] the Source path
336     @param  pSrcName [in] the Source name
337     @param  pDstPath [in] the Destination path
338     @param  pDstName [in] the Destination name
339     @return store_E_None upon success
340  */
341 STORE_DLLPUBLIC storeError SAL_CALL store_link (
342 	storeFileHandle hFile,
343 	rtl_uString *pSrcPath, rtl_uString *pSrcName,
344 	rtl_uString *pDstPath, rtl_uString *pDstName
345 ) SAL_THROW_EXTERN_C();
346 
347 
348 /** Insert a file entry as 'symbolic link' to another file entry.
349 	@precond  Source must not exist
350 	@postcond Source has attribute STORE_ATTRIB_ISLINK.
351 	@see      store_attrib()
352 
353     @param  hFile [in] the File Handle
354     @param  pSrcPath [in] the Source path
355     @param  pSrcName [in] the Source name
356     @param  pDstPath [in] the Destination path
357     @param  pDstName [in] the Destination name
358     @return store_E_None upon success
359  */
360 STORE_DLLPUBLIC storeError SAL_CALL store_symlink (
361 	storeFileHandle hFile,
362 	rtl_uString *pSrcPath, rtl_uString *pSrcName,
363 	rtl_uString *pDstPath, rtl_uString *pDstName
364 ) SAL_THROW_EXTERN_C();
365 
366 
367 /** Rename a file entry.
368     @param  hFile [in] the File Handle
369     @param  pSrcPath [in] the Source path
370     @param  pSrcName [in] the Source name
371     @param  pDstPath [in] the Destination path
372     @param  pDstName [in] the Destination name
373     @return store_E_None upon success
374  */
375 STORE_DLLPUBLIC storeError SAL_CALL store_rename (
376 	storeFileHandle hFile,
377 	rtl_uString *pSrcPath, rtl_uString *pSrcName,
378 	rtl_uString *pDstPath, rtl_uString *pDstName
379 ) SAL_THROW_EXTERN_C();
380 
381 
382 /** Remove a file entry.
383     @param  hFile [in] the File Handle
384     @param  pPath [in] the entry path
385     @param  pName [in] the entry name
386     @return store_E_None upon success
387  */
388 STORE_DLLPUBLIC storeError SAL_CALL store_remove (
389 	storeFileHandle hFile,
390 	rtl_uString    *pPath,
391 	rtl_uString    *pName
392 ) SAL_THROW_EXTERN_C();
393 
394 /*========================================================================
395  *
396  * The End.
397  *
398  *======================================================================*/
399 
400 #ifdef __cplusplus
401 }
402 #endif
403 
404 #endif /* _STORE_STORE_H_ */
405 
406 
407 
408 
409