LOGIN   :::   RECOVER PASS   :::   GET ACCOUNT    
Browse
  • Projects
  • Code (CVS)
  • Forums
  • News
  • Articles
  • Polls
  •  
    OpenCores
  • FAQ
  • CVS HowTo
  • Mission
  • Media
  • Tools
  • Advertise
  • Mirrors
  • Logos
  • Contact us
  • Job Opportunity
  •  
    Tools
  • Search
      
  • Download Cores (CVSGet)
  •  
    More
  • Wishbone
  • Perlilog
  • EDA tools
  • OpenTech CD
  •  
    Navigation: All forums > Cvs-checkins > Message List > Message Post

    Message

    Reply | Reply all
    Date Prev | Date Next | Thread Prev | Thread Next Date Index | Thread Index

    From: cvs at opencores.org<cvs@o...>
    Date: Thu Jun 7 16:37:28 CEST 2007
    Subject: [cvs-checkins] MODIFIED: jop ...
    Top
    Date: 00/07/06 07:16:37

    Added: jop/java/pc/src/yaffs2/utils/emulation
    FileEmulationUnix.java HiddenException.java
    RamEmulationUnix.java Utils.java
    Log:
    Java port of YAFFS, a NAND flash file system. Under development.


    Revision Changes Path
    1.1 jop/java/pc/src/yaffs2/utils/emulation/FileEmulationUnix.java

    http://www.opencores.org/cvsweb.shtml/jop/java/pc/src/yaffs2/utils/emulation/FileEmulationUnix.java?rev=1.1&content-type=text/x-cvsweb-markup

    Index: FileEmulationUnix.java
    ===================================================================
    package yaffs2.utils.emulation;

    import java.io.*;

    import static yaffs2.port.yaffsfs_H.*;

    public abstract class FileEmulationUnix
    {
    /**
    *
    * @param path
    * @param pathIndex
    * @param oflag Ignored. Access mode is always "rw".
    * @param permission Ignored.
    * @return
    */
    public static RandomAccessFile open(String path, int oflag, int permission)
    {
    return open(path, oflag);
    }

    public static RandomAccessFile open(String path, int oflag)
    {
    try
    {
    return new RandomAccessFile(path, "rw");
    }
    catch (FileNotFoundException e)
    {
    throw new HiddenException();
    }
    }

    public static int write(RandomAccessFile fildes, byte[] buf, int bufIndex, int nbyte)
    {
    try
    {
    fildes.write(buf, bufIndex, nbyte);
    }
    catch(IOException e)
    {
    throw new HiddenException();
    }

    return nbyte;
    }

    public static int read(RandomAccessFile fildes, byte[] buf, int bufIndex, int nbyte)
    {
    try
    {
    return fildes.read(buf, bufIndex, nbyte);
    }
    catch(IOException e)
    {
    throw new HiddenException();
    }
    }

    public static void close(RandomAccessFile f)
    {
    try
    {
    f.close();
    }
    catch(IOException e)
    {
    throw new HiddenException();
    }
    }

    public static int lseek(RandomAccessFile fildes, int offset, int whence)
    {
    try
    {
    fildes.seek(((whence == SEEK_END) ? fildes.length() :
    ((whence == SEEK_CUR) ? fildes.getFilePointer() : +
    0)) + offset);

    return (int)fildes.getFilePointer();
    }
    catch(IOException e)
    {
    throw new HiddenException();
    }
    }
    public static byte[] IntToByteArray(int value) { byte[] result = new byte[yaffs2.utils.Constants.SIZEOF_INT]; yaffs2.utils.Utils.writeIntToByteArray(result, 0, value); return result; } } 1.1 jop/java/pc/src/yaffs2/utils/emulation/HiddenException.java http://www.opencores.org/cvsweb.shtml/jop/java/pc/src/yaffs2/utils/emulation/HiddenException.java?rev=1.1&content-type=text/x-cvsweb-markup Index: HiddenException.java =================================================================== package yaffs2.utils.emulation; public class HiddenException extends RuntimeException { } 1.1 jop/java/pc/src/yaffs2/utils/emulation/RamEmulationUnix.java http://www.opencores.org/cvsweb.shtml/jop/java/pc/src/yaffs2/utils/emulation/RamEmulationUnix.java?rev=1.1&content-type=text/x-cvsweb-markup Index: RamEmulationUnix.java =================================================================== package yaffs2.utils.emulation; import yaffs2.port.yramdisk_Block; import yaffs2.port.yramdisk_Page; public abstract class RamEmulationUnix { public static void memset(yramdisk_Block s, byte c) { for (int i = 0; i < s.page.length; i++) memset(s.page[i], c); } public static void memset(yramdisk_Page s, byte c) { yaffs2.utils.Unix.memset(s.data, 0, c, s.data.length); } } 1.1 jop/java/pc/src/yaffs2/utils/emulation/Utils.java http://www.opencores.org/cvsweb.shtml/jop/java/pc/src/yaffs2/utils/emulation/Utils.java?rev=1.1&content-type=text/x-cvsweb-markup Index: Utils.java =================================================================== package yaffs2.utils.emulation; import static yaffs2.utils.Unix.*; /** * These methods should not be used if you want to avoid garbage collection. * */ public abstract class Utils { public static String byteArrayToString(byte[] array, int index) { int length = strlen(array, index); StringBuffer result = new StringBuffer(length); result.setLength(length); for (int i = 0; i < length; i++) result.setCharAt(i, (char)(array[index+i] & 0xff)); return result.toString(); } /** * XXX A terminating 0 is appended. * @param string * @return */ public static byte[] StringToByteArray(String string) { byte[] result = new byte[string.length()+1]; for (int i = 0; i < string.length(); i++) result[i] = (byte)string.charAt(i); result[result.length-1] = 0; return result; } /** * XXX No terminating 0 is appended. * @param string * @param array * @param offset * @return */ public static int StringToByteArraySafe(String string, byte[] array, int offset) { for (int i = 0; i < string.length() && offset+i < array.length; i++) array[offset+i] = (byte)string.charAt(i); return Math.min(offset+string.length(), array.length-1); } }

     
    Copyright (c) 1999 OPENCORES.ORG. All rights reserved.