aboutsummaryrefslogtreecommitdiff
path: root/src/filehandler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/filehandler.cc')
-rw-r--r--src/filehandler.cc32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/filehandler.cc b/src/filehandler.cc
index 4856702..915657e 100644
--- a/src/filehandler.cc
+++ b/src/filehandler.cc
@@ -5,17 +5,17 @@
void
Filehandler::init(char *path)
{
- f = NULL;
- buffer = NULL;
- this->path = path;
+ m_file = NULL;
+ m_buffer = NULL;
+ m_path = path;
}
bool
Filehandler::open(void)
{
- f = fopen(path, "r");
- if (f == NULL) {
- printf("Unable to open %s\n", path);
+ m_file = fopen(m_path, "r");
+ if (m_file == NULL) {
+ printf("Unable to open %s\n", m_path);
return false;
}
@@ -25,32 +25,32 @@ Filehandler::open(void)
unsigned int
Filehandler::size(void)
{
- unsigned int current = ftell(f);
+ unsigned int current = ftell(m_file);
- fseek(f, 0, SEEK_END);
- unsigned int s = ftell(f);
+ fseek(m_file, 0, SEEK_END);
+ unsigned int s = ftell(m_file);
- fseek(f, current, SEEK_SET);
+ fseek(m_file, current, SEEK_SET);
return s;
}
char *
Filehandler::read(void)
{
- fseek(f, 0, SEEK_SET);
+ fseek(m_file, 0, SEEK_SET);
- buffer = (char *) calloc(size(), sizeof(char));
- int bytesread = fread(buffer, sizeof(char), size(), f);
+ m_buffer = (char *) calloc(size(), sizeof(char));
+ int bytesread = fread(m_buffer, sizeof(char), size(), m_file);
if (bytesread < 0) {
return NULL;
}
- return buffer;
+ return m_buffer;
}
void
Filehandler::close(void)
{
- fclose(f);
- free(buffer);
+ fclose(m_file);
+ free(m_buffer);
}