2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 package com
.sun
.star
.sdbcx
.comp
.hsqldb
;
20 import org
.hsqldb
.lib
.FileAccess
;
21 import org
.hsqldb
.lib
.FileSystemRuntimeException
;
23 @SuppressWarnings("ucd")
24 public class StorageFileAccess
implements org
.hsqldb
.lib
.FileAccess
{
25 static { NativeLibraries
.load(); }
29 /** Creates a new instance of StorageFileAccess */
30 public StorageFileAccess(Object key
) throws java
.lang
.Exception
{
31 this.key
= (String
)key
;
34 public void createParentDirs(String filename
) {
37 public boolean isStreamElement(String elementName
) {
38 return isStreamElement(key
,elementName
);
41 public java
.io
.InputStream
openInputStreamElement(String streamName
) throws java
.io
.IOException
{
42 return new NativeInputStreamHelper(key
,streamName
);
45 public java
.io
.OutputStream
openOutputStreamElement(String streamName
) throws java
.io
.IOException
{
46 return new NativeOutputStreamHelper(key
,streamName
);
49 public void removeElement(String filename
) throws java
.util
.NoSuchElementException
{
51 if ( isStreamElement(key
,filename
) )
52 removeElement(key
,filename
);
53 } catch (java
.io
.IOException e
) {
54 throw new FileSystemRuntimeException( e
);
58 public void renameElement(String oldName
, String newName
) throws java
.util
.NoSuchElementException
{
60 if ( isStreamElement(key
,oldName
) ){
61 removeElement(key
,newName
);
62 renameElement(key
,oldName
, newName
);
64 } catch (java
.io
.IOException e
) {
65 throw new FileSystemRuntimeException( e
);
69 private static class FileSync
implements FileAccess
.FileSync
71 private final NativeOutputStreamHelper os
;
72 private FileSync(NativeOutputStreamHelper _os
)
76 public void sync() throws java
.io
.IOException
82 public FileAccess
.FileSync
getFileSync(java
.io
.OutputStream os
) throws java
.io
.IOException
84 return new FileSync((NativeOutputStreamHelper
)os
);
87 static native boolean isStreamElement(String key
,String elementName
);
88 static native void removeElement(String key
,String filename
) throws java
.util
.NoSuchElementException
, java
.io
.IOException
;
89 static native void renameElement(String key
,String oldName
, String newName
) throws java
.util
.NoSuchElementException
, java
.io
.IOException
;