|
|
|
@ -24,6 +24,7 @@ package require punk::args |
|
|
|
|
|
|
|
|
|
|
|
namespace eval punk::du { |
|
|
|
namespace eval punk::du { |
|
|
|
variable has_twapi 0 |
|
|
|
variable has_twapi 0 |
|
|
|
|
|
|
|
variable has_winpath 0 |
|
|
|
} |
|
|
|
} |
|
|
|
if {"windows" eq $::tcl_platform(platform)} { |
|
|
|
if {"windows" eq $::tcl_platform(platform)} { |
|
|
|
if {![interp issafe]} { |
|
|
|
if {![interp issafe]} { |
|
|
|
@ -36,7 +37,10 @@ if {"windows" eq $::tcl_platform(platform)} { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
set punk::du::has_twapi 1 |
|
|
|
set punk::du::has_twapi 1 |
|
|
|
} |
|
|
|
} |
|
|
|
#package require punk::winpath |
|
|
|
|
|
|
|
|
|
|
|
if {![catch {package require punk::winpath}]} { |
|
|
|
|
|
|
|
set punk::du::has_winpath 1 |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1450,6 +1454,7 @@ namespace eval punk::du { |
|
|
|
|
|
|
|
|
|
|
|
#return fsizes,allsizes,alltimes metadata in same order as files,dirs,links lists - if specified in sized_types |
|
|
|
#return fsizes,allsizes,alltimes metadata in same order as files,dirs,links lists - if specified in sized_types |
|
|
|
proc du_get_metadata_lists {sized_types timed_types files dirs links} { |
|
|
|
proc du_get_metadata_lists {sized_types timed_types files dirs links} { |
|
|
|
|
|
|
|
upvar ::punk::du::has_winpath has_winpath |
|
|
|
set meta_dict [dict create] |
|
|
|
set meta_dict [dict create] |
|
|
|
set meta_types [list {*}$sized_types {*}$timed_types] |
|
|
|
set meta_types [list {*}$sized_types {*}$timed_types] |
|
|
|
#known tcl stat keys 2023 - review |
|
|
|
#known tcl stat keys 2023 - review |
|
|
|
@ -1460,13 +1465,24 @@ namespace eval punk::du { |
|
|
|
foreach ft {f d l} lvar {files dirs links} { |
|
|
|
foreach ft {f d l} lvar {files dirs links} { |
|
|
|
if {"$ft" in $meta_types} { |
|
|
|
if {"$ft" in $meta_types} { |
|
|
|
foreach path [set $lvar] { |
|
|
|
foreach path [set $lvar] { |
|
|
|
#caller may have read perm on the containing folder - but not on child item - so file stat could raise an error |
|
|
|
if {$has_winpath && [punk::winpath::illegalname_test $path]} { |
|
|
|
if {![catch {file stat $path arrstat} errM]} { |
|
|
|
set testpath [punk::winpath::illegalname_fix $path] |
|
|
|
dict set meta_dict $path [dict create shorttype $ft {*}[array get arrstat]] |
|
|
|
if {![catch {file stat $testpath arrstat} errM]} { |
|
|
|
|
|
|
|
dict set meta_dict $path [dict create shorttype $ft {*}[array get arrstat]] |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
puts stderr "du_get_metadata_lists: file stat $testpath error: $errM" |
|
|
|
|
|
|
|
dict lappend errors $path "file stat error: $errM" |
|
|
|
|
|
|
|
dict set meta_dict $path [dict create shorttype $ft {*}$empty_stat_dict] |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
puts stderr "du_get_metadata_lists: file stat $path error: $errM" |
|
|
|
#caller may have read perm on the containing folder - but not on child item - so file stat could raise an error |
|
|
|
dict lappend errors $path "file stat error: $errM" |
|
|
|
if {![catch {file stat $path arrstat} errM]} { |
|
|
|
dict set meta_dict $path [dict create shorttype $ft {*}$empty_stat_dict] |
|
|
|
dict set meta_dict $path [dict create shorttype $ft {*}[array get arrstat]] |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
puts stderr "du_get_metadata_lists: file stat $path error: $errM" |
|
|
|
|
|
|
|
dict lappend errors $path "file stat error: $errM" |
|
|
|
|
|
|
|
dict set meta_dict $path [dict create shorttype $ft {*}$empty_stat_dict] |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|