Ejemplo n.º 1
0
 private void manageGuiState(CFSDriveConfig dc)
 {
     currentFiles.SwitchTo(dc);
     this.pbUnmount.Enabled = dc.Mounted;
     this.pbMount.Enabled   = !dc.Mounted && dc.isValid();
     this.pbMonitor.Enabled = dc.Mounted;
 }
Ejemplo n.º 2
0
 private void dgConfigs_RowEnter(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex < myDrives.Count)
     {
         CFSDriveConfig dc = myDrives[e.RowIndex];
         manageGuiState(dc);
     }
 }
Ejemplo n.º 3
0
 public void Apply(CFSDriveConfig drive)
 {
     drive.Files.Clear();
     foreach (FileChoice fc in this)
     {
         drive.Files.Add(fc.FileName);
     }
 }
Ejemplo n.º 4
0
        public static void MyClassInitialize(TestContext testContext)
        {
            CFSDriveConfig config = new CFSDriveConfig("test", args[0], args[1], args, 2);

            target = new ChunkFSDriver(config);
            //bool ok = target.Init(args[1], args[2]);
            bool ok = target.Init();
        }
Ejemplo n.º 5
0
        public void InitTest()
        {
            CFSDriveConfig config = new CFSDriveConfig("test", args[0], args[1], args, 2);
            //bool ok = target.Init(args[1], args[2]);
            ChunkFSDriver target = new ChunkFSDriver(config);
            bool          ok     = target.Init();

            Assert.IsTrue(ok);
        }
Ejemplo n.º 6
0
 public wfCFSMonitor(CFSDriveConfig drive)
 {
     InitializeComponent();
     theDrive = drive;
     myStats  = new StatSource(new CFSStats());
     this.statBindingSource.DataSource = myStats;
     this.lbDrive.Text = "[" + drive.Name + "] on " + drive.MountPoint.ToUpper();
     run();
 }
Ejemplo n.º 7
0
        private void unMountDrive(CFSDriveConfig dc)
        {
            ChunkFSDriver theDrive = dc.RunningDriver;
            int           rc       = Dokan.DokanNet.DokanUnmount(dc.MountPoint.ToCharArray()[0]);

            dc.RunningDriver = null;
            dc.Mounted       = false;
            myDrives.ResetBindings();
            manageGuiState(dc);
        }
Ejemplo n.º 8
0
 private void dgFiles_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         CFSDriveConfig dc = this.myDrives[this.dgConfigs.CurrentCell.RowIndex];
         currentFiles.Apply(dc);
         manageGuiState(dc);
     }
     catch (Exception) { }
 }
Ejemplo n.º 9
0
        public void CFSDriveConfigConstructorTest()
        {
            string name  = null;
            string mount = "k:\\";
            string csize = "22.5G";

            string[]       files   = { "k:\\", "22.5G", "file1.big", "file2.big" };
            int            startix = 2;
            CFSDriveConfig target  = new CFSDriveConfig(name, mount, csize, files, startix);

            Assert.AreEqual(2, target.Files.Count);
        }
Ejemplo n.º 10
0
 private void pbUnmount_Click(object sender, EventArgs e)
 {
     try
     {
         int            ix = this.dgConfigs.CurrentCell.RowIndex;
         CFSDriveConfig dc = this.myDrives[ix];
         if (!dc.Mounted || dc.RunningDriver == null)
         {
             MessageBox.Show(this, "Drive config is not mounted", "Internal Error", MessageBoxButtons.OK);
             return;
         }
         unMountDrive(dc);
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message + ex.StackTrace, "Error", MessageBoxButtons.OK);
     }
 }
Ejemplo n.º 11
0
 private void pbMonitor_Click(object sender, EventArgs e)
 {
     try
     {
         int            ix = this.dgConfigs.CurrentCell.RowIndex;
         CFSDriveConfig dc = this.myDrives[ix];
         if (!dc.Mounted)
         {
             MessageBox.Show(this, "Drive is not mounted", "Error", MessageBoxButtons.OK);
             return;
         }
         wfCFSMonitor fmon = new wfCFSMonitor(dc);
         fmon.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message + ex.StackTrace, "Monitor Failed", MessageBoxButtons.OK);
     }
 }
Ejemplo n.º 12
0
 public void SwitchTo(CFSDriveConfig drive)
 {
     if (drive == currentOwner)
     {
         return;
     }
     if (currentOwner != null)
     {
         Apply(currentOwner);
     }
     this.Clear();
     currentOwner = drive;
     if (drive.Files != null)
     {
         foreach (string fn in drive.Files)
         {
             Add(new FileChoice(fn));
         }
     }
 }
Ejemplo n.º 13
0
 private void pbMount_Click(object sender, EventArgs e)
 {
     try
     {
         int            ix = this.dgConfigs.CurrentCell.RowIndex;
         CFSDriveConfig dc = this.myDrives[ix];
         if (!dc.isValid())
         {
             MessageBox.Show(this, "Drive config is not valid", "Error", MessageBoxButtons.OK);
             return;
         }
         ChunkFSDriver theDrive = new ChunkFSDriver(dc);
         if (theDrive.Init())
         {
             //MessageBox.Show("drive will be mounted now, to unmount hit <CTRL>C");
             Thread t = new Thread(new ThreadStart(theDrive.exec2));
             t.Start();
             dc.Mounted       = true;
             dc.RunningDriver = theDrive;
             myDrives.ResetBindings();
             manageGuiState(dc);
         }
         else
         {
             MessageBox.Show("Init() failed, drive not mounted");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message + ex.StackTrace, "Mount Failed", MessageBoxButtons.OK);
     }
     finally
     {
         //manageGuiState();
     }
 }
Ejemplo n.º 14
0
        public void ReadFileTest2()
        {
            bool remember = Logger.UsuallyDebugging;

            Logger.UsuallyDebugging = true;
            Logger.setLogger(null);
            int    kperchunk = 640;
            string infn      = TestDataHelper.locateTestText();
            string mount     = "k:\\";
            string csize     = "640K";

            string[]       files = { mount, csize, infn };
            CFSDriveConfig cfg   = new CFSDriveConfig(null, mount, csize, files, 2);
            ChunkFSDriver  cfs   = new ChunkFSDriver(cfg);

            cfs.Init();
            Assert.IsTrue(cfs.Count() > 0);

            uint readBytes         = 64 * 1024;
            uint readBytesExpected = readBytes;

            byte[] buffer = new byte[readBytes];

            string   filename       = infn.Substring(infn.LastIndexOf("\\") + 1);
            FileInfo fi             = new FileInfo(infn);
            long     actualsize     = fi.Length;
            string   outDir         = fi.DirectoryName + "\\out\\";
            int      bytesperchunk  = kperchunk * 1024;
            int      chunksExpected = (int)((actualsize + (long)bytesperchunk - 1L) / (long)bytesperchunk);

            long            offset = 0;
            DokanFileInfo   info   = new DokanFileInfo(0);
            FileInformation finf   = new FileInformation();
            int             ok;

            for (int i = 0; i < chunksExpected; i++)
            {
                // get file info and note the size
                string uniq   = fi.LastWriteTime.ToString("yyyyMMddHHmm", CultureInfo.InvariantCulture);
                string currfn = filename + "." + uniq + "." + (i + 1) + "." + chunksExpected;
                ok = cfs.GetFileInformation(currfn, finf, info);
                long currcs = finf.Length;

                // open the file, create an output file
                ok = cfs.CreateFile(currfn, FileAccess.Read, FileShare.Read, FileMode.Open, FileOptions.None, info);
                FileStream ofs = new FileStream(outDir + currfn, FileMode.Create, FileAccess.Write);

                // read all the bytes and write to output
                offset = 0;
                do
                {
                    ok = cfs.ReadFile(currfn, buffer, ref readBytes, offset, info);
                    ofs.Write(buffer, 0, (int)readBytes);
                    offset += readBytes;
                } while (offset + 1 < currcs);

                // close the input and output
                ok = cfs.Cleanup(currfn, info);
                ok = cfs.CloseFile(currfn, info);
                string ofn = ofs.Name;
                ofs.Close();
                new FileInfo(ofn).LastWriteTime = finf.LastWriteTime;
            }
            // now you can compare the files TODO

            //int expected = 0;
            //int actual;
            //actual = cfs.ReadFile(filename, buffer, ref readBytes, offset, info);
            //Assert.AreEqual(readBytesExpected, readBytes);
            //Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
            Logger.UsuallyDebugging = remember;
            Logger.setLogger(null);
        }