What is the best strategy for this? Is embedding a database in memory like hsqldb a good reason to get this kind of atomicity / transactional behavior?
Yes. If you require transactional behavior, use a well-tested system that has been designed with this in mind, rather than trying to topple your own on top of an untrusted substrate.
File systems generally do not support multi-file transactions.
Non-Windows file systems and NTFS typically have the property that you can replace an atomic file, so if you cannot use a database and
- all files are in one fairly small directory
- who owns your application and
- which is stored on one physical disk:
then you can do the following:
- Copy directory contents using hard links.
- Change 5 files.
- Atomic replacement of a modified copy of the catalog with the original
source share