Question

A way to unpack embedded resource has been already discussed on StackOverflow. Provided solution unfortunately doesn't work for libraries that might get executed from multiple processes simultaneously, which could result in corruption of the unpacked resource or some spurious exceptions.

I am looking for a method to unpack embedded resource in a safe way, by which I mean:

  1. No unnecessary copies of the file are created. If it's the same file, it should be in the same location.

  2. Multiple versions of the file can coexist in the filesystem.

  3. Once unpacked, the file will live at least as long as the process that unpacked it and all attempts to read the file will succeed.

  4. It doesn't matter how many processes execute the unpacking process concurrently. The result is always the same.

  5. If unpacking gets interrupted in one process, other processes (executing concurrently or sequentially) will be able to recover transparently.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top