private void execFormatTrackTask() { File file = this.ioFile; long pos = this.ioFilePos; int cnt = this.ioByteCnt; if ((file != null) && (pos >= 0) && (cnt > 0)) { boolean err = false; RandomAccessFile raf = null; try { raf = new RandomAccessFile(file, "rw"); raf.seek(pos); while (cnt > 0) { raf.write(0); --cnt; } raf.close(); raf = null; } catch (IOException ex) { err = true; if (!this.writeErrShown) { this.writeErrShown = true; EmuUtil.fireShowError(this.owner, null, ex); } } finally { EmuUtil.doClose(raf); } if (err) { this.errorReg = ERROR_UNCORRECTABLE_DATA; this.statusReg |= STATUS_ERROR; } fireInterrupt(); } }
private void execReadSectorsTask() { File file = this.ioFile; long pos = this.ioFilePos; if (this.debugLevel > 3) { System.out.printf("GIDE io task: read track, pos=%d", pos); } if ((file != null) && (pos >= 0)) { if (file.exists()) { RandomAccessFile raf = null; try { raf = new RandomAccessFile(file, "r"); raf.seek(pos); this.ioByteCnt = (int) raf.read(this.ioBuf, 0, this.ioByteCnt); if (this.debugLevel > 3) { System.out.printf("GIDE io task: read sector: %d read\n", this.ioByteCnt); } } catch (IOException ex) { if (this.debugLevel > 3) { System.out.println("GIDE io task: read sector: error"); } if (!this.readErrShown) { this.readErrShown = true; EmuUtil.fireShowError( this.owner, "Die Festplattenabbilddatei kann nicht gelesen" + " werden.\n" + "Gegen\u00FCber dem emulierten System" + " wird jedoch kein Fehler signalisiert.", ex); } } finally { EmuUtil.doClose(raf); } } else { EmuUtil.fireShowError( this.owner, "Die Festplattenabbilddatei existiert nicht und" + " kann deshalb auch nicht gelesen werden.\n" + "Gegen\u00FCber dem emulierten System" + " wird jedoch kein Fehler signalisiert.\n" + "Mit dem ersten Schreibzugriff auf das" + " emulierte Laufwerk wird die Abbilddatei" + " angelegt.", null); } this.ioBufPos = 0; this.statusReg |= STATUS_DATA_REQUEST; fireInterrupt(); } }
private void execWriteSectorsTask() { File file = this.ioFile; long pos = this.ioFilePos; if (this.debugLevel > 3) { System.out.printf("GIDE io task: write sector, pos=%d", pos); } if ((file != null) && (pos >= 0)) { boolean err = false; RandomAccessFile raf = null; try { raf = new RandomAccessFile(file, "rw"); raf.seek(pos); raf.write(this.ioBuf, 0, SECTOR_SIZE); raf.close(); raf = null; } catch (IOException ex) { err = true; if (!this.writeErrShown) { this.writeErrShown = true; EmuUtil.fireShowError(this.owner, null, ex); } } finally { EmuUtil.doClose(raf); } if (err) { this.errorReg = ERROR_UNCORRECTABLE_DATA; this.statusReg |= STATUS_ERROR; if (this.debugLevel > 3) { System.out.println("GIDE io task: write sector: error"); } } else { this.ioBufPos = 0; countSector(); if (this.sectorCnt > 0) { fireInterrupt(); } else { this.statusReg = STATUS_SEEK_COMPLETE | STATUS_DRIVE_READY; } if (this.debugLevel > 3) { System.out.println("GIDE io task: write sector: ok"); } } } }