protected internal FATX.IOReader br_dumpReader() { try { br.Close(); } catch { } br = new FATX.IOReader(fs_dumpStream()); try { driveSize = br.BaseStream.Length; } catch { } return(br); }
public bool BackupDrive(ref long Progress, string savePath) { FATX.IOWriter fileWriter = null; FATX.IOReader driveReader = null; try { long driveSize = DriveSize; fileWriter = new FATX.IOWriter(new System.IO.FileStream(savePath, System.IO.FileMode.Create)); driveReader = this.GetIO(); for (long i = 0; i < driveSize; i += 0x4000, Progress += 0x4000) { byte[] buffer = driveReader.ReadBytes(0x4000); fileWriter.Write(buffer); } fileWriter.Close(); driveReader.Close(); return(true); } catch { try { fileWriter.Close(); driveReader.Close(); } catch { } return(false); } }
public bool RestoreBackup(ref long Progress, string inFile) { FATX.IOReader fileReader = null; FATX.IOWriter driveWriter = null; try { long driveSize = DriveSize; fileReader = new FATX.IOReader(new System.IO.FileStream(inFile, System.IO.FileMode.Open)); driveWriter = this.GetWriterIO(); for (long i = 0; i < driveSize; i += 0x4000, Progress += 0x4000) { byte[] buffer = fileReader.ReadBytes(0x4000); driveWriter.Write(buffer); } driveWriter.Close(); fileReader.Close(); return(true); } catch { try { fileReader.Close(); driveWriter.Close(); } catch { } return(false); } }
public bool Close() { try { io.Close(); } catch {} try { bw.Close(); } catch {} try { br.Close(); } catch {} closed = true; return(true); }
/// <summary> /// Returns an array of valid FATXDrives /// </summary> public FATX.FATXDrive[] GetFATXDrives(int range) { List <FATX.FATXDrive> driveList = new List <FATX.FATXDrive>(); try { ///Gets physical disks for (int i = 0; i < range; i++) { try { //Start reading the physical drive fs = fs_diskStream(i); br = br_diskReader(i); //Seek to the FATX partition try { br.BaseStream.Position = (long)FATX.Info.HDDFATX.Partitions.Data; //Read the header byte[] header = br.ReadBytes(0x4); //Convert the header to a string, check if it's fatx if (Encoding.ASCII.GetString(header) == "XTAF") { FATX.FATXDrive drive = new FATXDrive(i, FATX.Info.DriveType.HDD); driveList.Add(drive); } // Check to see if it's a dev drive... else { br.BaseStream.Position = (long)FATX.Info.HDDFATX.DevOffsets.Content; // Read the header byte[] devheader = br.ReadBytes(0x4); // Convert header to a string, check to see if it's fatx if (Encoding.ASCII.GetString(devheader) == "XTAF") { FATX.FATXDrive drive = new FATXDrive(i, FATX.Info.DriveType.HDD); drive.IsDev = true; driveList.Add(drive); } } } catch { br.Close(); fs.Close(); diskDrive.Close(); continue; } br.Close(); fs.Close(); diskDrive.Close(); bool closed = diskDrive.IsClosed; } catch { fs.Close(); br.Close(); diskDrive.Close(); continue; } } ///Gets usb drives DriveInfo[] drives = DriveInfo.GetDrives(); ///Check to see if the drive has a subdirectory of "Xbox360" foreach (DriveInfo drive in drives) { if (drive.Name == @"A:\" || drive.Name == @"B:\" || drive.DriveType == DriveType.NoRootDirectory || drive.DriveType == DriveType.CDRom || drive.DriveType == DriveType.Network || drive.DriveType == DriveType.Unknown) { continue; } //If the directory does not exist DirectoryInfo di = new DirectoryInfo(drive.Name + "Xbox360"); if (!di.Exists) { continue; } else { //Check to make sure that there's actually files in that directory.. FileInfo[] fi = di.GetFiles(); bool found = false; foreach (FileInfo file in fi) { string name = file.Name.ToLower(); if (name == "data0000" || name == "data0001" || name == "data0002") { found = true; break; } } if (!found) { continue; } } driveList.Add(new FATXDrive(drive.Name + "Xbox360", Info.DriveType.USB, drive.VolumeLabel)); } return(driveList.ToArray()); } catch { return(driveList.ToArray()); } }