Make path operations safe + avoid generating file when unchanged