Android: Add content provider support to File::FileInfo

This commit is contained in:
JosJuice
2020-11-05 19:47:23 +01:00
parent 99ffee9a0a
commit a7c05d7e84
7 changed files with 73 additions and 2 deletions

View File

@ -78,19 +78,40 @@ FileInfo::FileInfo(const char* path) : FileInfo(std::string(path))
#else
FileInfo::FileInfo(const std::string& path) : FileInfo(path.c_str())
{
#ifdef ANDROID
if (IsPathAndroidContent(path))
AndroidContentInit(path);
else
#endif
m_exists = stat(path.c_str(), &m_stat) == 0;
}
FileInfo::FileInfo(const char* path)
{
m_exists = stat(path, &m_stat) == 0;
#ifdef ANDROID
if (IsPathAndroidContent(path))
AndroidContentInit(path);
else
#endif
m_exists = stat(path, &m_stat) == 0;
}
#endif
FileInfo::FileInfo(int fd)
{
m_exists = fstat(fd, &m_stat);
m_exists = fstat(fd, &m_stat) == 0;
}
#ifdef ANDROID
void FileInfo::AndroidContentInit(const std::string& path)
{
const jlong result = GetAndroidContentSizeAndIsDirectory(path);
m_exists = result != -1;
m_stat.st_mode = result == -2 ? S_IFDIR : S_IFREG;
m_stat.st_size = result >= 0 ? result : 0;
}
#endif
bool FileInfo::Exists() const
{
return m_exists;