Files
comaps/platform/platform_tests_support/scoped_file.hpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

61 lines
1.4 KiB
C++

#pragma once
#include "platform/country_defines.hpp"
#include "platform/platform.hpp"
#include "base/macros.hpp"
#include <string>
namespace platform
{
class CountryFile;
namespace tests_support
{
class ScopedDir;
class ScopedFile
{
public:
enum class Mode : uint32_t
{
// Create or overwrite the file and remove it at scope exit.
Create,
// Remove the file at scope exit. The caller must
// ensure that the file has been created by that time.
DoNotCreate
};
// Creates a scoped file in the specified mode.
ScopedFile(std::string const & relativePath, Mode mode);
// Creates a scoped file in Mode::Create and writes |contents| to it.
ScopedFile(std::string const & relativePath, std::string const & contents);
// Creates a scoped file in Mode::Create using the path inferred from |countryFile|
// and |mapOptions|.
ScopedFile(ScopedDir const & dir, CountryFile const & countryFile, MapFileType type);
~ScopedFile();
std::string const & GetFullPath() const { return m_fullPath; }
void Reset() { m_reset = true; }
bool Exists() const { return GetPlatform().IsFileExistsByFullPath(GetFullPath()); }
private:
ScopedFile(std::string const & relativePath, std::string const & contents, Mode mode);
std::string const m_fullPath;
bool m_reset = false;
DISALLOW_COPY_AND_MOVE(ScopedFile);
};
std::string DebugPrint(ScopedFile const & file);
} // namespace tests_support
} // namespace platform