Fix dir-only addFilesRecursive

This commit is contained in:
zv0n 2022-02-27 13:52:05 +01:00
parent d56765ac1b
commit 2bbaac3157

View File

@ -60,15 +60,14 @@ void closeLibraries( std::vector< RenameLibrary > &libraries ) {
void addFilesRecursive(const FileObject &parent, std::vector< FileObject > &results, const std::string &filename, const std::string &containing_directory, bool dir_only = false ) { void addFilesRecursive(const FileObject &parent, std::vector< FileObject > &results, const std::string &filename, const std::string &containing_directory, bool dir_only = false ) {
auto path = containing_directory + FSLib::dir_divisor + filename; auto path = containing_directory + FSLib::dir_divisor + filename;
FileObject fo{};
if(!dir_only || FSLib::isDirectory(path)) { if(!dir_only || FSLib::isDirectory(path)) {
FileObject fo{};
if(!parent.getPath().empty()) { if(!parent.getPath().empty()) {
fo.setPath(parent.getPath() + FSLib::dir_divisor + filename); fo.setPath(parent.getPath() + FSLib::dir_divisor + filename);
} else { } else {
fo.setPath(filename); fo.setPath(filename);
} }
fo.setDepth(parent.getDepth() + 1); fo.setDepth(parent.getDepth() + 1);
}
if( FSLib::isDirectory(path) ) { if( FSLib::isDirectory(path) ) {
fo.setFileType(TYPE_DIRECTORY); fo.setFileType(TYPE_DIRECTORY);
for(const auto &entry : FSLib::Directory(path)) { for(const auto &entry : FSLib::Directory(path)) {
@ -77,6 +76,7 @@ void addFilesRecursive(const FileObject &parent, std::vector< FileObject > &resu
} }
results.push_back(std::move(fo)); results.push_back(std::move(fo));
} }
}
std::vector< FileObject > getFilesInSource( const std::string &source_dir ) { std::vector< FileObject > getFilesInSource( const std::string &source_dir ) {
std::vector< FileObject > result; std::vector< FileObject > result;