summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-05-26 19:28:08 -0300
committerRenato Filho <renato.filho@openbossa.org>2010-05-26 19:34:28 -0300
commit440715431fb1abae0a089eaeae76df0686558097 (patch)
treeb8845cde3c24823a0037f0058aa4b3d2bfb4dc57
parent666a4deb3be66237800145ba0ad9f894575f044d (diff)
downloadshiboken-440715431fb1abae0a089eaeae76df0686558097.tar.gz
shiboken-440715431fb1abae0a089eaeae76df0686558097.tar.xz
shiboken-440715431fb1abae0a089eaeae76df0686558097.zip
Fixed declaration of class SimpleFile.
Move FILE member to internal structor to avoid errors on compilation of debian PPC. Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r--tests/libsample/simplefile.cpp57
-rw-r--r--tests/libsample/simplefile.h29
2 files changed, 56 insertions, 30 deletions
diff --git a/tests/libsample/simplefile.cpp b/tests/libsample/simplefile.cpp
index c79152ba..1dc378ac 100644
--- a/tests/libsample/simplefile.cpp
+++ b/tests/libsample/simplefile.cpp
@@ -32,18 +32,59 @@
* 02110-1301 USA
*/
+#include <stdlib.h>
+#include <string.h>
#include <fstream>
#include "simplefile.h"
+class SimpleFile_p
+{
+public:
+ SimpleFile_p(const char* filename) : m_descriptor(0), m_size(0)
+ {
+ m_filename = strdup(filename);
+ }
+
+ ~SimpleFile_p()
+ {
+ free(m_filename);
+ }
+
+ char* m_filename;
+ FILE* m_descriptor;
+ long m_size;
+};
+
+SimpleFile::SimpleFile(const char* filename)
+{
+ p = new SimpleFile_p(filename);
+}
+
+SimpleFile::~SimpleFile()
+{
+ close();
+ delete p;
+}
+
+const char* SimpleFile::filename()
+{
+ return p->m_filename;
+}
+
+long SimpleFile::size()
+{
+ return p->m_size;
+}
+
bool
SimpleFile::open()
{
- if ((m_descriptor = fopen(m_filename, "rb")) == 0)
+ if ((p->m_descriptor = fopen(p->m_filename, "rb")) == 0)
return false;
- fseek(m_descriptor, 0, SEEK_END);
- m_size = ftell(m_descriptor);
- rewind(m_descriptor);
+ fseek(p->m_descriptor, 0, SEEK_END);
+ p->m_size = ftell(p->m_descriptor);
+ rewind(p->m_descriptor);
return true;
}
@@ -51,16 +92,16 @@ SimpleFile::open()
void
SimpleFile::close()
{
- if (m_descriptor) {
- fclose(m_descriptor);
- m_descriptor = 0;
+ if (p->m_descriptor) {
+ fclose(p->m_descriptor);
+ p->m_descriptor = 0;
}
}
bool
SimpleFile::exists() const
{
- std::ifstream ifile(m_filename);
+ std::ifstream ifile(p->m_filename);
return ifile;
}
diff --git a/tests/libsample/simplefile.h b/tests/libsample/simplefile.h
index 67797e7d..9f7d042a 100644
--- a/tests/libsample/simplefile.h
+++ b/tests/libsample/simplefile.h
@@ -38,29 +38,16 @@
#include "libsamplemacros.h"
#include <stdio.h>
+class SimpleFile_p;
+
class LIBSAMPLE_API SimpleFile
{
public:
- explicit SimpleFile(const char* filename)
- : m_filename(filename), m_descriptor(0), m_size(0)
- {
- }
-
- ~SimpleFile()
- {
- this->close();
- }
-
- const char* filename()
- {
- return m_filename;
- }
-
- long size()
- {
- return m_size;
- }
+ explicit SimpleFile(const char* filename);
+ ~SimpleFile();
+ const char* filename();
+ long size();
bool open();
void close();
@@ -68,9 +55,7 @@ public:
static bool exists(const char* filename);
private:
- const char* m_filename;
- FILE* m_descriptor;
- long m_size;
+ SimpleFile_p *p;
};
#endif // SIMPLEFILE_H