public override bool DeleteFile(GR.Memory.ByteBuffer Filename) { _LastError = ""; if (Filename.Compare(this.Filename) != 0) { _LastError = "file not found"; return(false); } Data.Clear(); return(true); }
bool LocateFile(GR.Memory.ByteBuffer Filename, out Location FileLocation, out Types.FileInfo FileInfo) { _LastError = ""; FileLocation = null; FileInfo = null; Location curLoc = new Location(TRACK_DIRECTORY, SECTOR_DIRECTORY); bool endFound = false; while (!endFound) { Sector sec = Tracks[curLoc.Track - 1].Sectors[curLoc.Sector]; for (int i = 0; i < 8; ++i) { int fileTrack = sec.Data.ByteAt(0x20 * i + 3); int fileSector = sec.Data.ByteAt(0x20 * i + 4); if (fileTrack != 0) { // valid entry? if (sec.Data.ByteAt(0x20 * i + 2) != (byte)C64Studio.Types.FileType.SCRATCHED) { GR.Memory.ByteBuffer filename = sec.Data.SubBuffer(0x20 * i + 5, 16); if (Filename.Compare(filename) == 0) { FileLocation = new Location(fileTrack, fileSector); FileInfo = new C64Studio.Types.FileInfo(); FileInfo.Filename = new GR.Memory.ByteBuffer(filename); FileInfo.StartSector = fileSector; FileInfo.StartTrack = fileTrack; FileInfo.Type = (C64Studio.Types.FileType)sec.Data.ByteAt(0x20 * i + 2); FileInfo.Blocks = 0; return(true); } } } } curLoc = sec.NextLocation; if (curLoc == null) { // track = 0 marks last directory entry break; } } _LastError = "Could not locate directory entry for file"; return(false); }
public override Types.FileInfo LoadFile(GR.Memory.ByteBuffer Filename) { _LastError = ""; if (Filename.Compare(this.Filename) != 0) { _LastError = "file not found"; return(null); } Types.FileInfo fileInfo = new C64Studio.Types.FileInfo(); fileInfo.Type = C64Studio.Types.FileType.PRG; fileInfo.Data = new GR.Memory.ByteBuffer(Data); fileInfo.Filename = new GR.Memory.ByteBuffer(Filename); return(fileInfo); }