You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2011/04/29 07:56:23 UTC

svn commit: r1097695 - in /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime: ./ io/ platform/unix/ platform/windows/

Author: mturk
Date: Fri Apr 29 05:56:22 2011
New Revision: 1097695

URL: http://svn.apache.org/viewvc?rev=1097695&view=rev
Log:
More classes from original code

Added:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Device.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileAttributes.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileType.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/RuntimeIOException.java   (with props)
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Streamable.java   (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/InvalidDescriptorException.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Shm.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Syncable.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShm.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVShm.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsShm.java

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/InvalidDescriptorException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/InvalidDescriptorException.java?rev=1097695&r1=1097694&r2=1097695&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/InvalidDescriptorException.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/InvalidDescriptorException.java Fri Apr 29 05:56:22 2011
@@ -15,7 +15,6 @@
  */
 
 package org.apache.commons.runtime;
-import java.io.IOException;
 
 /**
  * InvalidDescriptorException thrown when an attempt is made to

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java?rev=1097695&r1=1097694&r2=1097695&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Mutex.java Fri Apr 29 05:56:22 2011
@@ -15,6 +15,8 @@
  */
 package org.apache.commons.runtime;
 
+import org.apache.commons.runtime.io.RuntimeIOException;
+
 /**
  * Mutex class.
  * <p>

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Shm.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Shm.java?rev=1097695&r1=1097694&r2=1097695&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Shm.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Shm.java Fri Apr 29 05:56:22 2011
@@ -16,6 +16,8 @@
 package org.apache.commons.runtime;
 
 import org.apache.commons.runtime.io.Syncable;
+import java.io.IOException;
+import java.io.SyncFailedException;
 
 /**
  * Shm class.
@@ -124,7 +126,7 @@ public abstract class Shm implements Syn
      * @throws IOException if an I/O error occurs.
      */
     public abstract void sync()
-        throws SystemException;
+        throws SyncFailedException, IOException;
 
     /**
      * Flushed the underlying object by writing any buffered data.
@@ -141,7 +143,7 @@ public abstract class Shm implements Syn
      * @throws IOException if an I/O error occurs.
      */
     public abstract void flush()
-        throws SystemException;
+        throws SyncFailedException, IOException;
 
     /**
      * Closes the sharedmem.

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Device.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Device.java?rev=1097695&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Device.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Device.java Fri Apr 29 05:56:22 2011
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.commons.runtime.io;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+/**
+ * The base class for all devices.
+ */
+public interface Device extends Closeable
+{
+
+    /**
+     * Test if {@code this} device is valid.
+     *
+     * @return {@code true} if the device represents a valid,
+     *         open file, socket, or other I/O object; {@code false} otherwise.
+     *
+     */
+    public boolean valid();
+
+    /**
+     * Test wather or not every I/O operation on {@code this} device will
+     * block until it completes.
+     *
+     * @return {@code true} if, and only if, this device
+     *         is in blocking mode.
+     *
+     * @throws IOException if an I/O error occurs.
+     */
+    public boolean isBlocking()
+        throws RuntimeIOException;
+
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Device.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileAttributes.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileAttributes.java?rev=1097695&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileAttributes.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileAttributes.java Fri Apr 29 05:56:22 2011
@@ -0,0 +1,110 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime.io;
+
+import java.util.EnumSet;
+
+/**
+ * File attributes flag flags.
+ */
+public enum FileAttributes
+{
+    /** File is read-only.
+     */
+    READONLY(   0x01),
+    /** File is executable.
+     */
+    EXECUTABLE( 0x02),
+    /** File is hidden.
+     * <p>
+     * On POSIX platforms this bit means that the file name starts with the
+     * dot (@code (.)} character which is usual way of representing the
+     * hidden files.
+     * On Windows platform it merely reflects the
+     * {@code hidden} file attribute.
+     * </p>
+     */
+    HIDDEN(     0x04),
+    /** File is reserved for system use only.
+     * <p>
+     * On POSIX platforms this bit means that the file has
+     * set UID bit set. On Windows platform it merely reflects the
+     * {@code system} file attribute.
+     * </p>
+     */
+    SYSTEM(     0x08);
+
+    private int value;
+    private FileAttributes(int v)
+    {
+        value = v;
+    }
+
+    public int valueOf()
+    {
+        return value;
+    }
+
+    /**
+     * Integer representing the sum of the integer values
+     * of the {@code FileAttributes} enums.
+     * @param set The {@code EnumSet} which values to get.
+     * @return sum of {@code FileAttributes} values
+     */
+    public static int bitmapOf(EnumSet<FileAttributes> set)
+    {
+        int bitmap = 0;
+        if (set != null && set.size() != 0) {
+            for (FileAttributes a : set)
+                bitmap += a.valueOf();
+        }
+        return bitmap;
+    }
+
+    /**
+     * Integer representing the sum of the integer values
+     * of the {@code FileAttributes} enums.
+     * @param set arguments of {@code FileAttributes} which values to get.
+     * @return sum of {@code FileAttributes} values
+     */
+    public static int bitmapOf(FileAttributes... set)
+    {
+        int bitmap = 0;
+        if (set != null) {
+            for (FileAttributes a : set)
+                bitmap += a.valueOf();
+        }
+        return bitmap;
+    }
+
+    /**
+     * Returns {@code EnumSet} of {@code FileAttributes} enums
+     * from the integer bitmap value.
+     * @param value Integer used to construct the {@code EnumSet}
+     * with {@code FileAttributes} values mathching the value flags.
+     * @return set of {@code FileAttributes} enums.
+     */
+    public static EnumSet<FileAttributes> valueOf(int value)
+    {
+        EnumSet<FileAttributes> set = EnumSet.noneOf(FileAttributes.class);
+        for (FileAttributes e : values()) {
+            if ((e.value & value) == e.value)
+                set.add(e);
+        }
+        return set;
+    }
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileAttributes.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileType.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileType.java?rev=1097695&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileType.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileType.java Fri Apr 29 05:56:22 2011
@@ -0,0 +1,71 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime.io;
+
+/** FileType values for the filetype member of the
+ * FileInfo structure
+ * <br /><b>Warning :</b>: Not all of the filetypes below can be determined.
+ * For example, a given platform might not correctly report
+ * a socket descriptor as SOCK if that type isn't
+ * well-identified on that platform.  In such cases where
+ * a filetype exists but cannot be described by the recognized
+ * flags below, the filetype will be UNKFILE.  If the
+ * filetype member is not determined, the type will be NOFILE.
+ */
+public enum FileType
+{
+    /** No file type determined */
+    NOFILE(     0),
+     /** A regular file */
+    REG(        1),
+    /** A directory */
+    DIR(        2),
+    /** A character device */
+    CHR(        3),
+    /** A block device */
+    BLK(        4),
+    /** A FIFO / pipe */
+    PIPE(       5),
+    /** A symbolic link */
+    LNK(        6),
+    /** A [unix domain] socket */
+    SOCK(       7),
+    /** A file of some other unknown type */
+    UNKFILE(  127);
+
+
+    private int value;
+    private FileType(int v)
+    {
+        value = v;
+    }
+
+    public int valueOf()
+    {
+        return value;
+    }
+
+    public static FileType valueOf(int value)
+    {
+        for (FileType e : values()) {
+            if (e.value == value)
+                return e;
+        }
+        return UNKFILE;
+    }
+
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/FileType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/RuntimeIOException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/RuntimeIOException.java?rev=1097695&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/RuntimeIOException.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/RuntimeIOException.java Fri Apr 29 05:56:22 2011
@@ -0,0 +1,40 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime.io;
+import java.io.IOException;
+
+/**
+ * RuntimeIOException
+ *
+ * Base exception class for all IO Exceptions
+ * @author Mladen Turk
+ *
+ */
+
+public class RuntimeIOException extends IOException
+{
+
+    public RuntimeIOException()
+    {
+        super();
+    }
+
+    public RuntimeIOException(String msg)
+    {
+        super(msg);
+    }
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/RuntimeIOException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Streamable.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Streamable.java?rev=1097695&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Streamable.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Streamable.java Fri Apr 29 05:56:22 2011
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.commons.runtime.io;
+
+import java.io.IOException;
+
+/**
+ * The base class for bidirectional streams.
+ */
+public interface Streamable extends Device
+{
+
+    /**
+     * Test the end-of-stream indicator.
+     *
+     * @return {@code true} if end-of-stream was reached.
+     *
+     * @throws ClosedDescriptorException
+     *          If this stream is closed.
+     * @throws IOException
+     *          If some other I/O error occurs.
+     */
+    public boolean eof()
+        throws RuntimeIOException;
+
+}

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Streamable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Syncable.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Syncable.java?rev=1097695&r1=1097694&r2=1097695&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Syncable.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Syncable.java Fri Apr 29 05:56:22 2011
@@ -18,7 +18,9 @@
 
 package org.apache.commons.runtime.io;
 
-import org.apache.commons.runtime.SystemException;
+import java.io.Flushable;
+import java.io.IOException;
+import java.io.SyncFailedException;
 
 /**
  * Defines an interface for classes that can (or need to) be synced, typically
@@ -29,7 +31,7 @@ import org.apache.commons.runtime.System
  * is usually used for flushing object's metadata to the output device.
  *
  */
-public interface Syncable
+public interface Syncable extends Flushable
 {
 
     /**
@@ -46,7 +48,7 @@ public interface Syncable
      * @throws IOException if an I/O error occurs.
      */
     public void flush()
-        throws SystemException;
+        throws SyncFailedException, IOException;
 
 
     /**
@@ -64,6 +66,6 @@ public interface Syncable
      * @throws IOException if an I/O error occurs.
      */
     public void sync()
-        throws SystemException;
+        throws SyncFailedException, IOException;
 
 }

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShm.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShm.java?rev=1097695&r1=1097694&r2=1097695&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShm.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/PosixShm.java Fri Apr 29 05:56:22 2011
@@ -25,6 +25,8 @@ import org.apache.commons.runtime.NoSuch
 import org.apache.commons.runtime.ClosedDescriptorException;
 import org.apache.commons.runtime.SystemException;
 import org.apache.commons.runtime.io.Syncable;
+import java.io.IOException;
+import java.io.SyncFailedException;
 
 /**
  * PosixShm class.
@@ -142,24 +144,24 @@ final class PosixShm extends Shm
 
     @Override
     public final void flush()
-        throws SystemException
+        throws SyncFailedException, IOException
     {
         if (fd == -1)
             throw new ClosedDescriptorException();
         int rc = Posix.msync(base, size, Posix.MS_ASYNC);
         if (rc != 0)
-            throw new SystemException(Status.describe(rc));
+            throw new SyncFailedException(Status.describe(rc));
     }
 
     @Override
     public final void sync()
-        throws SystemException
+        throws SyncFailedException, IOException
     {
         if (fd == -1)
             throw new ClosedDescriptorException();
         int rc = Posix.msync(base, size, Posix.MS_SYNC);
         if (rc != 0)
-            throw new SystemException(Status.describe(rc));
+            throw new SyncFailedException(Status.describe(rc));
     }
 
     @Override

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVShm.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVShm.java?rev=1097695&r1=1097694&r2=1097695&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVShm.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVShm.java Fri Apr 29 05:56:22 2011
@@ -24,6 +24,8 @@ import org.apache.commons.runtime.NoSuch
 import org.apache.commons.runtime.ClosedDescriptorException;
 import org.apache.commons.runtime.SystemException;
 import org.apache.commons.runtime.io.Syncable;
+import java.io.IOException;
+import java.io.SyncFailedException;
 
 /**
  * SysVShm class.
@@ -125,24 +127,24 @@ final class SysVShm extends Shm
 
     @Override
     public final void flush()
-        throws SystemException
+        throws SyncFailedException, IOException
     {
         if (fd == -1)
             throw new ClosedDescriptorException();
         int rc = Posix.msync(base, size, Posix.MS_ASYNC);
         if (rc != 0)
-            throw new SystemException(Status.describe(rc));
+            throw new SyncFailedException(Status.describe(rc));
     }
 
     @Override
     public final void sync()
-        throws SystemException
+        throws SyncFailedException, IOException
     {
         if (fd == -1)
             throw new ClosedDescriptorException();
         int rc = Posix.msync(base, size, Posix.MS_SYNC);
         if (rc != 0)
-            throw new SystemException(Status.describe(rc));
+            throw new SyncFailedException(Status.describe(rc));
     }
 
     @Override

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsShm.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsShm.java?rev=1097695&r1=1097694&r2=1097695&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsShm.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/windows/WindowsShm.java Fri Apr 29 05:56:22 2011
@@ -25,6 +25,8 @@ import org.apache.commons.runtime.NoSuch
 import org.apache.commons.runtime.ClosedDescriptorException;
 import org.apache.commons.runtime.SystemException;
 import org.apache.commons.runtime.io.Syncable;
+import java.io.IOException;
+import java.io.SyncFailedException;
 
 /**
  * WindowsShm class.
@@ -158,24 +160,24 @@ final class WindowsShm extends Shm
 
     @Override
     public final void flush()
-        throws SystemException
+        throws SyncFailedException, IOException
     {
         if (handle == 0)
             throw new InvalidHandleException();
         int rc = Win32.FlushViewOfFile(base, 0L);
         if (rc != 0)
-            throw new SystemException(Status.describe(rc));
+            throw new SyncFailedException(Status.describe(rc));
     }
 
     @Override
     public final void sync()
-        throws SystemException
+        throws SyncFailedException, IOException
     {
         if (handle == 0)
             throw new InvalidHandleException();
         int rc = Win32.FlushViewOfFile(base, 0L);
         if (rc != 0)
-            throw new SystemException(Status.describe(rc));
+            throw new SyncFailedException(Status.describe(rc));
     }
 
     @Override