[util.cpp#L216](https://github.com/bitcoin/bitcoin/blob/master/src/util.cpp#L216) 
if `fopen `failed, a null file pointer could be passed to `FileWriteStr(vMsgsBeforeOpenLog->front(), fileout);`
{
    namespace fs = boost::filesystem;
    LOCK(csPathCached);
    fs::path &path = fNetSpecific ? pathCachedNetSpecific : pathCached;
    
    
    if (!path.empty())
        return path;
    if (IsArgSet("-datadir")) {
        path = fs::system_complete(GetArg("-datadir", ""));
        if (!fs::is_directory(path)) {
            path = "";
            return path;
        }
    } else {
        path = GetDefaultDataDir();
    }
    if (fNetSpecific)
        path /= BaseParams().DataDir();
    fs::create_directories(path);
    return path;
}
void ClearDatadirCache()