Ticket UUID: | 823329 | |||
Title: | glob -types type/creator/hidden not implemented on OSX | |||
Type: | Bug | Version: | obsolete: 8.5a4 | |
Submitter: | vincentdarley | Created on: | 2003-10-14 10:09:58 | |
Subsystem: | 37. File System | Assigned To: | das | |
Priority: | 9 Immediate | Severity: | ||
Status: | Closed | Last Modified: | 2006-03-21 18:10:44 | |
Resolution: | Fixed | Closed By: | das | |
Closed on: | 2006-03-21 11:10:44 | |||
Description: |
Commands like: glob -type TEXT * are not implemented on OS X. Since it is a version of MacOS, it is capable of supporting these things. Vince. Various comments below: On Tuesday, Oct 14, 2003, at 19:40 Australia/Sydney, Vince Darley wrote: > Should this just be #ifdef'd into NativeMatchType so it compiles on the > relevant platform, or...? I don't really understand all the vagaries > of > different unix systems so am probably not the person to implement > this... the creator/type code is #ifdef MAC_OSX_TCL so the same would be appropriate, c.f tclMacOSXFCmd.c [glob -types hidden] should be properly supported as well, that's also handled by TclMacOSXGetFileAttribute() and controlled by same #ifdef also [glob -types readonly] should be handled on unices that support CHFLAGS, c.f GetReadOnlyAttribute() in tclUnixFCmd.c, this is controlled by #if defined(HAVE_CHFLAGS) && defined(UF_IMMUTABLE) > Also, by the time we're in NativeMatchType we actually only have a > native > path description (no Tcl_Obj) so we really want access to the innards > of > TclMacOSXGetFileAttribute. that's a bit of a pain, it kills code modularization for these functions... it wouldn't be hard to copy the guts out of TclMacOSXGetFileAttribute() and GetReadOnlyAttribute() into the unix NativeMatchType() but it doesn't seem to be very clean. maybe we need a native path aware versions of TclMacOSXGetFileAttribute/GetReadOnlyAttribute ? don't have much time to spend on this at the moment, maybe best to add a bug report on SF so that this doesn't get lost? we really should have thought about this when I did TIP 118... | |||
User Comments: |
das added on 2006-03-21 18:10:43:
Logged In: YES user_id=90580 patch committed to HEAD: * generic/tclInt.decls: implement globbing for HFS creator & type * macosx/tclMacOSXFCmd.c: codes and 'hidden' flag, as documented in * tests/macOSXFCmd.test: glob.n; objectified OSType handling in [glob] * unix/tclUnixFile.c: and [file attributes]; fix globbing for hidden files with pattern==NULL arg. [Bug 823329] * generic/tclIntPlatDecls.h: * generic/tclStubInit.c: make genstubs nobody added on 2006-03-21 00:31:47: Logged In: NO Sounds v. good to me, including the 'invisible' trade-off. Vince. das added on 2006-03-20 21:38:54: File Added - 171573: 823329.diff das added on 2006-03-20 21:38:53: Logged In: YES user_id=90580 patch attached that implements this on HEAD. also fixes minor issue with pattern==NULL case of 'glob -types hidden' on unix ([glob -types hidden someFile] incorrectly returned 'someFile'). the only thing not implemented is exclusion of files hidden via HFS invisible flag from ordinary glob results (i.e. without -types hidden), to implement this it would be necessary to do always do a costly stat & getattrlist for every file traversed (as well as a major rewrite of unix TclpMatchInDirectory/ NativeMatchType), I don't think it's worth the slowdown of the most common glob cases to add this minor feature. [glob -types hidden] does however return the files with HFS invisible flag in addition to files starting with '.' will commit this tomorrow if I don't hear any objections. vincentdarley added on 2006-03-20 06:10:33: Logged In: YES user_id=32170 Has this been implemented at any point? Vince. das added on 2003-10-14 19:10:41: File Added - 64313: tclUnixFile.diff das added on 2003-10-14 19:07:50: Logged In: YES user_id=90580 On Tuesday, Oct 14, 2003, at 19:56 Australia/Sydney, Daniel A. Steffen wrote: > On Tuesday, Oct 14, 2003, at 19:40 Australia/Sydney, Vince Darley > wrote: >> On Tue, 14 Oct 2003, Daniel A. Steffen wrote: >>> On Monday, Oct 13, 2003, at 21:38 Australia/Sydney, Vince Darley >>> wrote: >>> >>>> The 'NativeMatchType' in tcl/unix/tclUnixFile.c needs to be updated >>>> to >>>> (somehow) access the file type/creator when running on a compatible >>>> version of Unix (i.e. Darwin). >>> >>> it should be very easy to use the new TclMacOSXGetFileAttribute() >>> from >>> TIP118 for this. >> >> Should this just be #ifdef'd into NativeMatchType so it compiles on >> the >> relevant platform, or...? > > the creator/type code is #ifdef MAC_OSX_TCL so the same would be > appropriate, c.f tclMacOSXFCmd.c > > [glob -types hidden] should be properly supported as well, that's also > handled by TclMacOSXGetFileAttribute() and controlled by same #ifdef > > also [glob -types readonly] should be handled on unices that support > CHFLAGS, c.f GetReadOnlyAttribute() in tclUnixFCmd.c, this is > controlled by #if defined(HAVE_CHFLAGS) && defined(UF_IMMUTABLE) as far as support for readonly goes, the 4 line patch below should do the trick, what do you think? this'll work on OSX and any BSD that has chflags this way [glob -type readonly] will find any files that have [file attribute -readonly] but also files that don't have any write perms (to preserve existing behaviour) >> Also, by the time we're in NativeMatchType we actually only have a >> native >> path description (no Tcl_Obj) so we really want access to the innards >> of >> TclMacOSXGetFileAttribute. > > that's a bit of a pain, it kills code modularization for these > functions... > > it wouldn't be hard to copy the guts out of > TclMacOSXGetFileAttribute() and GetReadOnlyAttribute() into the unix > NativeMatchType() but it doesn't seem to be very clean. maybe we need > a native path aware versions of > TclMacOSXGetFileAttribute/GetReadOnlyAttribute ? maybe better to make a TclMacOSXNativeMatchType() that checks for OSX specific possibilities like creator/type/hidden and put that into tclMacOSXFCmd.c and call it from the unix NativeMatchType()? That way platform specific FS code stays in tclMacOSXFCmd.c (and can potentially be shared via static functions). |