summaryrefslogtreecommitdiff
path: root/src/common/fs/fs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/fs/fs.cpp')
-rw-r--r--src/common/fs/fs.cpp41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/common/fs/fs.cpp b/src/common/fs/fs.cpp
index e1716c62d..36e67c145 100644
--- a/src/common/fs/fs.cpp
+++ b/src/common/fs/fs.cpp
@@ -3,6 +3,9 @@
3 3
4#include "common/fs/file.h" 4#include "common/fs/file.h"
5#include "common/fs/fs.h" 5#include "common/fs/fs.h"
6#ifdef ANDROID
7#include "common/fs/fs_android.h"
8#endif
6#include "common/fs/path_util.h" 9#include "common/fs/path_util.h"
7#include "common/logging/log.h" 10#include "common/logging/log.h"
8 11
@@ -433,7 +436,7 @@ void IterateDirEntries(const std::filesystem::path& path, const DirEntryCallable
433 436
434 if (True(filter & DirEntryFilter::File) && 437 if (True(filter & DirEntryFilter::File) &&
435 entry.status().type() == fs::file_type::regular) { 438 entry.status().type() == fs::file_type::regular) {
436 if (!callback(entry.path())) { 439 if (!callback(entry)) {
437 callback_error = true; 440 callback_error = true;
438 break; 441 break;
439 } 442 }
@@ -441,7 +444,7 @@ void IterateDirEntries(const std::filesystem::path& path, const DirEntryCallable
441 444
442 if (True(filter & DirEntryFilter::Directory) && 445 if (True(filter & DirEntryFilter::Directory) &&
443 entry.status().type() == fs::file_type::directory) { 446 entry.status().type() == fs::file_type::directory) {
444 if (!callback(entry.path())) { 447 if (!callback(entry)) {
445 callback_error = true; 448 callback_error = true;
446 break; 449 break;
447 } 450 }
@@ -490,7 +493,7 @@ void IterateDirEntriesRecursively(const std::filesystem::path& path,
490 493
491 if (True(filter & DirEntryFilter::File) && 494 if (True(filter & DirEntryFilter::File) &&
492 entry.status().type() == fs::file_type::regular) { 495 entry.status().type() == fs::file_type::regular) {
493 if (!callback(entry.path())) { 496 if (!callback(entry)) {
494 callback_error = true; 497 callback_error = true;
495 break; 498 break;
496 } 499 }
@@ -498,7 +501,7 @@ void IterateDirEntriesRecursively(const std::filesystem::path& path,
498 501
499 if (True(filter & DirEntryFilter::Directory) && 502 if (True(filter & DirEntryFilter::Directory) &&
500 entry.status().type() == fs::file_type::directory) { 503 entry.status().type() == fs::file_type::directory) {
501 if (!callback(entry.path())) { 504 if (!callback(entry)) {
502 callback_error = true; 505 callback_error = true;
503 break; 506 break;
504 } 507 }
@@ -525,15 +528,39 @@ void IterateDirEntriesRecursively(const std::filesystem::path& path,
525// Generic Filesystem Operations 528// Generic Filesystem Operations
526 529
527bool Exists(const fs::path& path) { 530bool Exists(const fs::path& path) {
531#ifdef ANDROID
532 if (Android::IsContentUri(path)) {
533 return Android::Exists(path);
534 } else {
535 return fs::exists(path);
536 }
537#else
528 return fs::exists(path); 538 return fs::exists(path);
539#endif
529} 540}
530 541
531bool IsFile(const fs::path& path) { 542bool IsFile(const fs::path& path) {
543#ifdef ANDROID
544 if (Android::IsContentUri(path)) {
545 return !Android::IsDirectory(path);
546 } else {
547 return fs::is_regular_file(path);
548 }
549#else
532 return fs::is_regular_file(path); 550 return fs::is_regular_file(path);
551#endif
533} 552}
534 553
535bool IsDir(const fs::path& path) { 554bool IsDir(const fs::path& path) {
555#ifdef ANDROID
556 if (Android::IsContentUri(path)) {
557 return Android::IsDirectory(path);
558 } else {
559 return fs::is_directory(path);
560 }
561#else
536 return fs::is_directory(path); 562 return fs::is_directory(path);
563#endif
537} 564}
538 565
539fs::path GetCurrentDir() { 566fs::path GetCurrentDir() {
@@ -578,6 +605,12 @@ fs::file_type GetEntryType(const fs::path& path) {
578} 605}
579 606
580u64 GetSize(const fs::path& path) { 607u64 GetSize(const fs::path& path) {
608#ifdef ANDROID
609 if (Android::IsContentUri(path)) {
610 return Android::GetSize(path);
611 }
612#endif
613
581 std::error_code ec; 614 std::error_code ec;
582 615
583 const auto file_size = fs::file_size(path, ec); 616 const auto file_size = fs::file_size(path, ec);