/*
 * File_Handling_RTOS.h
 *
 *  Created on: 14-May-2020
 *      Author: Controllerstech
 */

#ifndef FILE_HANDLING_RTOS_H_
#define FILE_HANDLING_RTOS_H_

#include "fatfs.h"
#include <string.h>
#include "stdio.h"
#include "fatfs.h"


/* mounts the sd card*/
int Mount_SD (const TCHAR* path);

/* unmounts the sd card*/
int Unmount_SD (const TCHAR* path);

/* Start node to be scanned (***also used as work area***) */
FRESULT Scan_SD (char* pat);

/* Only supports removing files from home directory. Directory remover to be added soon */
FRESULT Format_SD (void);

/* write the data to the file
 * @ name : is the path to the file*/
FRESULT Write_File (char *name, char *data);

/* write the data to the file
 * @ name : is the path to the file tooooooooooooooooooooooooooooooooooooooooooooooooo*/
FRESULT Write_File_byte (char *name, uint8_t *data, unsigned int bytesize);

/* read data from the file
 * @ name : is the path to the file*/
FRESULT Read_File (char *name);

FRESULT Seek_Read_File (char *name, uint8_t *data, unsigned int bytesize, unsigned long goto_label);

/* creates the file, if it does not exists
 * @ name : is the path to the file*/
FRESULT Create_File (char *name);

/* Removes the file from the sd card
 * @ name : is the path to the file*/
FRESULT Remove_File (char *name);

/* creates a directory
 * @ name: is the path to the directory
 */
FRESULT Create_Dir (char *name);

/* checks the free space in the sd card*/
void Check_SD_Space (void);

/* updates the file. write pointer is set to the end of the file
 * @ name : is the path to the file
 */
FRESULT Update_File (char *name, char *data);

FRESULT Update_File_float (char *name, float *data, unsigned int bytesize);

FRESULT Update_File_byte (char *name, uint8_t *data, unsigned int bytesize);


#endif /* FILE_HANDLING_RTOS_H_ */
