Exemplo n.º 1
0
        /// <summary>
        /// Loads a <see cref="FileEntryGraph"/> from the specified file.
        /// </summary>
        /// <param name="file">The file to load a new <see cref="FileEntryGraph"/> from.</param>
        /// <param name="forFileName">The initial value for the returned objects <see cref="FileEntryGraph.ForFileName"/></param>
        /// <returns>The newly loaded <see cref="FileEntryGraph"/>.</returns>
        public static FileEntryGraph Load(FileInfo file, string forFileName)
        {
            var graph = new FileEntryGraph(forFileName);

            using (var f = file.OpenText())
            {
                f.ReadLine();//headings
                while (!f.EndOfStream)
                {
                    var line = f.ReadLine().Split(',');
                    if (line.Length != 5)
                    {
                        throw new IOException("Expected 5 fields!");
                    }
                    graph.Add(new FileEntry(line[0], Int64.Parse(line[1]), DeserializeDate(line[2]), DeserializeDate(line[3]), DeserializeAttributes(line[4])));
                }
            }
            return(graph);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets a <see cref="FileEntryGraph"/> representing the files in the specified outputDir (where an MSI was extracted).
        /// </summary>
        public static FileEntryGraph GetActualEntries(string outputDir, string forFileName)
        {
            var actualEntries = new FileEntryGraph(forFileName);
            var dir           = new DirectoryInfo(outputDir);
            var dirsToProcess = new Stack <DirectoryInfo>();

            dirsToProcess.Push(dir);
            while (dirsToProcess.Count > 0)
            {
                dir = dirsToProcess.Pop();
                foreach (var file in dir.GetFiles())
                {
                    actualEntries.Add(new FileEntry(file, outputDir));
                }
                foreach (var subDir in dir.GetDirectories())
                {
                    dirsToProcess.Push(subDir);
                }
            }
            return(actualEntries);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Loads a <see cref="FileEntryGraph"/> from the specified file.
        /// </summary>
        /// <param name="file">The file to load a new <see cref="FileEntryGraph"/> from.</param>
        /// <param name="forFileName">The initial value for the returned objects <see cref="FileEntryGraph.ForFileName"/></param>
        /// <returns>The newly loaded <see cref="FileEntryGraph"/>.</returns>
        public static FileEntryGraph Load(FileInfo file, string forFileName)
        {
            var graph = new FileEntryGraph(forFileName);

            using (var f = file.OpenText())
            {
                f.ReadLine();//headings
                while (!f.EndOfStream)
                {
                    var line = f.ReadLine().Split(',');
                    if (line.Length != 5)
                    {
                        throw new IOException("Expected 5 fields!");
                    }

                    /* FIX for github issue #23:
                     * The problem was that old ExpectedOutput files were all prefixed with C:\projects\lessmsi\src\Lessmsi.Tests\bin\Debug\<msiFileNameWithoutExtension> (something like C:\projects\lessmsi\src\Lessmsi.Tests\bin\Debug\NUnit-2.5.2.9222\SourceDir\PFiles\NUnit 2.5.2\fit-license.txt)
                     * We need to remove Since we don't reasonably know what the original msi filename was, we do know it was the subdirectory of C:\projects\lessmsi\src\Lessmsi.Tests\bin\Debug\. So we should remove C:\projects\lessmsi\src\Lessmsi.Tests\bin\Debug\ and the next subdirectory from the path.
                     * HACK: A better fix would undoubtedly be to cleanup those old file swith code like this and remove this hack from this code forever!
                     */
                    var          path        = line[0];
                    const string oldRootPath = @"C:\projects\lessmsi\src\Lessmsi.Tests\bin\Debug\";
                    if (path.StartsWith(oldRootPath, StringComparison.InvariantCultureIgnoreCase))
                    {
                        //this is an old file that would trigger github issue #23, so we'll fix it here...
                        // first remove the old root path:
                        path = path.Substring(oldRootPath.Length);
                        // now romove the msi filename (which we don't know, but we know it is the next subdirectory of the old root):
                        var lengthOfSubDirectoryName = path.IndexOf('\\', 0);
                        path = path.Substring(lengthOfSubDirectoryName);
                    }
                    graph.Add(new FileEntry(path, Int64.Parse(line[1]), DeserializeDate(line[2]), DeserializeDate(line[3]), DeserializeAttributes(line[4])));
                }
            }
            return(graph);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Gets a <see cref="FileEntryGraph"/> representing the files in the specified outputDir (where an MSI was extracted).
 /// </summary>
 public static FileEntryGraph GetActualEntries(string outputDir, string forFileName)
 {
     var actualEntries = new FileEntryGraph(forFileName);
     var dir = new DirectoryInfo(outputDir);
     var dirsToProcess = new Stack<DirectoryInfo>();
     dirsToProcess.Push(dir);
     while (dirsToProcess.Count > 0)
     {
         dir = dirsToProcess.Pop();
         foreach (var file in dir.GetFiles())
         {
             actualEntries.Add(new FileEntry(file, outputDir));
         }
         foreach (var subDir in dir.GetDirectories())
         {
             dirsToProcess.Push(subDir);
         }
     }
     return actualEntries;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Loads a <see cref="FileEntryGraph"/> from the specified file.
 /// </summary>
 /// <param name="file">The file to load a new <see cref="FileEntryGraph"/> from.</param>
 /// <param name="forFileName">The initial value for the returned objects <see cref="FileEntryGraph.ForFileName"/></param>
 /// <returns>The newly loaded <see cref="FileEntryGraph"/>.</returns>
 public static FileEntryGraph Load(FileInfo file, string forFileName)
 {
     var graph = new FileEntryGraph(forFileName);
     using (var f = file.OpenText())
     {
         f.ReadLine();//headings
         while (!f.EndOfStream)
         {
             var line = f.ReadLine().Split(',');
             if (line.Length != 5)
                 throw new IOException("Expected 5 fields!");
             /* FIX for github issue #23:
              * The problem was that old ExpectedOutput files were all prefixed with C:\projects\lessmsi\src\Lessmsi.Tests\bin\Debug\<msiFileNameWithoutExtension> (something like C:\projects\lessmsi\src\Lessmsi.Tests\bin\Debug\NUnit-2.5.2.9222\SourceDir\PFiles\NUnit 2.5.2\fit-license.txt)
              * We need to remove Since we don't reasonably know what the original msi filename was, we do know it was the subdirectory of C:\projects\lessmsi\src\Lessmsi.Tests\bin\Debug\. So we should remove C:\projects\lessmsi\src\Lessmsi.Tests\bin\Debug\ and the next subdirectory from the path.
              * HACK: A better fix would undoubtedly be to cleanup those old file swith code like this and remove this hack from this code forever!
              */
             var path = line[0];
             const string oldRootPath = @"C:\projects\lessmsi\src\Lessmsi.Tests\bin\Debug\";
             if (path.StartsWith(oldRootPath, StringComparison.InvariantCultureIgnoreCase))
             {
                 //this is an old file that would trigger github issue #23, so we'll fix it here...
                 // first remove the old root path:
                 path = path.Substring(oldRootPath.Length);
                 // now romove the msi filename (which we don't know, but we know it is the next subdirectory of the old root):
                 var lengthOfSubDirectoryName = path.IndexOf('\\', 0);
                 path = path.Substring(lengthOfSubDirectoryName);
             }
             graph.Add(new FileEntry(path, Int64.Parse(line[1]), DeserializeDate(line[2]), DeserializeDate(line[3]), DeserializeAttributes(line[4])) );
         }
     }
     return graph;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Loads a <see cref="FileEntryGraph"/> from the specified file.
 /// </summary>
 /// <param name="file">The file to load a new <see cref="FileEntryGraph"/> from.</param>
 /// <param name="forFileName">The initial value for the returned objects <see cref="FileEntryGraph.ForFileName"/></param>
 /// <returns>The newly loaded <see cref="FileEntryGraph"/>.</returns>
 public static FileEntryGraph Load(FileInfo file, string forFileName)
 {
     var graph = new FileEntryGraph(forFileName);
     using (var f = file.OpenText())
     {
         f.ReadLine();//headings
         while (!f.EndOfStream)
         {
             var line = f.ReadLine().Split(',');
             if (line.Length != 5)
                 throw new IOException("Expected 5 fields!");
             graph.Add(new FileEntry(line[0], Int64.Parse(line[1]), DeserializeDate(line[2]), DeserializeDate(line[3]), DeserializeAttributes(line[4])) );
         }
     }
     return graph;
 }