5
5
* Author: petera
6
6
*/
7
7
8
-
9
-
10
8
#ifndef SPIFFS_H_
11
9
#define SPIFFS_H_
12
10
#if defined(__cplusplus )
@@ -186,6 +184,11 @@ typedef struct {
186
184
// logical size of a page, must be at least
187
185
// log_block_size / 8
188
186
u32_t log_page_size ;
187
+
188
+ #endif
189
+ #if SPIFFS_FILEHDL_OFFSET
190
+ // an integer offset added to each file handle
191
+ u16_t fh_ix_offset ;
189
192
#endif
190
193
} spiffs_config ;
191
194
@@ -310,7 +313,7 @@ void SPIFFS_unmount(spiffs *fs);
310
313
* @param path the path of the new file
311
314
* @param mode ignored, for posix compliance
312
315
*/
313
- s32_t SPIFFS_creat (spiffs * fs , char * path , spiffs_mode mode );
316
+ s32_t SPIFFS_creat (spiffs * fs , const char * path , spiffs_mode mode );
314
317
315
318
/**
316
319
* Opens/creates a file.
@@ -321,7 +324,7 @@ s32_t SPIFFS_creat(spiffs *fs, char *path, spiffs_mode mode);
321
324
* SPIFFS_WR_ONLY, SPIFFS_RDWR, SPIFFS_DIRECT
322
325
* @param mode ignored, for posix compliance
323
326
*/
324
- spiffs_file SPIFFS_open (spiffs * fs , char * path , spiffs_flags flags , spiffs_mode mode );
327
+ spiffs_file SPIFFS_open (spiffs * fs , const char * path , spiffs_flags flags , spiffs_mode mode );
325
328
326
329
327
330
/**
@@ -360,13 +363,14 @@ s32_t SPIFFS_read(spiffs *fs, spiffs_file fh, void *buf, s32_t len);
360
363
s32_t SPIFFS_write (spiffs * fs , spiffs_file fh , void * buf , s32_t len );
361
364
362
365
/**
363
- * Moves the read/write file offset
366
+ * Moves the read/write file offset. Resulting offset is returned or negative if error.
367
+ * lseek(fs, fd, 0, SPIFFS_SEEK_CUR) will thus return current offset.
364
368
* @param fs the file system struct
365
369
* @param fh the filehandle
366
370
* @param offs how much/where to move the offset
367
371
* @param whence if SPIFFS_SEEK_SET, the file offset shall be set to offset bytes
368
372
* if SPIFFS_SEEK_CUR, the file offset shall be set to its current location plus offset
369
- * if SPIFFS_SEEK_END, the file offset shall be set to the size of the file plus offset
373
+ * if SPIFFS_SEEK_END, the file offset shall be set to the size of the file plus offse, which should be negative
370
374
*/
371
375
s32_t SPIFFS_lseek (spiffs * fs , spiffs_file fh , s32_t offs , int whence );
372
376
@@ -375,7 +379,7 @@ s32_t SPIFFS_lseek(spiffs *fs, spiffs_file fh, s32_t offs, int whence);
375
379
* @param fs the file system struct
376
380
* @param path the path of the file to remove
377
381
*/
378
- s32_t SPIFFS_remove (spiffs * fs , char * path );
382
+ s32_t SPIFFS_remove (spiffs * fs , const char * path );
379
383
380
384
/**
381
385
* Removes a file by filehandle
@@ -390,7 +394,7 @@ s32_t SPIFFS_fremove(spiffs *fs, spiffs_file fh);
390
394
* @param path the path of the file to stat
391
395
* @param s the stat struct to populate
392
396
*/
393
- s32_t SPIFFS_stat (spiffs * fs , char * path , spiffs_stat * s );
397
+ s32_t SPIFFS_stat (spiffs * fs , const char * path , spiffs_stat * s );
394
398
395
399
/**
396
400
* Gets file status by filehandle
@@ -420,7 +424,7 @@ s32_t SPIFFS_close(spiffs *fs, spiffs_file fh);
420
424
* @param old path of file to rename
421
425
* @param newPath new path of file
422
426
*/
423
- s32_t SPIFFS_rename (spiffs * fs , char * old , char * newPath );
427
+ s32_t SPIFFS_rename (spiffs * fs , const char * old , const char * newPath );
424
428
425
429
/**
426
430
* Returns last error of last file operation.
@@ -443,7 +447,7 @@ void SPIFFS_clearerr(spiffs *fs);
443
447
* @param name the name of the directory
444
448
* @param d pointer the directory stream to be populated
445
449
*/
446
- spiffs_DIR * SPIFFS_opendir (spiffs * fs , char * name , spiffs_DIR * d );
450
+ spiffs_DIR * SPIFFS_opendir (spiffs * fs , const char * name , spiffs_DIR * d );
447
451
448
452
/**
449
453
* Closes a directory stream
@@ -544,6 +548,20 @@ s32_t SPIFFS_gc_quick(spiffs *fs, u16_t max_free_pages);
544
548
*/
545
549
s32_t SPIFFS_gc (spiffs * fs , u32_t size );
546
550
551
+ /**
552
+ * Check if EOF reached.
553
+ * @param fs the file system struct
554
+ * @param fh the filehandle of the file to check
555
+ */
556
+ s32_t SPIFFS_eof (spiffs * fs , spiffs_file fh );
557
+
558
+ /**
559
+ * Get position in file.
560
+ * @param fs the file system struct
561
+ * @param fh the filehandle of the file to check
562
+ */
563
+ s32_t SPIFFS_tell (spiffs * fs , spiffs_file fh );
564
+
547
565
#if SPIFFS_TEST_VISUALISATION
548
566
/**
549
567
* Prints out a visualization of the filesystem.
0 commit comments