コード例 #1
0
ファイル: DisableClm.cs プロジェクト: raystyle/Stracciatella
        private static string FindWritableImplantPath(string root)
        {
            foreach (string f in SafeWalk.EnumerateFiles(root, "*.dll", SearchOption.AllDirectories))
            {
                string p = Path.GetDirectoryName(f);
                if (CheckDirectoryWritePrivilege(p, FileSystemRights.FullControl))
                {
                    return(p);
                }
            }

            return("");
        }
コード例 #2
0
ファイル: HashProcessor.cs プロジェクト: junk13/sfshu
 public void Run()
 {
     //see if we have a single file, path
     if (File.Exists(Path))
     {
         _RunFile(Path);
     }
     else
     {
         foreach (var file in SafeWalk.EnumerateFiles(Path, "*", SearchOption.AllDirectories))
         {
             _RunFile(file);
         }
     }
 }
コード例 #3
0
        public void IndexDirectory(string path, HashSet <string> ignoredDirectories, ExtensionContainer extensionContainer)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                return;
            }

            try
            {
                var traverseDirectoriesWatch = Stopwatch.StartNew();

                var allFiles = SafeWalk.EnumerateFiles(path, ignoredDirectories);

                var paths = allFiles
                            .Where(x => extensionContainer.IsKnownExtension(Path.GetExtension(x)))
                            .Distinct()
                            .ToArray();

                traverseDirectoriesWatch.Stop();

                var indexWatch = Stopwatch.StartNew();

                try
                {
                    _lock.EnterWriteLock();
                    _indexData.Update(path, paths);
                    SaveIndex();
                }
                finally
                {
                    _lock.ExitWriteLock();
                }

                indexWatch.Stop();

                var traverseMs = traverseDirectoriesWatch.ElapsedMilliseconds;
                var indexMs    = indexWatch.ElapsedMilliseconds;
                var totalMs    = indexWatch.ElapsedMilliseconds + traverseDirectoriesWatch.ElapsedMilliseconds;

                Log.Information($"Index {path} - {paths.Length} items. [ {totalMs} ms, tra: {traverseMs} ms, idx: {indexMs} ms ]");
            }
            catch (Exception e)
            {
                Log.Error(e, "Failed to index path: {path}, message: {message}", path, e.Message);
            }
        }
コード例 #4
0
 private static string FindLocalDbUtility()
 {
     return(SafeWalk.EnumerateFiles("C:\\Program Files\\Microsoft SQL Server", "SqlLocalDb.exe", SearchOption.AllDirectories).OrderBy(p => p)
            .LastOrDefault());
 }