MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / close

Method close

libraries/AP_Filesystem/AP_Filesystem_FATFS.cpp:362–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360}
361
362int AP_Filesystem_FATFS::close(int fileno)
363{
364 FAT_FILE *stream;
365 FIL *fh;
366 int res;
367
368 FS_CHECK_ALLOWED(-1);
369 WITH_SEMAPHORE(sem);
370
371 errno = 0;
372
373 // checks if fileno out of bounds
374 stream = fileno_to_stream(fileno);
375 if (stream == nullptr) {
376 return -1;
377 }
378
379 // fileno_to_fatfs checks for fileno out of bounds
380 fh = fileno_to_fatfs(fileno);
381 if (fh == nullptr) {
382 return -1;
383 }
384 res = f_close(fh);
385 free_file_descriptor(fileno);
386 if (res != FR_OK) {
387 errno = fatfs_to_errno((FRESULT)res);
388 return -1;
389 }
390 return 0;
391}
392
393int32_t AP_Filesystem_FATFS::read(int fd, void *buf, uint32_t count)
394{

Callers

nothing calls this directly

Calls 4

fileno_to_streamFunction · 0.85
fileno_to_fatfsFunction · 0.85
free_file_descriptorFunction · 0.85
fatfs_to_errnoFunction · 0.85

Tested by

no test coverage detected