Browse Source

fix for dir listings of folders with windows illegal paths

master
Julian Noble 1 day ago
parent
commit
d8e110991b
  1. 18
      src/bootsupport/modules/punk/du-0.1.0.tm
  2. 2
      src/bootsupport/modules/punk/nav/fs-0.1.0.tm
  3. 2
      src/bootsupport/modules/punk/repo-0.1.1.tm
  4. 18
      src/modules/punk/du-999999.0a1.0.tm
  5. 2
      src/modules/punk/imap4-999999.0a1.0.tm
  6. 2
      src/modules/punk/repo-999999.0a1.0.tm
  7. 18
      src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/du-0.1.0.tm
  8. 2
      src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/nav/fs-0.1.0.tm
  9. 2
      src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/repo-0.1.1.tm
  10. 18
      src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/du-0.1.0.tm
  11. 2
      src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/nav/fs-0.1.0.tm
  12. 2
      src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/repo-0.1.1.tm

18
src/bootsupport/modules/punk/du-0.1.0.tm

@ -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,6 +1465,16 @@ 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] {
if {$has_winpath && [punk::winpath::illegalname_test $path]} {
set testpath [punk::winpath::illegalname_fix $path]
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 {
#caller may have read perm on the containing folder - but not on child item - so file stat could raise an error #caller may have read perm on the containing folder - but not on child item - so file stat could raise an error
if {![catch {file stat $path arrstat} errM]} { if {![catch {file stat $path arrstat} errM]} {
dict set meta_dict $path [dict create shorttype $ft {*}[array get arrstat]] dict set meta_dict $path [dict create shorttype $ft {*}[array get arrstat]]
@ -1472,6 +1487,7 @@ namespace eval punk::du {
} }
} }
} }
}
set fsizes [list] set fsizes [list]
set allsizes [dict create] set allsizes [dict create]
set alltimes [dict create] set alltimes [dict create]

2
src/bootsupport/modules/punk/nav/fs-0.1.0.tm

@ -792,7 +792,7 @@ tcl::namespace::eval punk::nav::fs {
if {$searchspec eq ""} { if {$searchspec eq ""} {
set location set location
} else { } else {
if {$is_relativesarchspec} { if {$is_relativesearchspec} {
#set location [file dirname [file join $opt_searchbase $searchspec]] #set location [file dirname [file join $opt_searchbase $searchspec]]
set location [punk::path::normjoin $searchbase $searchspec ..] set location [punk::path::normjoin $searchbase $searchspec ..]
} else { } else {

2
src/bootsupport/modules/punk/repo-0.1.1.tm

@ -1682,7 +1682,7 @@ namespace eval punk::repo {
#whether path is at and/or below one of the vfs mount points #whether path is at and/or below one of the vfs mount points
#The design should facilitate nested vfs mountpoints #The design should facilitate nested vfs mountpoints
proc path_vfs_info {filepath} { proc path_vfs_info {filepath} {
error "unimplmented" error "unimplemented"
} }
#file normalize is expensive so this is too #file normalize is expensive so this is too

18
src/modules/punk/du-999999.0a1.0.tm

@ -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,6 +1465,16 @@ 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] {
if {$has_winpath && [punk::winpath::illegalname_test $path]} {
set testpath [punk::winpath::illegalname_fix $path]
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 {
#caller may have read perm on the containing folder - but not on child item - so file stat could raise an error #caller may have read perm on the containing folder - but not on child item - so file stat could raise an error
if {![catch {file stat $path arrstat} errM]} { if {![catch {file stat $path arrstat} errM]} {
dict set meta_dict $path [dict create shorttype $ft {*}[array get arrstat]] dict set meta_dict $path [dict create shorttype $ft {*}[array get arrstat]]
@ -1472,6 +1487,7 @@ namespace eval punk::du {
} }
} }
} }
}
set fsizes [list] set fsizes [list]
set allsizes [dict create] set allsizes [dict create]
set alltimes [dict create] set alltimes [dict create]

2
src/modules/punk/imap4-999999.0a1.0.tm

@ -1639,7 +1639,7 @@ tcl::namespace::eval punk::imap4 {
chan configure $chan -translation binary chan configure $chan -translation binary
dict set coninfo $chan [dict create hostname $address port $port debug $opt_debug security $opt_security] dict set coninfo $chan [dict create hostname $address port $port debug $opt_debug security $opt_security]
# Intialize the connection state array # Initialize the connection state array
punk::imap4::proto::initinfo $chan punk::imap4::proto::initinfo $chan
# Get the banner # Get the banner
punk::imap4::proto::processline $chan * punk::imap4::proto::processline $chan *

2
src/modules/punk/repo-999999.0a1.0.tm

@ -1682,7 +1682,7 @@ namespace eval punk::repo {
#whether path is at and/or below one of the vfs mount points #whether path is at and/or below one of the vfs mount points
#The design should facilitate nested vfs mountpoints #The design should facilitate nested vfs mountpoints
proc path_vfs_info {filepath} { proc path_vfs_info {filepath} {
error "unimplmented" error "unimplemented"
} }
#file normalize is expensive so this is too #file normalize is expensive so this is too

18
src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/du-0.1.0.tm

@ -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,6 +1465,16 @@ 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] {
if {$has_winpath && [punk::winpath::illegalname_test $path]} {
set testpath [punk::winpath::illegalname_fix $path]
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 {
#caller may have read perm on the containing folder - but not on child item - so file stat could raise an error #caller may have read perm on the containing folder - but not on child item - so file stat could raise an error
if {![catch {file stat $path arrstat} errM]} { if {![catch {file stat $path arrstat} errM]} {
dict set meta_dict $path [dict create shorttype $ft {*}[array get arrstat]] dict set meta_dict $path [dict create shorttype $ft {*}[array get arrstat]]
@ -1472,6 +1487,7 @@ namespace eval punk::du {
} }
} }
} }
}
set fsizes [list] set fsizes [list]
set allsizes [dict create] set allsizes [dict create]
set alltimes [dict create] set alltimes [dict create]

2
src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/nav/fs-0.1.0.tm

@ -792,7 +792,7 @@ tcl::namespace::eval punk::nav::fs {
if {$searchspec eq ""} { if {$searchspec eq ""} {
set location set location
} else { } else {
if {$is_relativesarchspec} { if {$is_relativesearchspec} {
#set location [file dirname [file join $opt_searchbase $searchspec]] #set location [file dirname [file join $opt_searchbase $searchspec]]
set location [punk::path::normjoin $searchbase $searchspec ..] set location [punk::path::normjoin $searchbase $searchspec ..]
} else { } else {

2
src/project_layouts/custom/_project/punk.project-0.1/src/bootsupport/modules/punk/repo-0.1.1.tm

@ -1682,7 +1682,7 @@ namespace eval punk::repo {
#whether path is at and/or below one of the vfs mount points #whether path is at and/or below one of the vfs mount points
#The design should facilitate nested vfs mountpoints #The design should facilitate nested vfs mountpoints
proc path_vfs_info {filepath} { proc path_vfs_info {filepath} {
error "unimplmented" error "unimplemented"
} }
#file normalize is expensive so this is too #file normalize is expensive so this is too

18
src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/du-0.1.0.tm

@ -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,6 +1465,16 @@ 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] {
if {$has_winpath && [punk::winpath::illegalname_test $path]} {
set testpath [punk::winpath::illegalname_fix $path]
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 {
#caller may have read perm on the containing folder - but not on child item - so file stat could raise an error #caller may have read perm on the containing folder - but not on child item - so file stat could raise an error
if {![catch {file stat $path arrstat} errM]} { if {![catch {file stat $path arrstat} errM]} {
dict set meta_dict $path [dict create shorttype $ft {*}[array get arrstat]] dict set meta_dict $path [dict create shorttype $ft {*}[array get arrstat]]
@ -1472,6 +1487,7 @@ namespace eval punk::du {
} }
} }
} }
}
set fsizes [list] set fsizes [list]
set allsizes [dict create] set allsizes [dict create]
set alltimes [dict create] set alltimes [dict create]

2
src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/nav/fs-0.1.0.tm

@ -792,7 +792,7 @@ tcl::namespace::eval punk::nav::fs {
if {$searchspec eq ""} { if {$searchspec eq ""} {
set location set location
} else { } else {
if {$is_relativesarchspec} { if {$is_relativesearchspec} {
#set location [file dirname [file join $opt_searchbase $searchspec]] #set location [file dirname [file join $opt_searchbase $searchspec]]
set location [punk::path::normjoin $searchbase $searchspec ..] set location [punk::path::normjoin $searchbase $searchspec ..]
} else { } else {

2
src/project_layouts/custom/_project/punk.shell-0.1/src/bootsupport/modules/punk/repo-0.1.1.tm

@ -1682,7 +1682,7 @@ namespace eval punk::repo {
#whether path is at and/or below one of the vfs mount points #whether path is at and/or below one of the vfs mount points
#The design should facilitate nested vfs mountpoints #The design should facilitate nested vfs mountpoints
proc path_vfs_info {filepath} { proc path_vfs_info {filepath} {
error "unimplmented" error "unimplemented"
} }
#file normalize is expensive so this is too #file normalize is expensive so this is too

Loading…
Cancel
Save