ScannedFile: Allow skipping canonicalization

This commit is contained in:
Arne Welzel 2025-02-28 17:31:58 +01:00
parent 3c16b0720a
commit 2a8040039a
2 changed files with 10 additions and 3 deletions

View file

@ -13,14 +13,15 @@ namespace zeek::detail {
std::list<ScannedFile> files_scanned;
std::vector<SignatureFile> sig_files;
ScannedFile::ScannedFile(int arg_include_level, std::string arg_name, bool arg_skipped, bool arg_prefixes_checked)
ScannedFile::ScannedFile(int arg_include_level, std::string arg_name, bool arg_skipped, bool arg_prefixes_checked,
bool arg_is_canonical)
: include_level(arg_include_level),
skipped(arg_skipped),
prefixes_checked(arg_prefixes_checked),
name(std::move(arg_name)) {
if ( name == canonical_stdin_path )
canonical_path = canonical_stdin_path;
else {
else if ( ! arg_is_canonical ) {
std::error_code ec;
auto canon = filesystem::canonical(name, ec);
if ( ec )
@ -28,6 +29,9 @@ ScannedFile::ScannedFile(int arg_include_level, std::string arg_name, bool arg_s
canonical_path = canon.string();
}
else {
canonical_path = name;
}
}
bool ScannedFile::AlreadyScanned() const {

View file

@ -12,10 +12,13 @@ namespace zeek::detail {
// Script file we have already scanned (or are in the process of scanning).
// They are identified by normalized canonical path.
//
// If arg_is_canonical is set to true, assume arg_name is canonicalized and
// skip resolving the canonical name.
class ScannedFile {
public:
ScannedFile(int arg_include_level, std::string arg_name, bool arg_skipped = false,
bool arg_prefixes_checked = false);
bool arg_prefixes_checked = false, bool arg_is_canonical = false);
/**
* Compares the canonical path of this file against every canonical path