/// <summary> /// Converts the <paramref name="paths"/> list into a byte array containing the amount of paths in the /// <paramref name="paths"/> as a first <c>int</c>, and the unicode-converted list of paths after it. /// </summary> /// <param name="paths">List of paths to convert.</param> /// <returns> /// Byte array suitable to be used as a <c>FETCH_PATHS</c> data. /// </returns> private static byte[] GetWatchPathsData(IEnumerable <string> paths) { if (paths == null) { paths = new string[0]; } // This will replace the Windows path roots with the device names. string[] pathsArray = paths.ToArray(); // See the 'FETCH_PATHS' structure for more details. List <byte> data = new List <byte>(BitConverter.GetBytes(pathsArray.Length)); // Convert strings to byte array. foreach (string path in pathsArray) { data.AddRange(LazyCopyDriverClient.ConvertToDevicePath(path)); } return(data.ToArray()); }
/// <summary> /// Prevents a default instance of the <see cref="LazyCopyDriver"/> class from being created. /// </summary> private LazyCopyDriver() { // First, load the driver. FltmcManager.Instance.LoadFilter(Settings.Default.DriverName); // And connect to it. this.driverClient = new LazyCopyDriverClient(); this.driverClient.OpenFileInUserModeHandler += this.OpenFileInUserModeHandler; this.driverClient.CloseFileHandleHandler += this.CloseFileHandleHandler; this.driverClient.FetchFileInUserModeHandler += this.FetchFileInUserModeHandler; }
/// <summary> /// Clears the list of paths to watch. /// </summary> /// <exception cref="InvalidOperationException">Client is not connected to the driver.</exception> public void ClearWatchPaths() { this.ExecuteCommand(new DriverCommand(DriverCommandType.SetWatchPaths, LazyCopyDriverClient.GetWatchPathsData(null))); }
/// <summary> /// Sets the list of paths the driver should watch. /// </summary> /// <param name="paths">List of paths to watch and their report rates. Should be in DOS name format, for example: <c>\Device\HarddiskVolume1\Folder\</c></param> /// <exception cref="InvalidOperationException">Client is not connected to the driver.</exception> public void SetWatchPaths(string[] paths) { byte[] data = LazyCopyDriverClient.GetWatchPathsData(paths); this.ExecuteCommand(new DriverCommand(DriverCommandType.SetWatchPaths, data)); }