2016-06-15 02:02:35 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014-2015, Claudio Lapilli and the newRPL Team
|
|
|
|
* All rights reserved.
|
|
|
|
* This file is released under the 3-clause BSD license.
|
|
|
|
* See the file LICENSE.txt that shipped with this distribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fsyspriv.h"
|
|
|
|
|
2019-06-20 22:59:24 +02:00
|
|
|
#ifndef CONFIG_NO_FSYSTEM
|
2016-06-15 02:02:35 +02:00
|
|
|
|
2020-01-22 00:34:44 +01:00
|
|
|
int FSRead(unsigned char *buffer, int nbytes, FS_FILE * file)
|
2016-06-15 02:02:35 +02:00
|
|
|
{
|
2020-01-22 00:34:44 +01:00
|
|
|
FS_VOLUME *fs;
|
|
|
|
int vol = 0;
|
2016-06-15 02:02:35 +02:00
|
|
|
|
|
|
|
// SAME AS LOW-LEVEL FUNCTION BUT W/SOME CHECKS
|
|
|
|
|
2020-01-22 00:34:44 +01:00
|
|
|
if(!FSystem.Init)
|
|
|
|
return FS_ERROR;
|
|
|
|
|
|
|
|
if(file == NULL)
|
|
|
|
return FS_ERROR;
|
|
|
|
vol = file->Volume;
|
|
|
|
if(vol > 3 || vol < 0)
|
|
|
|
return FS_ERROR; // INVALID VOLUME --> FILE STRUCTURE CORRUPT
|
|
|
|
fs = FSystem.Volumes[vol];
|
|
|
|
if(fs == NULL)
|
|
|
|
return FS_ERROR;
|
|
|
|
return FSReadLL(buffer, nbytes, file, fs);
|
2016-06-15 02:02:35 +02:00
|
|
|
}
|
|
|
|
|
2019-06-20 22:59:24 +02:00
|
|
|
#endif
|