Esempio n. 1
0
        private void clusterViewerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ClusterForm cf = new ClusterForm();

            cf.clusterBitmaps1.GradientStart = Color.WhiteSmoke;
            cf.clusterBitmaps1.GradientEnd   = Color.Black;
            cf.Show();
        }
Esempio n. 2
0
        private void defragTestToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //-> VDisk Id=38469a5b-1194-4464-a21e-4d3120c18bb3
            //-> VDisk Device Name=\\?\scsi#disk&ven_msft&prod_virtual_disk#2&1f4adffe&0&000001#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
            //-> VDisk Path=\\pt3\raid1\VHDs\Tiny7.vhd
            //-> Disk Name=\\?\PhysicalDrive1
            //-> Disk Friendly=Msft Virtual Disk SCSI Disk Device
            BitArray ba        = defraglib.IOWrapper.GetVolumeMap(@"c:");
            int      nClusters = ba.Count;

            ClusterForm cf = new ClusterForm();

            cf.Icon = Icon;
            cf.Text = Text = " - Cluster Map of F:";
            //cf.clusterBitmaps1.GradientStart = Color.WhiteSmoke;
            //cf.clusterBitmaps1.GradientEnd = Color.Black;
            //cf.clusterBitmaps1.GradientSteps = 8;
            cf.clusterBitmaps1.Clusters = ba;
            cf.Show();

            //    static public BitArray GetVolumeMap(string DeviceName)
            // \\?\PhysicalDrive1
        }
Esempio n. 3
0
        private void ProcessFiles(string[] files)
        {
            BitArray ba = new BitArray((int)fs.TotalClusters);

            foreach (var file in files)
            {
                try
                {
                    Range <long, long>[] clusters = fs.PathToClusters(file);
                    foreach (var range in clusters)
                    {
                        int end = (int)(range.Offset + range.Count);
                        for (int i = (int)range.Offset; i < end; i++)
                        {
                            ba.Set(i, true);
                        }
                    }
                }
                catch (FileNotFoundException ex)
                {
                    System.Console.WriteLine("FileNotFound: {0}", file);
                }
            }

            // BitArray ba = defraglib.IOWrapper.GetVolumeMap(@"f:");


            ClusterForm cf = new ClusterForm();

            cf.Icon = Icon;
            cf.Text = Text + " - Cluster Map";
            //cf.clusterBitmaps1.GradientStart = Color.WhiteSmoke;
            //cf.clusterBitmaps1.GradientEnd = Color.Black;
            //cf.clusterBitmaps1.GradientSteps = 8;
            cf.clusterBitmaps1.Clusters = ba;
            cf.Show();
        }
Esempio n. 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            DiscUtils.VolumeManager volMgr = new VolumeManager();
            volMgr.AddDisk(VirtualDisk.OpenDisk(textBox1.Text, FileAccess.Read));


            Stream partitionStream = null;

            if (!string.IsNullOrEmpty(VolumeId))
            {
                partitionStream = volMgr.GetVolume(VolumeId).Open();
            }
            else if (Partition >= 0)
            {
                partitionStream = volMgr.GetPhysicalVolumes()[Partition].Open();
            }
            else
            {
                partitionStream = volMgr.GetLogicalVolumes()[0].Open();
            }

            SparseStream cacheStream = SparseStream.FromStream(partitionStream, Ownership.None);

            cacheStream = new BlockCacheStream(cacheStream, Ownership.None);

            fs = new NtfsFileSystem(cacheStream);
            fs.NtfsOptions.HideHiddenFiles = false;
            fs.NtfsOptions.HideSystemFiles = false;
            fs.NtfsOptions.HideMetafiles   = false;

            ClusterMap clusterMap = null;

            try
            {
                clusterMap = fs.BuildClusterMap();
            }
            catch (IOException ex)
            {
                // DebugConsole.LogException(ex, "Trying to build a clustermap of " + textBox1.Text);
                MessageBox.Show(ex.Message, "Exception");
                // return;
            }
            // string[] files = null;


            // string[] sysfiles = fs.GetFileSystemEntries(@"\");
            // string[] files = fs.GetFiles(@"\", "*.*", SearchOption.AllDirectories);
            // fs.Dump(Console.Out, "");

            //QueuedBackgroundWorker.QueueWorkItem(QueuedBackgroundWorker.m_Queue, null,
            //    (args) => { return fs.GetFiles(@"\", "*.*", SearchOption.AllDirectories); },
            //    (args) => { if (args.Result != null && args.Result is string[]) ProcessFiles((string[])args.Result); }
            //);

            BitArray ba = new BitArray((int)fs.TotalClusters);

            for (int i = 0; i < fs.TotalClusters; i++)
            {
                if (clusterMap.ClusterToPaths(i).Length > 0)
                {
                    ba.Set(i, true);
                }
            }

            ClusterForm cf = new ClusterForm();

            cf.Icon = Icon;
            cf.Text = Text + " - Cluster Map";
            //cf.clusterBitmaps1.GradientStart = Color.WhiteSmoke;
            //cf.clusterBitmaps1.GradientEnd = Color.Black;
            //cf.clusterBitmaps1.GradientSteps = 8;
            cf.clusterBitmaps1.Clusters = ba;
            cf.Show();
        }