Version 4 of tclvfs gotchas

Updated 2004-09-07 20:49:08 by SEH

tclvfs is an excellent facility; however, there are some gotchas (as you'd expect for something that exposes the soft underbelly of tcl's file system).

This page is for folklore and here be dragons advice. Please track changes to any folklore you relate here, so it can be a useful resource for implementors and not a collection of old wives' tales.


Never error out of the fileattributes command - it is used by tcl core to copy files, and throwing an error from it 'will' sigsegv. Subject to a bug report [L1 ] -- CMcC 20040904


Never close the file descriptor passed into the command invoked on file close. Let tclvfs do it for you. -- CMcC 20040904

SEH -- Because if you do, Tcl will crash.


SEH -- The vfs api layer will catch all errors in the close callback procedure, so if the procedure aborts due to an error, the close command that invoked the callback will still return OK, giving no indication that the close procedure failed and thus possibly lost data.

Although the w channel open mode is supported in theory, in practice when the channel is passed to the close callback to be handled no capability is provided to read what's been written to the channel. Thus the written data is inaccessible to the vfs programmer. So unless you want to limit yourself to read-only filesystems, you must kludge things somehow, like silently switching the mode to w+ in the open procedure and hoping nobody using the vfs assumes a file opened for writing only will have reads blocked.

You can't use fcopy in the close callback, or otherwise pass data directly from one file channel to another. You have to read channel data into a variable, then write it from the variable to the target channel.


[Category VFS]