mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-11 09:49:22 +08:00
Remove nonrecursive implementation
This commit is contained in:
parent
29c34d1ae1
commit
e2a435a666
@ -3,48 +3,6 @@
|
||||
#include "FileLocksmith.h"
|
||||
#include "NtdllExtensions.h"
|
||||
|
||||
std::vector<ProcessResult> find_processes_nonrecursive(const std::vector<std::wstring>& paths)
|
||||
{
|
||||
NtdllExtensions nt_ext;
|
||||
std::set<std::wstring> kernel_paths;
|
||||
|
||||
for (const auto& path : paths)
|
||||
{
|
||||
auto kernel_path = nt_ext.path_to_kernel_name(path.c_str());
|
||||
if (!kernel_path.empty())
|
||||
{
|
||||
kernel_paths.insert(std::move(kernel_path));
|
||||
}
|
||||
}
|
||||
|
||||
std::map<DWORD, uint64_t> pid_counts;
|
||||
|
||||
for (auto handle_info : nt_ext.handles())
|
||||
{
|
||||
if (handle_info.type_name == L"File" && kernel_paths.contains(handle_info.kernel_file_name))
|
||||
{
|
||||
pid_counts[handle_info.pid]++;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<ProcessResult> result;
|
||||
|
||||
for (auto process_info : nt_ext.processes())
|
||||
{
|
||||
if (auto it = pid_counts.find(process_info.pid); it != pid_counts.end())
|
||||
{
|
||||
result.push_back(ProcessResult
|
||||
{
|
||||
.name = process_info.name,
|
||||
.pid = process_info.pid,
|
||||
.num_files = it->second
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool is_directory(const std::wstring path)
|
||||
{
|
||||
DWORD attributes = GetFileAttributesW(path.c_str());
|
||||
|
@ -9,10 +9,6 @@ struct ProcessResult
|
||||
uint64_t num_files;
|
||||
};
|
||||
|
||||
// First version, checks handles towards the given objects themselves.
|
||||
// In particular, if the object is a directory, its entries are not considered
|
||||
std::vector<ProcessResult> find_processes_nonrecursive(const std::vector<std::wstring>& paths);
|
||||
|
||||
// Second version, checks handles towards files and all subfiles and folders of given dirs, if any.
|
||||
std::vector<ProcessResult> find_processes_recursive(const std::vector<std::wstring>& paths);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user