From bb5908b3167719cb19bb575919d70b3ae02b6e1e Mon Sep 17 00:00:00 2001 From: Vince Darley Date: Mon, 18 Feb 2002 13:01:37 +0000 Subject: [PATCH] changes for tip#72 --- ChangeLog | 5 +++++ generic/vfs.c | 9 ++++++--- library/ftpvfs.tcl | 41 ++++++++++++++++++++++++++++++----------- library/mk4vfs.tcl | 9 +++++++-- 4 files changed, 48 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 87e05c1..61b8181 100644 --- a/ChangeLog +++ b/ChangeLog @@ -51,6 +51,11 @@ * examples/simpleExamples.tcl: a demo * doc/vfslib.n: some documentation on the 'library' code. +2002-02-17 Vince Darley + * generic/vfs.c: updated for TIP#72 application to cvs head. + The 'file stat' implementation now deals with files of size + greater than a 32 bit representation. + 2001-10-29 Vince Darley * win/makefile.vc: installation is better. * library/vfsUrl.tcl: improved urltype mounting. The following diff --git a/generic/vfs.c b/generic/vfs.c index 070669d..b9ea6e5 100644 --- a/generic/vfs.c +++ b/generic/vfs.c @@ -6,6 +6,9 @@ * virtual file system support, and therefore allows * vfs's to be implemented in Tcl. * + * Some of this file could be used as a basis for a hard-coded + * vfs implemented in C (e.g. a zipvfs). + * * The code is thread-safe. Although under normal use only * one interpreter will be used to add/remove mounts and volumes, * it does cope with multiple interpreters in multiple threads. @@ -921,7 +924,7 @@ VfsFilesystemSeparator(Tcl_Obj* pathObjPtr) { static int VfsStat(pathPtr, bufPtr) Tcl_Obj *pathPtr; /* Path of file to stat (in current CP). */ - struct stat *bufPtr; /* Filled with results of stat call. */ + Tcl_StatBuf *bufPtr; /* Filled with results of stat call. */ { Tcl_Obj *mountCmd = NULL; Tcl_SavedResult savedResult; @@ -1001,8 +1004,8 @@ VfsStat(pathPtr, bufPtr) } bufPtr->st_gid = (short)v; } else if (!strcmp(fieldName,"size")) { - long v; - if (Tcl_GetLongFromObj(interp, val, &v) != TCL_OK) { + Tcl_WideInt v; + if (Tcl_GetWideIntFromObj(interp, val, &v) != TCL_OK) { returnVal = TCL_ERROR; break; } diff --git a/library/ftpvfs.tcl b/library/ftpvfs.tcl index 67faec7..6a20495 100644 --- a/library/ftpvfs.tcl +++ b/library/ftpvfs.tcl @@ -199,23 +199,42 @@ proc vfs::ftp::_parseListLine {line} { proc vfs::ftp::matchindirectory {fd path actualpath pattern type} { ::vfs::log "matchindirectory $path $pattern $type" - set ftpList [ftp::List $fd $path] - ::vfs::log "ftpList: $ftpList" set res [list] - - foreach p $ftpList { - foreach {name perms} [_parseListLine $p] {} - if {[::vfs::matchDirectories $type]} { + if {![string length $pattern]} { + # matching a single file + set ftpInfo [_findFtpInfo $fd $path] + if {$ftpInfo != ""} { + # Now check if types match + set perms [lindex $ftpInfo 0] if {[string index $perms 0] == "d"} { - lappend res "$actualpath$name" + if {[::vfs::matchDirectories $type]} { + lappend res $actualpath + } + } else { + if {[::vfs::matchFiles $type]} { + lappend res $actualpath + } } } - if {[::vfs::matchFiles $type]} { - if {[string index $perms 0] != "d"} { - lappend res "$actualpath$name" + } else { + # matching all files in the given directory + set ftpList [ftp::List $fd $path] + ::vfs::log "ftpList: $ftpList" + + foreach p $ftpList { + foreach {name perms} [_parseListLine $p] {} + if {[::vfs::matchDirectories $type]} { + if {[string index $perms 0] == "d"} { + lappend res "$actualpath$name" + } + } + if {[::vfs::matchFiles $type]} { + if {[string index $perms 0] != "d"} { + lappend res "$actualpath$name" + } } + } - } return $res diff --git a/library/mk4vfs.tcl b/library/mk4vfs.tcl index 70092f9..32a18e9 100644 --- a/library/mk4vfs.tcl +++ b/library/mk4vfs.tcl @@ -146,9 +146,14 @@ proc vfs::mk4::utime {db path actime modtime} { proc vfs::mk4::matchindirectory {db path actualpath pattern type} { #::vfs::log [list matchindirectory $path $actualpath $pattern $type] - set res [::mk4vfs::getdir $db $path $pattern] - #::vfs::log "got $res" set newres [list] + if {![string length $pattern]} { + # check single file + set res [list $path] + } else { + set res [::mk4vfs::getdir $db $path $pattern] + } + #::vfs::log "got $res" foreach p [::vfs::matchCorrectTypes $type $res $actualpath] { lappend newres "$actualpath$p" } -- 2.23.0