From 335133fa8f6a6a6fcf62468fd91bcd4017937f79 Mon Sep 17 00:00:00 2001 From: Ludvig Strigeus Date: Mon, 22 Oct 2018 00:29:08 +0200 Subject: [PATCH] Don't show empty directories in the server list. --- installer/ChangeLog.txt | 1 + tunsafe_win32.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/installer/ChangeLog.txt b/installer/ChangeLog.txt index 927fe1e..ad57133 100644 --- a/installer/ChangeLog.txt +++ b/installer/ChangeLog.txt @@ -25,6 +25,7 @@ Changes: 11.Show an error message and drop packets if the TUN queue grows too large. This is a problem with the TAP NDIS6 driver on Win7. 12.Bundle the TunSafe-TAP installer instead of downloading it. +13.Don't show empty directories in the server list. 2018-10-08 - TunSafe v1.4 diff --git a/tunsafe_win32.cpp b/tunsafe_win32.cpp index 05055dc..1199e46 100644 --- a/tunsafe_win32.cpp +++ b/tunsafe_win32.cpp @@ -440,12 +440,18 @@ void ConfigMenuBuilder::Recurse() { break; if (wfd_.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { buf_[bufpos_ - 1] = '\\'; + int old_nfiles = nfiles_; depth_++; if (depth_ < 16) Recurse(); depth_--; + // Remove directory if it had no files + if (old_nfiles == nfiles_) + nfiles_--; + if (nfiles_ == MAX_CONFIG_FILES) break; + } bufpos_ = old_bufpos; } while (FindNextFile(handle, &wfd_));