@@ -275,12 +275,14 @@ FATFileSystem::~FATFileSystem()
275
275
unmount ();
276
276
}
277
277
278
- int FATFileSystem::mount (BlockDevice *bd) {
278
+ int FATFileSystem::mount (BlockDevice *bd)
279
+ {
279
280
// requires duplicate definition to allow virtual overload to work
280
281
return mount (bd, true );
281
282
}
282
283
283
- int FATFileSystem::mount (BlockDevice *bd, bool mount) {
284
+ int FATFileSystem::mount (BlockDevice *bd, bool mount)
285
+ {
284
286
lock ();
285
287
if (_id != -1 ) {
286
288
unlock ();
@@ -322,7 +324,8 @@ int FATFileSystem::unmount()
322
324
323
325
/* See http://elm-chan.org/fsw/ff/en/mkfs.html for details of f_mkfs() and
324
326
* associated arguments. */
325
- int FATFileSystem::format (BlockDevice *bd, bd_size_t cluster_size) {
327
+ int FATFileSystem::format (BlockDevice *bd, bd_size_t cluster_size)
328
+ {
326
329
FATFileSystem fs;
327
330
int err = fs.mount (bd, false );
328
331
if (err) {
@@ -345,7 +348,8 @@ int FATFileSystem::format(BlockDevice *bd, bd_size_t cluster_size) {
345
348
return 0 ;
346
349
}
347
350
348
- int FATFileSystem::reformat (BlockDevice *bd, int allocation_unit) {
351
+ int FATFileSystem::reformat (BlockDevice *bd, int allocation_unit)
352
+ {
349
353
lock ();
350
354
if (_id != -1 ) {
351
355
if (!bd) {
@@ -375,7 +379,8 @@ int FATFileSystem::reformat(BlockDevice *bd, int allocation_unit) {
375
379
return err;
376
380
}
377
381
378
- int FATFileSystem::remove (const char *path) {
382
+ int FATFileSystem::remove (const char *path)
383
+ {
379
384
Deferred<const char *> fpath = fat_path_prefix (_id, path);
380
385
381
386
lock ();
@@ -388,7 +393,8 @@ int FATFileSystem::remove(const char *path) {
388
393
return fat_error_remap (res);
389
394
}
390
395
391
- int FATFileSystem::rename (const char *oldpath, const char *newpath) {
396
+ int FATFileSystem::rename (const char *oldpath, const char *newpath)
397
+ {
392
398
Deferred<const char *> oldfpath = fat_path_prefix (_id, oldpath);
393
399
Deferred<const char *> newfpath = fat_path_prefix (_id, newpath);
394
400
@@ -402,7 +408,8 @@ int FATFileSystem::rename(const char *oldpath, const char *newpath) {
402
408
return fat_error_remap (res);
403
409
}
404
410
405
- int FATFileSystem::mkdir (const char *path, mode_t mode) {
411
+ int FATFileSystem::mkdir (const char *path, mode_t mode)
412
+ {
406
413
Deferred<const char *> fpath = fat_path_prefix (_id, path);
407
414
408
415
lock ();
@@ -415,7 +422,8 @@ int FATFileSystem::mkdir(const char *path, mode_t mode) {
415
422
return fat_error_remap (res);
416
423
}
417
424
418
- int FATFileSystem::stat (const char *path, struct stat *st) {
425
+ int FATFileSystem::stat (const char *path, struct stat *st)
426
+ {
419
427
Deferred<const char *> fpath = fat_path_prefix (_id, path);
420
428
421
429
lock ();
@@ -442,7 +450,8 @@ int FATFileSystem::stat(const char *path, struct stat *st) {
442
450
return 0 ;
443
451
}
444
452
445
- int FATFileSystem::statvfs (const char *path, struct statvfs *buf) {
453
+ int FATFileSystem::statvfs (const char *path, struct statvfs *buf)
454
+ {
446
455
447
456
memset (buf, 0 , sizeof (struct statvfs ));
448
457
FATFS *fs;
@@ -470,17 +479,20 @@ int FATFileSystem::statvfs(const char *path, struct statvfs *buf) {
470
479
return 0 ;
471
480
}
472
481
473
- void FATFileSystem::lock () {
482
+ void FATFileSystem::lock ()
483
+ {
474
484
_ffs_mutex->lock ();
475
485
}
476
486
477
- void FATFileSystem::unlock () {
487
+ void FATFileSystem::unlock ()
488
+ {
478
489
_ffs_mutex->unlock ();
479
490
}
480
491
481
492
482
493
// //// File operations //////
483
- int FATFileSystem::file_open (fs_file_t *file, const char *path, int flags) {
494
+ int FATFileSystem::file_open (fs_file_t *file, const char *path, int flags)
495
+ {
484
496
debug_if (FFS_DBG, " open(%s) on filesystem [%s], drv [%s]\n " , path, getName (), _id);
485
497
486
498
FIL *fh = new FIL;
@@ -524,7 +536,8 @@ int FATFileSystem::file_open(fs_file_t *file, const char *path, int flags) {
524
536
return 0 ;
525
537
}
526
538
527
- int FATFileSystem::file_close (fs_file_t file) {
539
+ int FATFileSystem::file_close (fs_file_t file)
540
+ {
528
541
FIL *fh = static_cast <FIL*>(file);
529
542
530
543
lock ();
@@ -535,7 +548,8 @@ int FATFileSystem::file_close(fs_file_t file) {
535
548
return fat_error_remap (res);
536
549
}
537
550
538
- ssize_t FATFileSystem::file_read (fs_file_t file, void *buffer, size_t len) {
551
+ ssize_t FATFileSystem::file_read (fs_file_t file, void *buffer, size_t len)
552
+ {
539
553
FIL *fh = static_cast <FIL*>(file);
540
554
541
555
lock ();
@@ -551,7 +565,8 @@ ssize_t FATFileSystem::file_read(fs_file_t file, void *buffer, size_t len) {
551
565
}
552
566
}
553
567
554
- ssize_t FATFileSystem::file_write (fs_file_t file, const void *buffer, size_t len) {
568
+ ssize_t FATFileSystem::file_write (fs_file_t file, const void *buffer, size_t len)
569
+ {
555
570
FIL *fh = static_cast <FIL*>(file);
556
571
557
572
lock ();
@@ -567,7 +582,8 @@ ssize_t FATFileSystem::file_write(fs_file_t file, const void *buffer, size_t len
567
582
}
568
583
}
569
584
570
- int FATFileSystem::file_sync (fs_file_t file) {
585
+ int FATFileSystem::file_sync (fs_file_t file)
586
+ {
571
587
FIL *fh = static_cast <FIL*>(file);
572
588
573
589
lock ();
@@ -580,7 +596,8 @@ int FATFileSystem::file_sync(fs_file_t file) {
580
596
return fat_error_remap (res);
581
597
}
582
598
583
- off_t FATFileSystem::file_seek (fs_file_t file, off_t offset, int whence) {
599
+ off_t FATFileSystem::file_seek (fs_file_t file, off_t offset, int whence)
600
+ {
584
601
FIL *fh = static_cast <FIL*>(file);
585
602
586
603
lock ();
@@ -602,7 +619,8 @@ off_t FATFileSystem::file_seek(fs_file_t file, off_t offset, int whence) {
602
619
}
603
620
}
604
621
605
- off_t FATFileSystem::file_tell (fs_file_t file) {
622
+ off_t FATFileSystem::file_tell (fs_file_t file)
623
+ {
606
624
FIL *fh = static_cast <FIL*>(file);
607
625
608
626
lock ();
@@ -612,7 +630,8 @@ off_t FATFileSystem::file_tell(fs_file_t file) {
612
630
return res;
613
631
}
614
632
615
- off_t FATFileSystem::file_size (fs_file_t file) {
633
+ off_t FATFileSystem::file_size (fs_file_t file)
634
+ {
616
635
FIL *fh = static_cast <FIL*>(file);
617
636
618
637
lock ();
@@ -624,7 +643,8 @@ off_t FATFileSystem::file_size(fs_file_t file) {
624
643
625
644
626
645
// //// Dir operations //////
627
- int FATFileSystem::dir_open (fs_dir_t *dir, const char *path) {
646
+ int FATFileSystem::dir_open (fs_dir_t *dir, const char *path)
647
+ {
628
648
FATFS_DIR *dh = new FATFS_DIR;
629
649
Deferred<const char *> fpath = fat_path_prefix (_id, path);
630
650
@@ -642,7 +662,8 @@ int FATFileSystem::dir_open(fs_dir_t *dir, const char *path) {
642
662
return 0 ;
643
663
}
644
664
645
- int FATFileSystem::dir_close (fs_dir_t dir) {
665
+ int FATFileSystem::dir_close (fs_dir_t dir)
666
+ {
646
667
FATFS_DIR *dh = static_cast <FATFS_DIR*>(dir);
647
668
648
669
lock ();
@@ -653,7 +674,8 @@ int FATFileSystem::dir_close(fs_dir_t dir) {
653
674
return fat_error_remap (res);
654
675
}
655
676
656
- ssize_t FATFileSystem::dir_read (fs_dir_t dir, struct dirent *ent) {
677
+ ssize_t FATFileSystem::dir_read (fs_dir_t dir, struct dirent *ent)
678
+ {
657
679
FATFS_DIR *dh = static_cast <FATFS_DIR*>(dir);
658
680
FILINFO finfo;
659
681
@@ -681,7 +703,8 @@ ssize_t FATFileSystem::dir_read(fs_dir_t dir, struct dirent *ent) {
681
703
return 1 ;
682
704
}
683
705
684
- void FATFileSystem::dir_seek (fs_dir_t dir, off_t offset) {
706
+ void FATFileSystem::dir_seek (fs_dir_t dir, off_t offset)
707
+ {
685
708
FATFS_DIR *dh = static_cast <FATFS_DIR*>(dir);
686
709
687
710
lock ();
@@ -703,7 +726,8 @@ void FATFileSystem::dir_seek(fs_dir_t dir, off_t offset) {
703
726
unlock ();
704
727
}
705
728
706
- off_t FATFileSystem::dir_tell (fs_dir_t dir) {
729
+ off_t FATFileSystem::dir_tell (fs_dir_t dir)
730
+ {
707
731
FATFS_DIR *dh = static_cast <FATFS_DIR*>(dir);
708
732
709
733
lock ();
@@ -713,7 +737,8 @@ off_t FATFileSystem::dir_tell(fs_dir_t dir) {
713
737
return offset;
714
738
}
715
739
716
- void FATFileSystem::dir_rewind (fs_dir_t dir) {
740
+ void FATFileSystem::dir_rewind (fs_dir_t dir)
741
+ {
717
742
FATFS_DIR *dh = static_cast <FATFS_DIR*>(dir);
718
743
719
744
lock ();
0 commit comments