Fixed fs::scanDirectory to be more reliable on *nix platforms with more uncommon filessytems (e.g. NFS on FreeBSD)

This commit is contained in:
casey langen 2020-06-16 22:53:30 +00:00
parent 35edbe79b3
commit a5dcf74588
2 changed files with 13 additions and 6 deletions

View File

@ -39,7 +39,7 @@ if [ $OS == "Darwin" ]; then
fi
if [ $OS == "FreeBSD" ]; then
echo "detected freebsd"
pkg install boost-all curl libvorbis libogg libmicrohttpd ffmpeg alsa-lib cmake sndio libev taglib bash libopenmpt
pkg install boost-all ncurses curl libvorbis libogg libmicrohttpd ffmpeg alsa-lib cmake sndio libev taglib bash libopenmpt
portsnap fetch
portsnap extract
cd /usr/ports/audio/lame

View File

@ -53,6 +53,7 @@
#define DLLEXPORT
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#endif
namespace musik { namespace core { namespace sdk { namespace fs {
@ -182,7 +183,15 @@ namespace musik { namespace core { namespace sdk { namespace fs {
if (interrupt && interrupt()) {
return;
}
else if (entry->d_type == DT_DIR) {
bool hasTrailingSlash = path[path.size() - 1] == '/';
std::string fn = path + (hasTrailingSlash ? "" : "/") + entry->d_name;
struct stat info = {0};
if (stat(fn.c_str(), &info) < 0) {
return;
}
if (S_ISDIR(info.st_mode)) {
std::string name = entry->d_name;
if (name == "." || name == "..") {
continue;
@ -190,9 +199,7 @@ namespace musik { namespace core { namespace sdk { namespace fs {
scanDirectory(path + "/" + name, callback, interrupt);
}
else {
std::string fn = entry->d_name;
bool hasTrailingSlash = path[path.size() - 1] == '/';
callback(path + (hasTrailingSlash ? "" : "/") + fn);
callback(fn);
}
}
@ -200,4 +207,4 @@ namespace musik { namespace core { namespace sdk { namespace fs {
#endif
}
} } } }
} } } }