Fix build on FreeBSD.

basename(3)/dirname(3) const-ness may vary w/ platform.
This commit is contained in:
Jon Siwek 2013-12-05 11:01:44 -06:00
parent 574018f478
commit 21df25d429
2 changed files with 60 additions and 32 deletions

View file

@ -224,34 +224,38 @@ extern std::string bro_prefixes();
class SafePathOp {
public:
typedef char*(*PathOpFn)(char*);
SafePathOp(PathOpFn fn, const char* path, bool error_aborts = true);
SafePathOp(PathOpFn fn, const std::string& path, bool error_aborts = true);
std::string result;
bool error;
private:
protected:
SafePathOp()
{ }
void CheckValid(const char* result, const char* path, bool error_aborts);
void DoFunc(PathOpFn fn, const std::string& path, bool error_aborts = true);
};
class SafeDirname : public SafePathOp {
public:
SafeDirname(const char* path, bool error_aborts = true)
: SafePathOp(&dirname, path, error_aborts) { }
SafeDirname(const std::string& path, bool error_aborts = true)
: SafePathOp(&dirname, path, error_aborts) { }
SafeDirname(const char* path, bool error_aborts = true);
SafeDirname(const std::string& path, bool error_aborts = true);
private:
void DoFunc(const std::string& path, bool error_aborts = true);
};
class SafeBasename : public SafePathOp {
public:
SafeBasename(const char* path, bool error_aborts = true)
: SafePathOp(&basename, path, error_aborts) { }
SafeBasename(const std::string& path, bool error_aborts = true)
: SafePathOp(&basename, path, error_aborts) { }
SafeBasename(const char* path, bool error_aborts = true);
SafeBasename(const std::string& path, bool error_aborts = true);
private:
void DoFunc(const std::string& path, bool error_aborts = true);
};
std::string implode_string_vector(const std::vector<std::string>& v,