예제 #1
0
        /// <summary>
        /// Returns true if path was enumerated by journal service
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public bool IsPathEnumerated(string path)
        {
            // get NTFS volume root
            var volumeRoot = USNJournal.GetVolumeRootFromPath(path);

            // get volume data
            if (!m_volumeDataDict.TryGetValue(volumeRoot, out var volumeData))
            {
                return(false);
            }

            if (volumeData.Files.Contains(path))
            {
                return(true); // do not append from previous set, already scanned
            }
            foreach (var folder in volumeData.Folders)
            {
                if (m_token.IsCancellationRequested)
                {
                    break;
                }

                if (path.Equals(folder, Utility.Utility.ClientFilenameStringComparison))
                {
                    return(true); // do not append from previous set, already scanned
                }
                if (Utility.Utility.IsPathBelowFolder(path, folder))
                {
                    return(true); // do not append from previous set, already scanned
                }
            }

            return(false); // append from previous set
        }
예제 #2
0
        /// <summary>
        /// Sort sources by root volume
        /// </summary>
        /// <param name="sources">List of sources</param>
        /// <returns>Dictionary of volumes, with list of sources as values</returns>
        private static Dictionary <string, List <string> > SortByVolume(IEnumerable <string> sources)
        {
            var sourcesByVolume = new Dictionary <string, List <string> >();

            foreach (var path in sources)
            {
                // get NTFS volume root
                var volumeRoot = USNJournal.GetVolumeRootFromPath(path);

                if (!sourcesByVolume.TryGetValue(volumeRoot, out var list))
                {
                    list = new List <string>();
                    sourcesByVolume.Add(volumeRoot, list);
                }

                list.Add(path);
            }

            return(sourcesByVolume);
        }