Exemple #1
0
 protected void CreateRecursive(string[] files, bool recursive, TextWriter writer)
 {
     foreach (string f in files){
         if (Directory.Exists (f)){
             if (recursive)
                 CreateRecursive (Directory.GetFileSystemEntries (f), recursive, writer);
         }
         else {
             SFVElement e = new SFVElement (f, "", new FileHasherSHA1());
             e.GenerateHash();
             PutSHA1 (e, writer);
         }
     }
 }
Exemple #2
0
 protected void CreateRecursive(string[] files, bool recursive, TextWriter writer)
 {
     foreach (string f in files){
         if (Directory.Exists (f)){
             if (recursive){
                 CreateRecursive (Directory.GetFileSystemEntries (f), recursive, writer);
             }
         }
         else {
             SFVElement e = new SFVElement (f, "", new FileHasherCrc32());
             e.GenerateHash();
             writer.WriteLine (f.Replace (Path.DirectorySeparatorChar, '\\') + " " + e.RealHash);
         }
     }
 }
 protected void OnFileCheck(SFVElement e, FileCheckResult res)
 {
     string msg;
     switch (res){
         case FileCheckResult.Ok:
             msg = Catalog.GetString("Ok");
             break;
         case FileCheckResult.NotFound:
             msg = Catalog.GetString("Not Found");
             break;
         case FileCheckResult.IsDirectory:
             msg = Catalog.GetString("Is Directory");
             break;
         case FileCheckResult.Failed:
             msg = Catalog.GetString("Failed!");
             break;
         default:
             msg = Catalog.GetString("Unknown error!");
             break;
     }
     if ((verbose) || (res != FileCheckResult.Ok) )
         Console.WriteLine ("{0,-40} {1}", e.FileName + "...", msg);
 }
Exemple #4
0
 protected override ArrayList GenerateSFVFileList(string file)
 {
     ArrayList ret = new ArrayList ();
     TextReader reader = File.OpenText (file);
     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 (0, linea.LastIndexOf (" ")).Trim();
                 string hash = linea.Substring (linea.LastIndexOf(" ")).Trim();
                 fname = fname.Replace ('\\', Path.DirectorySeparatorChar);
                 SFVElement el = new SFVElement (fname, hash, new FileHasherCrc32());
                 ret.Add (el);
             }
             catch (System.Exception) {
             }
         }
         linea = reader.ReadLine ();
     }
     return ret;
 }
Exemple #5
0
 protected virtual void PutSHA1(SFVElement e, TextWriter writer)
 {
     writer.WriteLine (e.RealHash + "  " + e.FileName);
 }
 protected void OnFileCheck(SFVElement e, FileCheckResult res)
 {
     if (this.FileCheck != null){
         this.FileCheck (e, res);
     }
 }
Exemple #7
0
 protected void OnFileEvent(SFVElement e, FileCheckResult r)
 {
     if (this.FileCheck != null)
         this.FileCheck (e, r);
 }