From dea3ca01db3248f5629326834f49003c98fdf837 Mon Sep 17 00:00:00 2001 From: Julian Noble Date: Wed, 15 Nov 2023 04:35:10 +1100 Subject: [PATCH] fix windows file glob matching for d/,./ etc --- src/modules/punk-0.1.tm | 1 + src/modules/punk/du-999999.0a1.0.tm | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/modules/punk-0.1.tm b/src/modules/punk-0.1.tm index f3d7b1d..22ee0d5 100644 --- a/src/modules/punk-0.1.tm +++ b/src/modules/punk-0.1.tm @@ -5857,6 +5857,7 @@ namespace eval punk { set chunklist [list] } #only merge results if location matches previous (caller can deliberately intersperse bogus globs to force split if desired) + #TODO - remove duplicate file or dir items for overlapping patterns in same location!!! (at least for count, filebyte totals if not for display) set last_location "" set this_result [dict create] foreach searchspec $args { diff --git a/src/modules/punk/du-999999.0a1.0.tm b/src/modules/punk/du-999999.0a1.0.tm index fb57a05..152305e 100644 --- a/src/modules/punk/du-999999.0a1.0.tm +++ b/src/modules/punk/du-999999.0a1.0.tm @@ -552,6 +552,11 @@ namespace eval punk::du { set errors [dict create] set altname "" ;#possible we have to use a different name e.g short windows name or dos-device path //?/ # return it so it can be stored and tried as an alternative for problem paths + #puts stderr ">>> glob: $opt_glob" + #REVIEW! windows api pattern matchttps://www.red-gate.com/simple-talk/blogs/the-unexpected-behaviour-of-directoryinfo-getfiles-with-three-letter-extensions/hing is .. weird. partly due to 8.3 filenames + #https://www.red-gate.com/simple-talk/blogs/the-unexpected-behaviour-of-directoryinfo-getfiles-with-three-letter-extensions/ + #we will certainly need to check the resulting listing with our supplied glob.. but maybe we will have to change the glob passed to find_file_open too. + # using * all the time may be inefficient - so we might be able to avoid that in some cases. try { #glob of * will return dotfiles too on windows set iterator [twapi::find_file_open [file join $folderpath $opt_glob] -detail basic] ;# -detail full only adds data to the altname field @@ -682,6 +687,11 @@ namespace eval punk::du { while {[twapi::find_file_next $iterator iteminfo]} { set nm [dict get $iteminfo name] + #recheck glob + #review! + if {![string match $opt_glob $nm]} { + continue + } set tail_altname [dict get $iteminfo altname] ;#altname of tail - not whole path set attrinfo [decode_win_attributes [dict get $iteminfo attrs]] #puts stderr "$iteminfo" @@ -689,6 +699,7 @@ namespace eval punk::du { set ftype "" #attributes applicable to any classification set fullname [file_join_one $folderpath $nm] + if {"hidden" in $attrinfo} { lappend flaggedhidden $fullname }