// Path: src/main/java/de/waldheinz/fs/util/RamDisk.java
// public final class RamDisk implements BlockDevice {
//     
//     /**
//      * The default sector size for {@code RamDisk}s.
//      */
//     public final static int DEFAULT_SECTOR_SIZE = 512;
//     
//     private final int sectorSize;
//     private final ByteBuffer data;
//     private final int size;
//     private boolean closed;
// 
//     /**
//      * Reads a GZIP compressed disk image from the specified input stream and
//      * returns a {@code RamDisk} holding the decompressed image.
//      *
//      * @param in the stream to read the disk image from
//      * @return the decompressed {@code RamDisk}
//      * @throws IOException on read or decompression error
//      */
//     public static RamDisk readGzipped(InputStream in) throws IOException {
//         final GZIPInputStream zis = new GZIPInputStream(in);
//         ByteArrayOutputStream bos = new ByteArrayOutputStream();
//         
//         final byte[] buffer = new byte[4096];
//         
//         int read = zis.read(buffer);
//         int total = 0;
//         
//         while (read >= 0) {
//             total += read;
//             bos.write(buffer, 0, read);
//             read = zis.read(buffer);
//         }
// 
//         if (total < DEFAULT_SECTOR_SIZE) throw new IOException(
//                 "read only " + total + " bytes"); //NOI18N
//                 
//         final ByteBuffer bb = ByteBuffer.wrap(bos.toByteArray(), 0, total);
//         return new RamDisk(bb, DEFAULT_SECTOR_SIZE);
//     }
//     
//     /**
//      * Reads a GZIP compressed file into a new {@code RamDisk} instance.
//      * 
//      * @param f the file to read
//      * @return the new RamDisk with the file contents
//      * @throws FileNotFoundException if the specified file does not exist
//      * @throws IOException on read error
//      */
//     public static RamDisk readGzipped(File f)
//             throws FileNotFoundException, IOException {
//         
//         final FileInputStream is = new FileInputStream(f);
//         
//         try {
//             return readGzipped(is);
//         } finally {
//             is.close();
//         }
//     }
//     
//     private RamDisk(ByteBuffer buffer, int sectorSize) {
//         this.size = buffer.limit();
//         this.sectorSize = sectorSize;
//         this.data = buffer;
//         this.closed = false;
//     }
// 
//     /**
//      * Creates a new instance of {@code RamDisk} of this specified
//      * size and using the {@link #DEFAULT_SECTOR_SIZE}.
//      *
//      * @param size the size of the new block device
//      */
//     public RamDisk(int size) {
//         this(size, DEFAULT_SECTOR_SIZE);
//     }
// 
//     /**
//      * Creates a new instance of {@code RamDisk} of this specified
//      * size and sector size
//      *
//      * @param size the size of the new block device
//      * @param sectorSize the sector size of the new block device
//      */
//     public RamDisk(int size, int sectorSize) {
//         if (sectorSize < 1) throw new IllegalArgumentException(
//                 "invalid sector size"); //NOI18N
//         
//         this.sectorSize = sectorSize;
//         this.size = size;
//         this.data = ByteBuffer.allocate(size);
//     }
//     
//     @Override
//     public long getSize() {
//         checkClosed();
//         return this.size;
//     }
// 
//     @Override
//     public void read(long devOffset, ByteBuffer dest) throws IOException {
//         checkClosed();
//         if (devOffset > getSize()) throw new IllegalArgumentException();
//         
//         data.limit((int) (devOffset + dest.remaining()));
//         data.position((int) devOffset);
//         
//         dest.put(data);
//     }
// 
//     @Override
//     public void write(long devOffset, ByteBuffer src) throws IOException {
//         checkClosed();
//         
//         if (devOffset + src.remaining() > getSize()) throw new
//                 IllegalArgumentException(
//                 "offset=" + devOffset +
//                 ", length=" + src.remaining() +
//                 ", size=" + getSize());
//                 
//         data.limit((int) (devOffset + src.remaining()));
//         data.position((int) devOffset);
//         
//         
//         data.put(src);
//     }
//     
//     /**
//      * Returns a slice of the {@code ByteBuffer} that is used by this
//      * {@code RamDisk} as it's backing store. The returned buffer will be
//      * live (reflecting any changes made through the
//      * {@link #write(long, java.nio.ByteBuffer) method}, but read-only.
//      *
//      * @return a buffer holding the contents of this {@code RamDisk}
//      */
//     public ByteBuffer getBuffer() {
//         return this.data.asReadOnlyBuffer();
//     }
//     
//     @Override
//     public void flush() throws IOException {
//         checkClosed();
//     }
//     
//     @Override
//     public int getSectorSize() {
//         checkClosed();
//         return this.sectorSize;
//     }
// 
//     @Override
//     public void close() throws IOException {
//         this.closed = true;
//     }
// 
//     @Override
//     public boolean isClosed() {
//         return this.closed;
//     }
// 
//     private void checkClosed() {
//         if (closed) throw new IllegalStateException("device already closed");
//     }
// 
//     /**
//      * Returns always {@code false}, as a {@code RamDisk} is always writable.
//      *
//      * @return always {@code false}
//      */
//     @Override
//     public boolean isReadOnly() {
//         checkClosed();
//         
//         return false;
//     }
//     
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import de.waldheinz.fs.util.RamDisk;

package de.waldheinz.fs.fat;


public class MoveToReplaceTest {

    private static final String FILE_NAME = "file"; 
    private static final String DIRECTORY_NAME = "dir"; 

    private FatLfnDirectoryEntry file;
    private FatLfnDirectoryEntry dir;
    private FatLfnDirectory root;
    private FatFileSystem fs;
    
    @Before
    public void setUp() throws IOException {
// Path: src/main/java/de/waldheinz/fs/util/RamDisk.java
// public final class RamDisk implements BlockDevice {
//     
//     /**
//      * The default sector size for {@code RamDisk}s.
//      */
//     public final static int DEFAULT_SECTOR_SIZE = 512;
//     
//     private final int sectorSize;
//     private final ByteBuffer data;
//     private final int size;
//     private boolean closed;
// 
//     /**
//      * Reads a GZIP compressed disk image from the specified input stream and
//      * returns a {@code RamDisk} holding the decompressed image.
//      *
//      * @param in the stream to read the disk image from
//      * @return the decompressed {@code RamDisk}
//      * @throws IOException on read or decompression error
//      */
//     public static RamDisk readGzipped(InputStream in) throws IOException {
//         final GZIPInputStream zis = new GZIPInputStream(in);
//         ByteArrayOutputStream bos = new ByteArrayOutputStream();
//         
//         final byte[] buffer = new byte[4096];
//         
//         int read = zis.read(buffer);
//         int total = 0;
//         
//         while (read >= 0) {
//             total += read;
//             bos.write(buffer, 0, read);
//             read = zis.read(buffer);
//         }
// 
//         if (total < DEFAULT_SECTOR_SIZE) throw new IOException(
//                 "read only " + total + " bytes"); //NOI18N
//                 
//         final ByteBuffer bb = ByteBuffer.wrap(bos.toByteArray(), 0, total);
//         return new RamDisk(bb, DEFAULT_SECTOR_SIZE);
//     }
//     
//     /**
//      * Reads a GZIP compressed file into a new {@code RamDisk} instance.
//      * 
//      * @param f the file to read
//      * @return the new RamDisk with the file contents
//      * @throws FileNotFoundException if the specified file does not exist
//      * @throws IOException on read error
//      */
//     public static RamDisk readGzipped(File f)
//             throws FileNotFoundException, IOException {
//         
//         final FileInputStream is = new FileInputStream(f);
//         
//         try {
//             return readGzipped(is);
//         } finally {
//             is.close();
//         }
//     }
//     
//     private RamDisk(ByteBuffer buffer, int sectorSize) {
//         this.size = buffer.limit();
//         this.sectorSize = sectorSize;
//         this.data = buffer;
//         this.closed = false;
//     }
// 
//     /**
//      * Creates a new instance of {@code RamDisk} of this specified
//      * size and using the {@link #DEFAULT_SECTOR_SIZE}.
//      *
//      * @param size the size of the new block device
//      */
//     public RamDisk(int size) {
//         this(size, DEFAULT_SECTOR_SIZE);
//     }
// 
//     /**
//      * Creates a new instance of {@code RamDisk} of this specified
//      * size and sector size
//      *
//      * @param size the size of the new block device
//      * @param sectorSize the sector size of the new block device
//      */
//     public RamDisk(int size, int sectorSize) {
//         if (sectorSize < 1) throw new IllegalArgumentException(
//                 "invalid sector size"); //NOI18N
//         
//         this.sectorSize = sectorSize;
//         this.size = size;
//         this.data = ByteBuffer.allocate(size);
//     }
//     
//     @Override
//     public long getSize() {
//         checkClosed();
//         return this.size;
//     }
// 
//     @Override
//     public void read(long devOffset, ByteBuffer dest) throws IOException {
//         checkClosed();
//         if (devOffset > getSize()) throw new IllegalArgumentException();
//         
//         data.limit((int) (devOffset + dest.remaining()));
//         data.position((int) devOffset);
//         
//         dest.put(data);
//     }
// 
//     @Override
//     public void write(long devOffset, ByteBuffer src) throws IOException {
//         checkClosed();
//         
//         if (devOffset + src.remaining() > getSize()) throw new
//                 IllegalArgumentException(
//                 "offset=" + devOffset +
//                 ", length=" + src.remaining() +
//                 ", size=" + getSize());
//                 
//         data.limit((int) (devOffset + src.remaining()));
//         data.position((int) devOffset);
//         
//         
//         data.put(src);
//     }
//     
//     /**
//      * Returns a slice of the {@code ByteBuffer} that is used by this
//      * {@code RamDisk} as it's backing store. The returned buffer will be
//      * live (reflecting any changes made through the
//      * {@link #write(long, java.nio.ByteBuffer) method}, but read-only.
//      *
//      * @return a buffer holding the contents of this {@code RamDisk}
//      */
//     public ByteBuffer getBuffer() {
//         return this.data.asReadOnlyBuffer();
//     }
//     
//     @Override
//     public void flush() throws IOException {
//         checkClosed();
//     }
//     
//     @Override
//     public int getSectorSize() {
//         checkClosed();
//         return this.sectorSize;
//     }
// 
//     @Override
//     public void close() throws IOException {
//         this.closed = true;
//     }
// 
//     @Override
//     public boolean isClosed() {
//         return this.closed;
//     }
// 
//     private void checkClosed() {
//         if (closed) throw new IllegalStateException("device already closed");
//     }
// 
//     /**
//      * Returns always {@code false}, as a {@code RamDisk} is always writable.
//      *
//      * @return always {@code false}
//      */
//     @Override
//     public boolean isReadOnly() {
//         checkClosed();
//         
//         return false;
//     }
//     
// }


// Path: src/test/java/de/waldheinz/fs/fat/MoveToReplaceTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import de.waldheinz.fs.util.RamDisk;


package de.waldheinz.fs.fat;


public class MoveToReplaceTest {

    private static final String FILE_NAME = "file"; 
    private static final String DIRECTORY_NAME = "dir"; 

    private FatLfnDirectoryEntry file;
    private FatLfnDirectoryEntry dir;
    private FatLfnDirectory root;
    private FatFileSystem fs;
    
    @Before
    public void setUp() throws IOException {
        RamDisk dev = new RamDisk(1024 * 1024);