playlist_file.c 601 B

123456789101112131415161718192021
  1. #include <furi.h>
  2. #include <storage/storage.h>
  3. #include <flipper_format/flipper_format_i.h>
  4. int playlist_count_playlist_items(Storage* storage, const char* file_path) {
  5. FlipperFormat* format = flipper_format_file_alloc(storage);
  6. if(!flipper_format_file_open_existing(format, file_path)) {
  7. return -1;
  8. }
  9. int count = 0;
  10. FuriString* data;
  11. data = furi_string_alloc();
  12. while(flipper_format_read_string(format, "sub", data)) {
  13. ++count;
  14. }
  15. flipper_format_file_close(format);
  16. flipper_format_free(format);
  17. furi_string_free(data);
  18. return count;
  19. }