Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface SDFileSystem mbed-rtos mbed
Diff: file_manager.cpp
- Revision:
- 3:998f7fb862af
- Parent:
- 2:e699312248f3
--- a/file_manager.cpp Mon Dec 05 22:46:14 2016 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,166 +0,0 @@
-#include "file_manager.hpp"
-
-#define MAX_TEXT_LEN 400
-
-extern Serial pc;
-
-char buffer[MAX_TEXT_LEN];
-
-void file_manager::print_files(void)
-{
- pc.printf("1. %s\r\n", path_sisk);
- pc.printf("2. %s\r\n", path_agh);
- pc.printf("3. %s\r\n", path_krk);
-}
-
-void file_manager::get_string(void)
-{
-// char * p_my_//cmd = p_cmd;
-// uint8_t char_counter = 0;
-// static char byte_received;
-//
-// do
-// {
-// byte_received = pc.getc();
-// *p_my_cmd = byte_received;
-// p_my_cmd++;
-// char_counter++;
-// if (char_counter >= CMD_LENGTH)
-// {
-// break; // CMD length reached max length.
-// }
-// pc.putc(byte_received);
-// for (int i = 0; i < len; i++)
-// {
-// pc.putc(*(p_cmd + i));
-// }
-// }while(byte_received != '\r');
-//
-// len = char_counter;
-//
-// pc.printf("\r\r\n");
-// pc.putc('Y');
-}
-
-void file_manager::get_path(void)
-{
- pc.printf("Current file to write to is: %s.\r\n", current_path);
-}
-
-void file_manager::set_path(void)
-{
- char number;
- bool correct_number = false;
-
- if (fp != NULL)
- {
- pc.printf("First close the file!\r\n");
- return;
- }
-
- this->get_path();
- pc.printf("Write the number of new file to write to. \r\n");
- this->print_files();
-
- do
- {
- correct_number = true;
- number = pc.getc();
- switch(number)
- {
- case '1':
- current_path = path_sisk;
- break;
- case '2':
- current_path = path_agh;
- break;
- case '3':
- current_path = path_krk;
- break;
- default:
- pc.printf("Incorrect number, try again.\r\n");
- correct_number = false;
- }
- }while(!correct_number);
-
- pc.printf("Setting path to: %s.\r\n", current_path);
-}
-
-bool file_manager::open_file(char option)
-{
- if (fp != NULL)
- {
- pc.printf("File already opened!\r\n");
- return false;
- }
-
- fp = fopen(this->current_path, &option);
-
- if (fp != NULL)
- {
- pc.printf("Opened file: %s.\r\n", this->current_path);
- }
-
- return true;
-}
-
-bool file_manager::close_file(void)
-{
- if (fp == NULL)
- {
- pc.printf("File already closed!\r\n");
- return false;
- }
-
- fclose(fp);
-
- fp = NULL;
-
- return true;
-}
-
-void file_manager::write_to_file(void)
-{
- this->open_file('w');
-
-
-
- this->close_file();
-}
-
-
-void file_manager::append_to_file(void)
-{
- this->open_file('a');
-
-
-
- this->close_file();
-}
-
-void file_manager::read_file(void)
-{
- long lSize;
- size_t result;
-
- this->open_file('r');
-
- fseek(fp , 0 , SEEK_END);
- lSize = ftell (fp);
- rewind(fp);
-
- // copy the file into the buffer:
- result = fread(buffer, 1, lSize, fp);
- if (result != lSize)
- {
- pc.printf("Reading error");
- }
- else
- {
- pc.printf("File: %s.\r\r\n", this->current_path);
- }
-
-
- this->close_file();
-
-}
\ No newline at end of file