Adding header info

This commit is contained in:
Michael Tryby
2019-04-01 15:16:58 -04:00
parent 23ac179ec1
commit b9f00421dd
3 changed files with 39 additions and 17 deletions

View File

@@ -1,4 +1,15 @@
/*
******************************************************************************
Project: OWA EPANET
Version: 2.2
Module: util/filemanager.c
Description: Provides a simple interface for managing files
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
Last Updated: 04/01/2019
******************************************************************************
*/
// MSVC ONLY // MSVC ONLY
@@ -18,7 +29,6 @@
typedef struct file_s { typedef struct file_s {
char filename[FILE_MAXNAME + 1]; char filename[FILE_MAXNAME + 1];
FILE *file; FILE *file;
char mode[FILE_MAXMODE + 1];
} file_handle_t; } file_handle_t;
@@ -51,8 +61,7 @@ int open_file(file_handle_t *file_handle, const char *filename, const char *file
if (file_mode == NULL) if (file_mode == NULL)
error = -1; error = -1;
else { else {
strncpy(file_handle->mode, file_mode, FILE_MAXMODE); error = _fopen(&(file_handle->file), file_handle->filename, file_mode);
error = _fopen(&(file_handle->file), file_handle->filename, file_handle->mode);
} }
return error; return error;

View File

@@ -1,6 +1,15 @@
/*
******************************************************************************
Project: OWA EPANET
Version: 2.2
Module: util/filemanager.h
Description: Provides a simple interface for managing files
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
Last Updated: 04/01/2019
******************************************************************************
*/
#ifndef FILEMANAGER_H_ #ifndef FILEMANAGER_H_
#define FILEMANAGER_H_ #define FILEMANAGER_H_
@@ -17,14 +26,13 @@
#endif #endif
#define FILE_MAXNAME 259 #define FILE_MAXNAME 259
#define FILE_MAXMODE 3
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif
// Forward declariation of file_handle_t
typedef struct file_s file_handle_t; typedef struct file_s file_handle_t;

View File

@@ -1,4 +1,15 @@
/*
******************************************************************************
Project: OWA EPANET
Version: 2.2
Module: util/test_filemanager.cpp
Description: Tests filemanager
Authors: see AUTHORS
Copyright: see AUTHORS
License: see LICENSE
Last Updated: 04/01/2019
******************************************************************************
*/
#define BOOST_TEST_MODULE filemanager #define BOOST_TEST_MODULE filemanager
@@ -12,6 +23,7 @@
BOOST_AUTO_TEST_SUITE(test_filemanager) BOOST_AUTO_TEST_SUITE(test_filemanager)
BOOST_AUTO_TEST_CASE (test_create_destroy) BOOST_AUTO_TEST_CASE (test_create_destroy)
{ {
file_handle_t *file_handle = NULL; file_handle_t *file_handle = NULL;
@@ -55,12 +67,5 @@ struct Fixture{
file_handle_t *file_handle; file_handle_t *file_handle;
}; };
BOOST_FIXTURE_TEST_CASE(test_get_file, Fixture)
{
FILE *file;
//file = get_file(file_handle);
//BOOST_CHECK(file != NULL);
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()