file primitive test suite
John M McIntosh
johnmci at smalltalkconsulting.com
Tue Nov 20 02:00:14 UTC 2001
><fact>
>You would not be able to "fix" it to forbid delete if the file is
>open even if you wanted to. At least it would be very difficult.
>On unix, this might amount to implementing an atomic operation that
>would check the file system for hard links to the file inode, check
>all mounted file systems for symbolic links to the file, check all
>references from NFS remote-mounted file systems to the file, and
>check for any open file handles from any process owned by any user
>on the system. If no such references exist, then unlink the file
>to remove its name from the file system, at which time it becomes
>"deleted". If references do exist, then fail with a hopelessly
>incomprehensible error message.
></fact>
>
Well I think you need to step back from the problem. Remember the
Squeak object knows if it is open or closed, therefore I'd tackle the
problem up there versus in the platform layer. Ah and I might ignore
the problem about what to do if something else other than Squeak has
the file open.
ie in
deleteFileNamed: localFileName ifAbsent: failBlock
"Delete the file of the given name if it exists, else
evaluate failBlock.
If the first deletion attempt fails do a GC to force
finalization of any lost references. ar 3/21/98 17:53"
(self
retryWithGC:[self primDeleteFileNamed: (self
fullNameFor: localFileName)]
until:[:result| result notNil]) == nil
ifTrue: [^failBlock value].
I could add something that would look at the StandardFileStream's
weak array registry and see if the file in question lurks somewhere.
Then throw an exception.
StandardFileStream forTheFileIfUsed: localFileName do: [:file | file
closed ifFalse: [^failBlock value]].
*or* I could just close the file just to be sure, but I'm not sure if
that would break things. Then again read or writing to a file in your
squeak application that you've deleted just *might* be a real
programming error. So maybe the fix is just to issue the close before
a delete to ensure we might be able to delete it. This still won't
work everywhere because other app might have the file open, but at
least sloppy squeak programing will behave the same across platforms.
--
--
===========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com
===========================================================================
More information about the Squeak-dev
mailing list
|