Beispiel #1
0
// Returns true if pathname describes a directory in the file-system
// that exists.
bool FilePath::DirectoryExists() const {
  bool result = false;
#if GTEST_OS_WINDOWS
  // Don't strip off trailing separator if path is a root directory on
  // Windows (like "C:\\").
  const FilePath& path(IsRootDirectory() ? *this :
                                           RemoveTrailingPathSeparator());
#else
  const FilePath& path(*this);
#endif

#if GTEST_OS_WINDOWS_MOBILE
  LPCWSTR unicode = String::AnsiToUtf16(path.c_str());
  const DWORD attributes = GetFileAttributes(unicode);
  delete [] unicode;
  if ((attributes != kInvalidFileAttributes) &&
      (attributes & FILE_ATTRIBUTE_DIRECTORY)) {
    result = true;
  }
#else
  posix::StatStruct file_stat;
  result = posix::Stat(path.c_str(), &file_stat) == 0 &&
      posix::IsDir(file_stat);
#endif  // GTEST_OS_WINDOWS_MOBILE

  return result;
}
Beispiel #2
0
  ModuleSettingsPrivate()
    : autoLoadPaths()
  #ifdef US_ENABLE_AUTOLOADING_SUPPORT
    , autoLoadingEnabled(true)
  #else
    , autoLoadingEnabled(false)
  #endif
    , autoLoadingDisabled(false)
    , logLevel(DebugMsg)
  {
    autoLoadPaths.insert(ModuleSettings::CURRENT_MODULE_PATH());

    char* envPaths = getenv("US_AUTOLOAD_PATHS");
    if (envPaths != nullptr)
    {
      std::stringstream ss(envPaths);
      std::string envPath;
#ifdef US_PLATFORM_WINDOWS
      const char separator = ';';
#else
      const char separator = ':';
#endif
      while (std::getline(ss, envPath, separator))
      {
        std::string normalizedEnvPath = RemoveTrailingPathSeparator(envPath);
        if (!normalizedEnvPath.empty())
        {
          extraPaths.insert(normalizedEnvPath);
        }
      }
    }

    if (getenv("US_DISABLE_AUTOLOADING"))
    {
      autoLoadingDisabled = true;
    }
  }
Beispiel #3
0
void ModuleSettings::SetStoragePath(const std::string &path)
{
  US_UNUSED(ModuleSettingsPrivate::Lock(moduleSettingsPrivate()));
  moduleSettingsPrivate()->storagePath = RemoveTrailingPathSeparator(path);
}
Beispiel #4
0
void ModuleSettings::AddAutoLoadPath(const std::string& path)
{
  US_UNUSED(ModuleSettingsPrivate::Lock(moduleSettingsPrivate()));
  moduleSettingsPrivate()->autoLoadPaths.insert(RemoveTrailingPathSeparator(path));
}