get writing to a certain position in a file somewhat more correct
This commit is contained in:
1 parent
693d1959ac
commit
a9a1c1aa52
1 file changed
+6
-5
@@ -29,8 +29,8 @@ import com.loomcom.symon.exceptions.MemoryAccessException;
|
|||||||
import com.loomcom.symon.exceptions.MemoryRangeException;
|
import com.loomcom.symon.exceptions.MemoryRangeException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.RandomAccessFile;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -163,10 +163,10 @@ public class SdController extends Device {
|
|||||||
if(writePosition >= SECTOR_SIZE) {
|
if(writePosition >= SECTOR_SIZE) {
|
||||||
if(sdImageFile != null) {
|
if(sdImageFile != null) {
|
||||||
try {
|
try {
|
||||||
FileOutputStream fos = new FileOutputStream(sdImageFile);
|
RandomAccessFile raf = new RandomAccessFile(sdImageFile, "rw");
|
||||||
fos.getChannel().position(this.position);
|
raf.skipBytes(this.position);
|
||||||
fos.write(writeBuffer, 0, writeBuffer.length);
|
raf.write(writeBuffer, 0, writeBuffer.length);
|
||||||
fos.close();
|
raf.close();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
logger.log(Level.WARNING, "could not write data back to SD image file!", ex);
|
logger.log(Level.WARNING, "could not write data back to SD image file!", ex);
|
||||||
}
|
}
|
||||||
@@ -182,6 +182,7 @@ public class SdController extends Device {
|
|||||||
case IDLE:
|
case IDLE:
|
||||||
return 128;
|
return 128;
|
||||||
case READ:
|
case READ:
|
||||||
|
case WRITE:
|
||||||
return 224;
|
return 224;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in new issue
Block a user