Bit of a niche question this, but I want to atomically replace a directory with a symlink to itself under a different name.
Specifically, I have a directory ./node_modules, and I want to move it to ./node_modules.nosync and link the old path to the new path (./node_modules -> ./node_modules.nosync). This is because I want to stop iCloud from messing with it - long story. And I want to perform that operation while another process is writing to that path.
I'm looking to do something similar to this or this, but involving a directory.
I was originally thinking of holding some kind of lock on the path so that the other process writing to it stalls, but from what I can tell you can't hold a lock on a directory path on macOS.