A common trick in the UNIX world to is create a temporary file with open() and immediately unlink() it but continue using it before calling close(). The OS will preserve the inode internally and delete the file when the last user of the file's inode is done with it.
SQLite uses this trick for its own temporary files (etilsq_XXXXXXXX). unlink()ing before close() works fine in NestedVM when run on any UNIX filesystem, but it does not work when NestedVM is running on a Windows machine - the previously unlinked files still remain after the process exits. This is due to the fact that Java does not attempt to abstract its filesystem operations from the host operating system. For this unlink-before-close functionality to work in NestedVM on Windows it would have to keep a delete-on-close flag on each NestedVM file object and if this flag is set, the file would have be unlinked only after the last close is called on the file. The file's open()/close() operations would have to be ref-counted so that close() is only called when the open ref-count is 0. Upon exit (atexit, perhaps) the list of file descriptors could be scanned in NestedVM to perform these unlink operations after the files are closed. This would not address the problem of temp files remaining if the process crashes after the unlink() but before the close(), but it would properly delete temp files in programs that exit cleanly. I'd suggest to continue to attempt to delete the file immediately upon unlink(), as it would would work correctly on UNIX, but also to attempt to delete it again at last file close or program end. The redundant delete would be just a no-op in UNIX, but necessary in Windows. I may try to write a patch to address this issue, but it may not be for a while. If someone wants to take a crack at it, feel free. ____________________________________________________________________________________ Don't pick lemons. See all the new 2007 cars at Yahoo! Autos. http://autos.yahoo.com/new_cars.html --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "SQLiteJDBC" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups-beta.google.com/group/sqlitejdbc?hl=en -~----------~----~----~----~------~----~------~--~---
