mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 20:18:20 +00:00
Deprecate BroFile::GetFile(), replace with BroFile::Get()
This commit is contained in:
parent
65aad4922d
commit
599eec297c
3 changed files with 9 additions and 11 deletions
11
src/File.cc
11
src/File.cc
|
@ -346,16 +346,11 @@ double BroFile::Size()
|
|||
return s.st_size;
|
||||
}
|
||||
|
||||
BroFile* BroFile::GetFile(const char* name)
|
||||
IntrusivePtr<BroFile> BroFile::Get(const char* name)
|
||||
{
|
||||
for ( const auto &el : open_files )
|
||||
{
|
||||
if ( el.first == name )
|
||||
{
|
||||
Ref(el.second);
|
||||
return el.second;
|
||||
}
|
||||
}
|
||||
return {NewRef{}, el.second};
|
||||
|
||||
return new BroFile(name, "w");
|
||||
return make_intrusive<BroFile>(name, "w");
|
||||
}
|
||||
|
|
|
@ -63,7 +63,10 @@ public:
|
|||
static void CloseOpenFiles();
|
||||
|
||||
// Get the file with the given name, opening it if it doesn't yet exist.
|
||||
static BroFile* GetFile(const char* name);
|
||||
static IntrusivePtr<BroFile> Get(const char* name);
|
||||
[[deprecated("Remove in v4.1. Use BroFile::Get().")]]
|
||||
static BroFile* GetFile(const char* name)
|
||||
{ return Get(name).release(); }
|
||||
|
||||
void EnableRawOutput() { raw_output = true; }
|
||||
bool IsRawOutput() const { return raw_output; }
|
||||
|
|
|
@ -124,10 +124,10 @@ struct val_converter {
|
|||
return new StringVal(a.size(), a.data());
|
||||
case TYPE_FILE:
|
||||
{
|
||||
auto file = BroFile::GetFile(a.data());
|
||||
auto file = BroFile::Get(a.data());
|
||||
|
||||
if ( file )
|
||||
return new Val({AdoptRef{}, file});
|
||||
return new Val(std::move(file));
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue