spiffs icon indicating copy to clipboard operation
spiffs copied to clipboard

Added SPIFFS_truncate function

Open davctv opened this issue 6 years ago • 8 comments

Hi,

this pull request should solve issue

https://github.com/pellepl/spiffs/issues/107 and https://github.com/pellepl/spiffs/issues/217

I used SPIFFS_remove function as a template. Complete test not already done, but I think it shuold be ok.

thanks

davctv avatar Jul 28 '18 20:07 davctv

Hi,

I'm not an expert of Pull request (this is my first one), but I don't know why it failed the check..I modified the type of length parameter from __off_t to u32_t

Any suggestion to solve is appreciated.

Thanks.

davctv avatar Jul 30 '18 09:07 davctv

99% of the code in SPIFFS_truncate() is common with SPIFFS_remove(), except for the additional length argument and parameters passed internally to spiffs_object_truncate(), so I suggest to write a common internal function SPIFFS_truncate_or_remove() with both length and remove_object flag as arguments and passed to spiffs_object_truncate() as-is, that is called from SPIFFS_remove() and SPIFFS_truncate() stubs instead.

I think having a SPIFFS_ftrunctate() similar to SPIFFS_fremove() (i.e., with a file handle instead of a path) could also be done the same way with little extra efforts.

Squonk42 avatar Aug 16 '18 16:08 Squonk42

any update when this pull request will be accepted?

milamber-ls avatar Nov 26 '18 20:11 milamber-ls

Hi @milamber-ls,

In my opinion @pellepl is not updating anymore the project (maybe he is working on the new version). Since you are using it for esp32 I think you could import the spiffs in "components" folder of your project and modify the source code with my edits.

davctv avatar Nov 27 '18 08:11 davctv

Thank you @davctv ! This is what I did and it works nicely. The problem in this situation is that every time that I am updating edp-idf I have to go and apply these changes all over again. Every time. From the esp-idf point of view they cant accept the request into esp-idf if this request is not accepted first. catch 22.

milamber-ls avatar Nov 27 '18 17:11 milamber-ls

Is SPIFFS truncate still in limbo?

VikOlliver avatar Oct 10 '19 01:10 VikOlliver

Now implemented and merged in https://github.com/pellepl/spiffs/pull/278 + https://github.com/pellepl/spiffs/pull/287.

igrr avatar Mar 17 '22 23:03 igrr

Thanks, I'll get my project out of mothballs and try it out. Probably suffering from a little "bit rot" by now :)

VikOlliver avatar Mar 17 '22 23:03 VikOlliver