Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

29
LINES

< > BotCompany Repo | #1029250 // ROMIntMemoryFromFile

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3366L/21K).

sclass ROMIntMemoryFromFile implements IIntMemory, AutoCloseable {
  File file;
  int size;
  RandomAccessFile raf;
  bool bigEndian;
  
  *(File *file) {
    size = toInt_safe(fileSize(file)/4);
    raf = randomAccessFileForReading(file);
  }
  
  public void close {
    dispose raf;
  }
  
  public int get(int idx) ctex {
    rangeCheck(idx, size);
    raf.seek(idx*4L);
    ret bigEndian ? raf.readInt() : raf_readLittleEndianInt(raf);
  }
  
  public void set(int idx, int val) {
    fail("read-only");
  }
  
  public int size() {
    ret size;
  }
}

Author comment

Began life as a copy of #1029248

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1029250
Snippet name: ROMIntMemoryFromFile
Eternal ID of this version: #1029250/5
Text MD5: edf3862118e9908a6e7524160a67f153
Transpilation MD5: 4b08607af824e1a56395b9ac9de5ff10
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-08-02 20:23:50
Source code size: 585 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 249 / 556
Version history: 4 change(s)
Referenced in: #1029369 - BufferedDiskIntMemory
#1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)