Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Versions match `FIP_VERSION` in `src/version.h`.

## [Unreleased]

## [1.8.2] - 2026-10-18

### Fixed

- Directory paths with special characters (e.g. folders named "[unnamed]") are now scanned and removable: FindFirstFile patterns misread such names as wildcards, so folders silently vanished from Find/Remove Dead-Empty Directories.

## [1.8.1] - 2026-10-18

### Fixed
Expand Down
38 changes: 22 additions & 16 deletions src/main_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,23 +370,29 @@ class main_find_playing : public mainmenu_commands {
t_size removed = 0;
t_size failed = 0;
for (const auto & dir : dirs) {
// Delete all files in the directory first.
WIN32_FIND_DATAA fd;
HANDLE hFind = FindFirstFileA((dir + std::string("\\*")).c_str(), &fd);
if (hFind != INVALID_HANDLE_VALUE) {
do {
const char *name = fd.cFileName;
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
continue;
std::string fullPath = dir + std::string("\\") + name;
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
RemoveDirectoryA(fullPath.c_str());
} else {
DeleteFileA(fullPath.c_str());
}
} while (FindNextFileA(hFind, &fd));
FindClose(hFind);
// Delete all files in the directory first. std::filesystem is
// used because FindFirstFileA parses [abc] in the path as a
// wildcard pattern, so folder names like "[unnamed]" fail.
namespace fs = std::filesystem;
std::error_code ec;
for (fs::directory_iterator it(fs::path(dir), fs::directory_options::skip_permission_denied, ec), end;
it != end && !ec; it.increment(ec)) {
std::string name;
try {
name = it->path().filename().string();
} catch (const std::system_error &) {
continue; // undecodable name: skip the entry
}
const std::string fullPath = dir + std::string("\\") + name;
if (it->is_directory(ec)) {
if (ec)
break;
RemoveDirectoryA(fullPath.c_str());
} else if (!ec) {
DeleteFileA(fullPath.c_str());
}
}
ec.clear();
if (RemoveDirectoryA(dir.c_str()))
++removed;
else
Expand Down
35 changes: 21 additions & 14 deletions src/scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,25 +181,32 @@ bool tag_has_invalid_chars(metadb_handle_ptr h) {
return false;
}

// Enumerate one directory's direct files and subfolders.
// Enumerate one directory's direct files and subfolders. std::filesystem is
// used because FindFirstFileA parses [abc] in the path as a wildcard pattern,
// so folder names like "[unnamed]" silently fail to enumerate.
static bool list_dir_entries(const std::string & dir, std::vector<std::string> & filenames,
std::vector<std::string> & subdirs) {
WIN32_FIND_DATAA fd;
HANDLE hFind = FindFirstFileA((dir + "\\*").c_str(), &fd);
if (hFind == INVALID_HANDLE_VALUE)
return false;
do {
const char *name = fd.cFileName;
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
continue;
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
namespace fs = std::filesystem;
std::error_code ec;
for (fs::directory_iterator it(fs::path(dir), fs::directory_options::skip_permission_denied, ec), end; it != end;
it.increment(ec)) {
if (ec)
break;
std::string name;
try {
name = it->path().filename().string();
} catch (const std::system_error &) {
continue; // undecodable name: skip the entry
}
if (it->is_directory(ec)) {
if (ec)
break;
subdirs.push_back(dir + "\\" + name);
} else {
} else if (!ec) {
filenames.push_back(name);
}
} while (FindNextFileA(hFind, &fd));
FindClose(hFind);
return true;
}
return !ec;
}

std::vector<std::string> scan_dead_directories() {
Expand Down
1 change: 1 addition & 0 deletions src/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <windows.h>

#include <filesystem>
#include <string>
#include <unordered_set>
#include <unordered_map>
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

// Single source of truth for the component version.
// Automatically updated by GitHub Actions semantic release.
#define FIP_VERSION "1.8.1"
#define FIP_VERSION "1.8.2"
Loading