private List<DalleFile> getListaFicheros(FileInfo fichero) { DirectoryInfo dirFiles = fichero.Directory; List<DalleFile> ret = new List<DalleFile> (); TextReader reader = File.OpenText (fichero.FullName); string linea; linea = reader.ReadLine (); while (linea != null) { int idx = linea.IndexOf (';'); if (idx >= 0) linea = linea.Substring (0, linea.IndexOf (';')); linea = linea.Trim (); if (linea != string.Empty) { try { string fname = linea.Substring (linea.IndexOf (" ")).Trim (); string hash = linea.Substring (0, linea.IndexOf (" ")).Trim (); fname = fname.Replace ('/', Path.DirectorySeparatorChar); DalleFile el = new DalleFile (new FileInfo(dirFiles.FullName + Path.DirectorySeparatorChar + fname), hash); ret.Add (el); } catch (System.Exception) { } } linea = reader.ReadLine (); } reader.Close (); return ret; }
public override int Read(byte[] buffer, int offset, int count) { if (currentStream == null) { if (currentIndex == Int32.MaxValue) { return 0; } if (currentIndex < listaFicheros.Count) { currentIndex++; } if (currentIndex >= listaFicheros.Count) { return 0; } currentFile = listaFicheros[currentIndex]; currentStream = new HashStream ( File.OpenRead (currentFile.File.FullName), HashAlgorithm.Create ("SHA512"), currentFile.Hash ); } int tmp = 0; tmp = currentStream.Read (buffer, offset, count); position += tmp; if (tmp < count) { try { currentStream.Close (); } catch (ChecksumVerificationException ex) { throw new ChecksumVerificationException (ex.Message, currentFile.File.FullName, ex); } catch (IOException e) { throw new IOException (currentFile.File + " " + e.Message); } currentStream = null; tmp += this.Read(buffer, offset+tmp, count - tmp); } return tmp; }