forked from HowardHinnant/date
Create downloads folder when it does not exist yet.
This commit is contained in:
committed by
Howard Hinnant
parent
dbee0e7da4
commit
5e86f2c5ba
63
tz.cpp
63
tz.cpp
@@ -210,6 +210,14 @@ expand_path(std::string path)
|
|||||||
|
|
||||||
# endif // !INSTALL
|
# endif // !INSTALL
|
||||||
|
|
||||||
|
static
|
||||||
|
std::string
|
||||||
|
get_download_folder()
|
||||||
|
{
|
||||||
|
return expand_path("~/Downloads");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // !_WIN32
|
#endif // !_WIN32
|
||||||
|
|
||||||
namespace date
|
namespace date
|
||||||
@@ -227,11 +235,7 @@ access_install()
|
|||||||
static std::string install
|
static std::string install
|
||||||
#ifndef INSTALL
|
#ifndef INSTALL
|
||||||
|
|
||||||
# ifdef _WIN32
|
|
||||||
= get_download_folder() + folder_delimiter + "tzdata";
|
= get_download_folder() + folder_delimiter + "tzdata";
|
||||||
# else
|
|
||||||
= expand_path("~/Downloads/tzdata");
|
|
||||||
# endif
|
|
||||||
|
|
||||||
#else // INSTALL
|
#else // INSTALL
|
||||||
|
|
||||||
@@ -2333,25 +2337,6 @@ remote_version()
|
|||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
remote_download(const std::string& version)
|
|
||||||
{
|
|
||||||
assert(!version.empty());
|
|
||||||
auto url = "http://www.iana.org/time-zones/repository/releases/tzdata" + version +
|
|
||||||
".tar.gz";
|
|
||||||
bool result = download_to_file(url, get_download_gz_file(version),
|
|
||||||
download_file_options::binary);
|
|
||||||
#ifdef TIMEZONE_MAPPING
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
auto mapping_file = get_download_mapping_file(version);
|
|
||||||
result = download_to_file("http://unicode.org/repos/cldr/trunk/common/"
|
|
||||||
"supplemental/windowsZones.xml",
|
|
||||||
mapping_file, download_file_options::text);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO! Using system() create a process and a console window.
|
// TODO! Using system() create a process and a console window.
|
||||||
// This is useful to see what errors may occur but is slow and distracting.
|
// This is useful to see what errors may occur but is slow and distracting.
|
||||||
@@ -2727,6 +2712,38 @@ extract_gz_file(const std::string&, const std::string& gz_file, const std::strin
|
|||||||
|
|
||||||
#endif // !_WIN32
|
#endif // !_WIN32
|
||||||
|
|
||||||
|
bool
|
||||||
|
remote_download(const std::string& version)
|
||||||
|
{
|
||||||
|
assert(!version.empty());
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Download folder should be always available for Windows
|
||||||
|
#else
|
||||||
|
// Create download folder if it does not exist on UNIX system
|
||||||
|
auto download_folder = get_download_folder();
|
||||||
|
if (!file_exists(download_folder))
|
||||||
|
{
|
||||||
|
make_directory(download_folder);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
auto url = "http://www.iana.org/time-zones/repository/releases/tzdata" + version +
|
||||||
|
".tar.gz";
|
||||||
|
bool result = download_to_file(url, get_download_gz_file(version),
|
||||||
|
download_file_options::binary);
|
||||||
|
#ifdef TIMEZONE_MAPPING
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
auto mapping_file = get_download_mapping_file(version);
|
||||||
|
result = download_to_file("http://unicode.org/repos/cldr/trunk/common/"
|
||||||
|
"supplemental/windowsZones.xml",
|
||||||
|
mapping_file, download_file_options::text);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
remote_install(const std::string& version)
|
remote_install(const std::string& version)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user