Skip to content

Commit

Permalink
Options: offer resources from all config directories (#639, #30, ~#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
mintty committed May 8, 2017
1 parent 5f2ff29 commit 3a9b97e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
45 changes: 24 additions & 21 deletions src/config.c
Expand Up @@ -1085,7 +1085,7 @@ load_config(string filename, int to_save)
FILE * file = fopen(filename, "r");

if (to_save) {
if (file || (!rc_filename && (int)to_save == 2) || (int)to_save == 3) {
if (file || (!rc_filename && to_save == 2) || to_save == 3) {
clear_opts();

delete(rc_filename);
Expand Down Expand Up @@ -1486,30 +1486,33 @@ add_file_resources(control *ctrl, wstring pattern)
hFind = FindFirstFileW(rcpat, &ffd);
ok = hFind != INVALID_HANDLE_VALUE;
free(rcpat);
if (ok)
break;
if (GetLastError() == ERROR_FILE_NOT_FOUND) // empty valid dir
break;
}
if (ok) {
while (ok) {
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
// skip
}
else {
//LARGE_INTEGER filesize = {.LowPart = ffd.nFileSizeLow, .HighPart = ffd.nFileSizeHigh};
//long s = filesize.QuadPart;

// strip suffix
int len = wcslen(ffd.cFileName);
if (ffd.cFileName[0] != '.' && ffd.cFileName[len - 1] != '~') {
ffd.cFileName[len - sufl] = 0;
dlg_listbox_add_w(ctrl, ffd.cFileName);
}
}
ok = FindNextFileW(hFind, &ffd);
}
FindClose(hFind);

while (ok) {
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
// skip
//break;
}
else {
//LARGE_INTEGER filesize = {.LowPart = ffd.nFileSizeLow, .HighPart = ffd.nFileSizeHigh};
//long s = filesize.QuadPart;

// strip suffix
int len = wcslen(ffd.cFileName);
if (ffd.cFileName[0] != '.' && ffd.cFileName[len - 1] != '~') {
ffd.cFileName[len - sufl] = 0;
dlg_listbox_add_w(ctrl, ffd.cFileName);
}
if (GetLastError() == ERROR_FILE_NOT_FOUND) {
// empty valid dir
//break;
}
ok = FindNextFileW(hFind, &ffd);
}
FindClose(hFind);
}


Expand Down
1 change: 1 addition & 0 deletions wiki/Changelog.md
Expand Up @@ -17,6 +17,7 @@ Terminal handling
Configuration
* New option --configdir for config file and resource folders (mintty/winpty#30, mintty/winpty#40, mintty/winpty#38).
* Always save to config file specified with -c/--config or --configdir (mintty/winpty#30, ~mintty/winpty#40).
* Options: offer resources from subdirectories of all config directories (#639, #30, ~#38).

Other
* Fixed cleanup of environment variables after user command (#654).
Expand Down

0 comments on commit 3a9b97e

Please sign in to comment.