public static IEnumerable <AzusaStorageSpaceDrive> FindConnectedStorageSpaces() { int ordinal = 0; foreach (DriveInfo driveInfo in DriveInfo.GetDrives()) { string xmlFilename = Path.Combine(driveInfo.RootDirectory.FullName, "azusa_storagespace_id.xml"); FileInfo xmlFile = new FileInfo(xmlFilename); if (xmlFile.Exists) { AzusaStorageSpaceDrive drive = new AzusaStorageSpaceDrive(); drive.StorageSpace = AzusaStorageSpace.Load(xmlFile); drive.RootDirectory = driveInfo.RootDirectory; drive.Ordinal = ordinal++; yield return(drive); } } }
public void SetDumpFile(FileInfo fi) { //Path setzen DumpStorageSpacePath = fi.FullName.Substring(fi.Directory.Root.FullName.Length); //SpaceId setzen string rootName = fi.Directory.Root.FullName; string mediaId = Path.Combine(rootName, "azusa_storagespace_id.xml"); if (File.Exists(mediaId)) { var ami = AzusaStorageSpace.Load(new FileInfo(mediaId)); if (ami.MediaNo > 0) { DumpStorageSpaceId = (int)ami.MediaNo; } } //FauxHash setzen byte[] buffer = new byte[512]; string filename = fi.FullName; FileStream fs = File.OpenRead(filename); int headerLen = fs.Read(buffer, 0, 512); fs.Dispose(); long result = 0; for (int i = 0; i < headerLen; i++) { result += buffer[i]; result <<= 1; } FauxHash = result; }