File manager
Diff: FileManager.cpp
- Revision:
- 4:ec62bf823914
- Parent:
- 3:6e08d0bba1bb
- Child:
- 5:7c513eee7b2b
--- a/FileManager.cpp Sun May 15 09:56:42 2016 +0000 +++ b/FileManager.cpp Sun May 15 10:10:25 2016 +0000 @@ -9,9 +9,9 @@ /* ############### Static function prototype ################## */ -static void removeSpaces(char* s , int size); -static void getXmlText(char *str, char *ret); -static void generateFileNameWithTime(time_t timestamp, char * file_name); +static void FileManager_RemoveSpaces(char* s , int size); +static void FileManager_GetXmlText(char *str, char *ret); +static void FileManager_GenerateFileNameWithTime(time_t timestamp, char * file_name); /** @@ -21,7 +21,7 @@ * @param size of char array * @retval space removed char array */ -static void removeSpaces(char* s , int size) +static void FileManager_RemoveSpaces(char* s , int size) { char* cpy = s; // an alias to iterate through s without moving s char* temp = s; @@ -41,7 +41,7 @@ * @param char array to be populate XML text * @retval XML text */ -static void getXmlText(char *str, char *ret) +static void FileManager_GetXmlText(char *str, char *ret) { int size = strlen(str); int i; @@ -70,7 +70,7 @@ } /* Remove space from return value */ - removeSpaces(ret_addr, XMLTEXT_SIZE); + FileManager_RemoveSpaces(ret_addr, XMLTEXT_SIZE); } /** * @brief Utility function to get File Name with Date @@ -79,7 +79,7 @@ * @param file_name - char array to file name * @retval renamed file name */ -static void generateFileNameWithTime(time_t timestamp, char * file_name) +static void FileManager_GenerateFileNameWithTime(time_t timestamp, char * file_name) { char str[5]; struct tm * ptm; @@ -105,7 +105,7 @@ * @param None * @retval None */ -void readSetupFile() +void FileManager_ReadSetupFile() { /* Open file in reading mode */ FILE *fp = fopen(SETUP_FILE_NAME, "r"); @@ -139,14 +139,14 @@ if (state == STATE_FOUND_GPS) { /* Get XML text for GPS Interval */ - getXmlText(buf, m_GpsInterval); + FileManager_GetXmlText(buf, m_GpsInterval); printf("\r\n-found GPS interval %s ", m_GpsInterval); state = STATE_FINDING; } else if(state == STATE_FOUND_DATA) { /* Get XML text for Data Interval */ - getXmlText(buf, m_DataInterval); + FileManager_GetXmlText(buf, m_DataInterval); printf("\r\n-found Data interval %s ", m_DataInterval); state = STATE_FINDING; } @@ -164,13 +164,13 @@ * @param longti - char array for longtitude * @retval None */ -void logGPSData(time_t timestamp ,char lat[], char longti[]) +void FileManager_LogGPSData(time_t timestamp ,char lat[], char longti[]) { /* Get File name */ char file_name[] = GPS_LOG_FILE_NAME; /* Generate file name with time stamp */ - generateFileNameWithTime(timestamp,file_name); + FileManager_GenerateFileNameWithTime(timestamp,file_name); /* Open file with "APPEND" mode */ FILE *fp = fopen(file_name, "a"); @@ -200,17 +200,17 @@ * @param size - size of the float array * @retval None */ -void logRMSData(time_t timestamp ,float * var, int size) +void FileManager_LogRMSData(time_t timestamp ,float * var, int size) { /* Get File name */ char file_name[] = RTL_LOG_FILE_NAME; /* Generate File name with timestamp */ - generateFileNameWithTime(timestamp,file_name); - if (!is_file_exist(file_name)) + FileManager_GenerateFileNameWithTime(timestamp,file_name); + if (!FileManager_IsFileExist(file_name)) { /* If file is not exist, log the header */ - logRMSHeader(timestamp); + FileManager_LogRMSHeader(timestamp); } /* Open file with "APPEND" mode */ FILE *fp = fopen(file_name, "a"); @@ -247,13 +247,13 @@ * @param timestamp - time structure to get Date * @retval None */ -void logRMSHeader(time_t timestamp) +void FileManager_LogRMSHeader(time_t timestamp) { /* Get File name */ char file_name[] = RTL_LOG_FILE_NAME; /* Generate file name with time */ - generateFileNameWithTime(timestamp,file_name); + FileManager_GenerateFileNameWithTime(timestamp,file_name); /* Open file in append mode */ FILE *fp = fopen(file_name, "a"); @@ -289,7 +289,7 @@ * @param gps_interval - * @retval None */ -void logSystemData(float gps_interval) +void FileManager_LogSystemData(float gps_interval) { /* Open the file in append mode */ FILE *fp = fopen(MINIRMS_LOG_FILE_NAME, "a"); @@ -311,7 +311,7 @@ * @param filename - file name to be deleted * @retval None */ -void delete_file(char filename[]) +void FileManager_Deletefile(char filename[]) { printf("Deleting file '%s'...",filename); FILE *fp = fopen(filename, "r"); // try and open file @@ -328,7 +328,7 @@ * @param filename - file name to be checked * @retval true - file is exist , false - file is not exist */ -bool is_file_exist(char filename[]) +bool FileManager_IsFileExist(char filename[]) { bool exist = false; FILE *fp = fopen(filename, "r"); // try and open file @@ -345,7 +345,7 @@ * @param None * @retval GPS interval */ -int GPSInterval() +int FileManager_GPSInterval() { /* Return interval in int */ return atoi( m_GpsInterval ); @@ -356,7 +356,7 @@ * @param None * @retval Data interval */ -int DataInterval() +int FileManager_DataInterval() { /* Return interval in int */ return atoi( m_DataInterval ); @@ -367,7 +367,7 @@ * @param None * @retval pointer to variable list */ -Variable_Data_TypeDef * readVarFile() +Variable_Data_TypeDef * FileManager_ReadVarFile() { /* Open the file with reading mode */ FILE *fp = fopen(VARIABLE_FILE_NAME, "r"); @@ -396,13 +396,13 @@ if (strstr (buf,VAR_NAME_TAG)) { /* Found variable TAG, populate it*/ - getXmlText(buf , m_varList[index].varName); + FileManager_GetXmlText(buf , m_varList[index].varName); } else if (strstr (buf,VAR_ADDR_TAG)) { /* Found variable address TAG, populate it*/ - getXmlText(buf , m_varList[index].varAddress); + FileManager_GetXmlText(buf , m_varList[index].varAddress); index++; } @@ -423,7 +423,7 @@ * @param None * @retval amount of variable list */ -int getAmountVarList() +int FileManager_GetAmountVarList() { return m_amountVarList; } @@ -433,7 +433,7 @@ * @param None * @retval pointer to variable list */ -Variable_Data_TypeDef * getVarList() +Variable_Data_TypeDef * FileManager_GetVarList() { return m_varList; }