1
0
forked from mirrors/0ad

Update tinygettext to match upstream.

We're now ISO on the plural forms
(https://github.com/tinygettext/tinygettext/pull/30), so remove the
modified warning.
We use boost filesystem as <filesystem> and <experimental/filesystem>
are not available on the macOS CI yet.
(https://github.com/tinygettext/tinygettext/issues/31)

Differential Revision: https://code.wildfiregames.com/D3185
This was SVN commit r24342.
This commit is contained in:
Stan
2020-12-07 13:15:31 +00:00
parent 421fbfd278
commit a2f3b25923
13 changed files with 358 additions and 329 deletions
+9 -26
View File
@@ -1,3 +1,6 @@
/*
* Slightly modified version by Wildfire Games, for 0 A.D to support macOS 10.13
*/
// tinygettext - A gettext replacement that works directly on .po files
// Copyright (c) 2009 Ingo Ruhnke <grumbel@gmail.com>
//
@@ -21,16 +24,9 @@
#include "tinygettext/unix_file_system.hpp"
#include <sys/types.h>
#include <boost/filesystem.hpp>
#include <fstream>
#ifdef _MSC_VER
// MSVC doesn't include dirent.h, so we use this emulated win32 version
# include "win32/dirent.h"
#else
# include <dirent.h>
#endif
#include <stdlib.h>
#include <string.h>
namespace tinygettext {
@@ -41,31 +37,18 @@ UnixFileSystem::UnixFileSystem()
std::vector<std::string>
UnixFileSystem::open_directory(const std::string& pathname)
{
DIR* dir = opendir(pathname.c_str());
if (!dir)
std::vector<std::string> files;
for(auto const& p : boost::filesystem::directory_iterator(pathname))
{
// FIXME: error handling
return std::vector<std::string>();
}
else
{
std::vector<std::string> files;
struct dirent* dp;
while((dp = readdir(dir)) != 0)
{
files.push_back(dp->d_name);
}
closedir(dir);
return files;
files.push_back(p.path().filename().string());
}
return files;
}
std::unique_ptr<std::istream>
UnixFileSystem::open_file(const std::string& filename)
{
return std::unique_ptr<std::istream>(new std::ifstream(filename.c_str()));
return std::unique_ptr<std::istream>(new std::ifstream(filename));
}
} // namespace tinygettext