pellepl / spiffs

Wear-leveled SPI flash file system for embedded devices
MIT License
1.48k stars 403 forks source link

SPIFFS_rename behaviour #125

Open rojer opened 7 years ago

rojer commented 7 years ago

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.

pellepl commented 7 years ago

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

Cheers / P

rojer commented 7 years ago

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