spiffs icon indicating copy to clipboard operation
spiffs copied to clipboard

SPIFFS_rename behaviour

Open rojer opened this issue 8 years ago • 2 comments

I don't expect this to be addressed immediately, but perhaps in some future revision...

rename() is commonly used to safely write files, i.e. prepare a temp file and then move it into place. it's a good practice, but its safety hinges on the atomicity of rename and its behavior wrt destinations that already exist. it would be nice if SPIFFS_rename behaved closer to POSIX, specifically: it should be atomic and should not fail if newPath exists, it should silently delete newPath in this case.

see here for detailed spec.

rojer avatar Jan 09 '17 10:01 rojer

Ah, I did not know that this was the posix way. Will fix in som indefinable future 😉. Thanks for the heads up!

Cheers / P

pellepl avatar Jan 09 '17 10:01 pellepl

perhaps the latter (delete if src != dst and dst already exists) is simpler to implement.

rojer avatar Jan 09 '17 10:01 rojer