Exemplo n.º 1
0
 public Comments(HashFile file)
 {
     InitializeComponent();
     sfv = file;
     if (sfv != null)
         textBoxComments.Text = sfv.Comments;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Processes command line argument sent to the application.
 /// </summary>
 /// <param name="args">String array of arguments.</param>
 static void ProcessArguments(string[] args)
 {
     foreach (string arg in args)
     {
         if (!String.IsNullOrEmpty(arg))
         {
             FileInfo fi = new FileInfo(arg);
             if (fi.Exists)
             {
                 if (HashFile.IsHashFile(fi))
                 {
                     HashFile sfv = new HashFile(fi.FullName);
                     Program.CoreWorkQueue.Add(sfv.ReadAll());
                 }
                 else
                 {
                     Program.CoreWorkQueue.Add(new QueueItem(fi, StringUtilities.FindCRC(fi.Name), QueueItemAction.TestHash, HashType.CRC));
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 public HashFile SaveResultsToFile()
 {
     HashFile file = new HashFile(_OutputFile);
     // Clear all current results incase the file already existed and had some of these entries
     file.Clear();
     file.Add(this._ResultsList);
     if (file.Save())
     {
         return file;
     }
     else
     {
         return null;
     }
 }
Exemplo n.º 4
0
        private void ScanHashFilesAndAdd(string[] fileNames)
        {
            if (fileNames.Length == 0)
                return;

            // Pre-sort file list
            Array.Sort(fileNames);

            // Load all hash files in this directory
            List<FileInfo> HashFileList = HashFile.GetHashFiles(new DirectoryInfo(Path.GetDirectoryName(fileNames[0])));
            HashFile[] HashFiles = new HashFile[HashFileList.Count];
            for (int i = 0; i < HashFileList.Count; i++)
            {
                HashFiles[i] = new HashFile(HashFileList[i].FullName);
            }

            // Add the contents of any selected hash files to the work queue
            foreach (string FileName in fileNames)
            {
                if (HashFile.IsHashFile(FileName))
                {
                    HashFile hf = new HashFile(FileName);
                    Program.CoreWorkQueue.Add(hf.ReadAll());
                }
            }

            // Add the selected files to the work queue
            foreach (string FileName in fileNames)
            {
                // Check the SFV files in the directory for information on this file
                bool FoundCRCInSFV = false;
                foreach (HashFile sfv in HashFiles)
                {
                    string FileHash = sfv.GetHash(Path.GetFileName(FileName));
                    if (!String.IsNullOrEmpty(FileHash))
                    {
                        Program.CoreWorkQueue.Add(new QueueItem(new FileInfo(FileName), FileHash, QueueItemAction.TestHash, HashType.CRC));
                        FoundCRCInSFV = true;
                        break;
                    }
                }

                // If there was no information found in the SFVs then try to parse the file name
                if (!FoundCRCInSFV)
                {
                    // Only add hash files if they have an embedded hash... any other file will be added simply because it's not a hash file
                    string EmbeddedCRC = StringUtilities.FindCRC(FileName);
                    if (!String.IsNullOrEmpty(EmbeddedCRC) || !HashFile.IsHashFile(FileName))
                    {
                        Program.CoreWorkQueue.Add(new QueueItem(new FileInfo(FileName), EmbeddedCRC, QueueItemAction.TestHash, HashType.CRC));
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void RecursiveDirectoryGrab(string directory)
        {
            DirectoryInfo RootDirectory = new DirectoryInfo(directory);
            foreach (DirectoryInfo dir in RootDirectory.GetDirectories())
            {
                // Load hash files first
                List<FileInfo> HashFiles = HashFile.GetHashFiles(dir);
                foreach (FileInfo file in HashFiles)
                {
                    HashFile hf = new HashFile(file.FullName);
                    Program.CoreWorkQueue.Add(hf.ReadAll());
                }

                foreach (FileInfo TargetFile in dir.GetFiles())
                {
                    if (!HashFile.IsHashFile(TargetFile))
                    {
                        Program.CoreWorkQueue.Add(new QueueItem(TargetFile, StringUtilities.FindCRC(TargetFile.Name), QueueItemAction.TestHash, HashType.CRC));
                    }
                }

                RecursiveDirectoryGrab(dir.FullName);
            }
        }
Exemplo n.º 6
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.Title = "Select the file you want to process";
            openFileDialog1.Filter = "Hash Files (*.sfv, *.md5)|*.sfv;*.md5|SFV File (*.sfv)|*.sfv|MD5 File (*.md5)|*.md5";

            if (openFileDialog1.ShowDialog() != DialogResult.Cancel)
            {
                HashFile TargetFile = new HashFile(openFileDialog1.FileName);

                if (TargetFile.Exists)
                {
                    QueueItem[] HashItems = TargetFile.ReadAll();

                    if (HashItems.Length > 0)
                    {
                        Program.CoreWorkQueue.Reset();
                        Program.CoreWorkQueue.Add(HashItems);
                        CurrentHashFile = TargetFile;
                        ResetInfoAndLaunchWorker();
                    }
                    else
                    {
                        MessageBox.Show("The file does not appear to contain any file/checksum pairs.", "Unable to parse file", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void listView1_DragDrop(object sender, DragEventArgs e)
        {
            string[] s = (string[])e.Data.GetData(DataFormats.FileDrop, false);

            Program.CoreWorkQueue.Reset();

            // Load the files
            ScanHashFilesAndAdd(s);

            if (Program.CoreWorkQueue.RemainingRecords > 0 && s.Length > 0)
            {
                if (s.Length == 1 && HashFile.IsHashFile(s[0]))
                {
                    CurrentHashFile = new HashFile(s[0]);
                }
                //ResetInfoAndLaunchWorker();
                timer1.Start();
            }
        }
Exemplo n.º 8
0
        private void filesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.Title = "Select the files you want to check";
            openFileDialog1.Filter = "All Files|*.*";

            if (openFileDialog1.ShowDialog() != DialogResult.Cancel)
            {
                Program.CoreWorkQueue.Reset();
                ScanHashFilesAndAdd(openFileDialog1.FileNames);
                if (openFileDialog1.FileNames.Length == 1 && HashFile.IsHashFile(openFileDialog1.FileNames[0]))
                {
                    CurrentHashFile = new HashFile(openFileDialog1.FileNames[0]);
                }
                else
                {
                    CurrentHashFile = null;
                }
                ResetInfoAndLaunchWorker();
            }
        }
Exemplo n.º 9
0
        private void directoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() != DialogResult.Cancel)
            {
                DirectoryInfo dir = new DirectoryInfo(folderBrowserDialog1.SelectedPath);

                if (dir.Exists)
                {
                    FileInfo[] DirectoryFiles = dir.GetFiles();
                    List<FileInfo> HashFiles = HashFile.GetHashFiles(dir);

                    Program.CoreWorkQueue.Reset();

                    // Load hash files first
                    foreach (FileInfo file in HashFiles)
                    {
                        HashFile hf = new HashFile(file.FullName);
                        Program.CoreWorkQueue.Add(hf.ReadAll());
                    }

                    // Add all the files in the base directory
                    foreach (FileInfo TargetFile in DirectoryFiles)
                    {
                        if (!HashFile.IsHashFile(TargetFile))
                        {
                            Program.CoreWorkQueue.Add(new QueueItem(TargetFile, StringUtilities.FindCRC(TargetFile.Name), QueueItemAction.TestHash, HashType.CRC));
                        }
                    }

                    // Recursive grab
                    RecursiveDirectoryGrab(dir.FullName);

                    if (DirectoryFiles.Length == 1 && HashFile.IsHashFile(DirectoryFiles[0]))
                    {
                        CurrentHashFile = new HashFile(DirectoryFiles[0].Name);
                    }
                    else
                    {
                        CurrentHashFile = null;
                    }
                    ResetInfoAndLaunchWorker();
                }
                else
                {
                    MessageBox.Show("Target directory does not exist!", "Directory does not exist", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 10
0
        private void addCRCToNamesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.Title = "Select the files you append CRCs to";
            openFileDialog1.Filter = "All Files|*.*";

            if (openFileDialog1.ShowDialog() != DialogResult.Cancel)
            {
                // Pre-sort file list
                Array.Sort(openFileDialog1.FileNames);

                // Add the files to the work queue
                Program.CoreWorkQueue.Reset();
                foreach (string File in openFileDialog1.FileNames)
                {
                    Program.CoreWorkQueue.Add(new QueueItem(new FileInfo(File), QueueItemAction.AppendHash, HashType.CRC));
                }
                CurrentHashFile = null;
                ResetInfoAndLaunchWorker();
            }
        }