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(); }
static void Main(string[] args) { Boolean mounted = false; Logger.UsuallyDebugging = false; Logger.setLogger(null); try { Logger.getLogger().log(AssemblyHelper.About(System.Reflection.Assembly.GetExecutingAssembly())); if (args.Length < 3) { Logger.getLogger().log("Usage: ChunkFS <mountpoint> <chunksize> <sourcefile>..."); return; } CFSDriveConfig cfg = new CFSDriveConfig("CmdLineDrive", args[0], args[1], args, 2); ChunkFSDriver theDrive = new ChunkFSDriver(cfg); if (theDrive.Init()) { Logger.getLogger().log("drive will be mounted now, to unmount hit <CTRL>C"); mounted = true; theDrive.exec(); } else { Logger.getLogger().log("Init() failed, drive not mounted"); } } catch (Exception ex) { mounted = false; Logger.getLogger().log("failed, exception:" + ex.Message + ex.StackTrace); } finally { if (mounted) { Logger.getLogger().log("drive unmounted"); } } }
static void Main(string[] args) { Boolean mounted = false; Logger.UsuallyDebugging = false; Logger.setLogger(null); try { Logger.getLogger().log(AssemblyHelper.About(System.Reflection.Assembly.GetExecutingAssembly())); if (args.Length < 3) { Logger.getLogger().log("Usage: ChunkFS <mountpoint> <chunksize> <sourcefile>..."); return; } CFSDriveConfig cfg = new CFSDriveConfig("CmdLineDrive", args[0], args[1], args, 2); ChunkFSDriver theDrive = new ChunkFSDriver(cfg); if (theDrive.Init()) { Logger.getLogger().log("drive will be mounted now, to unmount hit <CTRL>C"); mounted = true; theDrive.exec(); } else { Logger.getLogger().log("Init() failed, drive not mounted"); } } catch (Exception ex) { mounted = false; Logger.getLogger().log("failed, exception:" + ex.Message + ex.StackTrace); } finally { if (mounted) Logger.getLogger().log("drive unmounted"); } }
public void add(CFSDriveConfig drive) { Drives.Add(drive); }
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(); }
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); }
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); }
public ChunkFSDriver(CFSDriveConfig config) { Config = config; init(); }
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); }
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; }