summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-09-29 11:49:03 +0200
committerGitHub <noreply@github.com>2020-09-29 11:49:03 +0200
commitaed16c8f84b67626b9a989ef24284fb92d569814 (patch)
treee5d117b5606cc73f851695adf258f7ec3ba8da49
parent22b3e9f76a22fa32e9c4078080f6bbd792c216c9 (diff)
parent1998f7867940c60ac4ed8c009add64cf0a5a45a7 (diff)
Merge pull request #42381 from timothyqiu/osx-hidden
Hide special folders in FileDialog for macOS
-rw-r--r--drivers/unix/dir_access_unix.cpp6
-rw-r--r--drivers/unix/dir_access_unix.h1
-rw-r--r--platform/osx/dir_access_osx.h2
-rw-r--r--platform/osx/dir_access_osx.mm10
4 files changed, 18 insertions, 1 deletions
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp
index 325a88b573..5b99a2f53f 100644
--- a/drivers/unix/dir_access_unix.cpp
+++ b/drivers/unix/dir_access_unix.cpp
@@ -152,7 +152,7 @@ String DirAccessUnix::get_next() {
_cisdir = (entry->d_type == DT_DIR);
}
- _cishidden = (fname != "." && fname != ".." && fname.begins_with("."));
+ _cishidden = is_hidden(fname);
return fname;
}
@@ -400,6 +400,10 @@ String DirAccessUnix::get_filesystem_type() const {
return ""; //TODO this should be implemented
}
+bool DirAccessUnix::is_hidden(const String &p_name) {
+ return p_name != "." && p_name != ".." && p_name.begins_with(".");
+}
+
DirAccessUnix::DirAccessUnix() {
dir_stream = nullptr;
_cisdir = false;
diff --git a/drivers/unix/dir_access_unix.h b/drivers/unix/dir_access_unix.h
index b897efcafc..90f98d4705 100644
--- a/drivers/unix/dir_access_unix.h
+++ b/drivers/unix/dir_access_unix.h
@@ -51,6 +51,7 @@ class DirAccessUnix : public DirAccess {
protected:
virtual String fix_unicode_name(const char *p_name) const { return String::utf8(p_name); }
+ virtual bool is_hidden(const String &p_name);
public:
virtual Error list_dir_begin(); ///< This starts dir listing
diff --git a/platform/osx/dir_access_osx.h b/platform/osx/dir_access_osx.h
index d61ee181f0..91b8f9b2c5 100644
--- a/platform/osx/dir_access_osx.h
+++ b/platform/osx/dir_access_osx.h
@@ -47,6 +47,8 @@ protected:
virtual int get_drive_count();
virtual String get_drive(int p_drive);
+
+ virtual bool is_hidden(const String &p_name);
};
#endif //UNIX ENABLED
diff --git a/platform/osx/dir_access_osx.mm b/platform/osx/dir_access_osx.mm
index 7791ba5407..439c6a075f 100644
--- a/platform/osx/dir_access_osx.mm
+++ b/platform/osx/dir_access_osx.mm
@@ -68,4 +68,14 @@ String DirAccessOSX::get_drive(int p_drive) {
return volname;
}
+bool DirAccessOSX::is_hidden(const String &p_name) {
+ String f = get_current_dir().plus_file(p_name);
+ NSURL *url = [NSURL fileURLWithPath:@(f.utf8().get_data())];
+ NSNumber *hidden = nil;
+ if (![url getResourceValue:&hidden forKey:NSURLIsHiddenKey error:nil]) {
+ return DirAccessUnix::is_hidden(p_name);
+ }
+ return [hidden boolValue];
+}
+
#endif //posix_enabled