Question about Pixie

<< < (2/2)

Cycl0ne:
Some update:
Code:

//*** Platform_Android_Time ***
#include "Platform_Android_Time.h"
//*** Constructor ***

Platform_Android_Time::Platform_Android_Time()
{
// Initialise Time
    struct timeval tv;
    gettimeofday(&tv, NULL);
    initTime_ = (float) tv.tv_sec*1000. + tv.tv_usec/1000.;
}

//*** GetTime ***

float Platform_Android_Time::GetTime()
{
    struct timeval tv;
    gettimeofday(&tv, NULL);
float curTime = (float) tv.tv_sec*1000. + tv.tv_usec/1000.;
deltaTime_ = curTime - initTime_;
return deltaTime_;
}

//*** GetSystemTime ***

Platform_Time::SystemTime Platform_Android_Time::GetSystemTime(bool utcTime)
{
SystemTime result;
result.day=0;
result.dayOfWeek=0;
result.hour=0;
result.minute=0;
result.month=0;
result.second=0;
result.year=0;
return result;
}


Code:

//*** Platform_Android_FileSystem_File.cpp ***

#include "Platform_Android_FileSystem_File.h"

//*** Constructor ***

Platform_Android_FileSystem_File::Platform_Android_FileSystem_File(const char* path)
{
if (!path)
{
Platform::GetPlatform_OS()->OutputDebugText("No path specified!\n");
}

if (path)
{
path_=strdup(path);
}
}

Platform_Android_FileSystem_File::~Platform_Android_FileSystem_File()
{
if (path_)
{
free(path_);
}

if (fileHandle_!=NULL)
{
fclose(fileHandle_);
}
}

//*** GetPath ***

const char* Platform_Android_FileSystem_File::GetPath()
{
return path_;
}


//*** Exists ***

bool Platform_Android_FileSystem_File::Exists()
{
if (!path_) return false;
if (FILE *file = fopen(path_, "r"))
{
fclose(file);
return true;
}
return false;
}


//*** Create ***

bool Platform_Android_FileSystem_File::Create()
{
if (fileHandle_!=NULL)
{
Platform::GetPlatform_OS()->OutputDebugText("File already open\n");
return false;
}
fileHandle_ = fopen(path_, "w+b");
return (fileHandle_!=NULL);
}


//*** Open ***

bool Platform_Android_FileSystem_File::Open()
{
if (fileHandle_!=NULL)
{
Platform::GetPlatform_OS()->OutputDebugText("File already open\n");
return false;
}
fileHandle_ = fopen(path_, "r+b");
return (fileHandle_!=NULL);
}


//*** Close ***

bool Platform_Android_FileSystem_File::Close()
{
if (fileHandle_==NULL)
{
Platform::GetPlatform_OS()->OutputDebugText("File not open\n");
return false;
}
fclose(fileHandle_);
fileHandle=NULL;
return true;
}


//*** Delete ***

void Platform_Android_FileSystem_File::Delete()
{
if (path_)
{
remove(path_);
}
}


//*** GetPosition ***

int Platform_Android_FileSystem_File::GetPosition()
{
if (fileHandle_==NULL)
{
Platform::GetPlatform_OS()->OutputDebugText("File not open\n");
return 0;
}
return ftell(fileHandle_);
}


//*** SetPosition ***

int Platform_Android_FileSystem_File::SetPosition(int position,SetPositionOrigin origin)
{
if (fileHandle_==NULL)
{
Platform::GetPlatform_OS()->OutputDebugText("File not open\n");
return 0;
}
return fseek(fileHandle_, position, origin);
}


//** Write methods */

#define WRITEMACRO() \
if (fileHandle_==NULL) \
{ \
Platform::GetPlatform_OS()->OutputDebugText("Tried to write to file that is not open for writing\n"); \
return 0; \
} \
\
unsigned long numberOfBytesWritten=0; /* Stores the number of bytes read */ \
/* Writes the data to the file */ \
numberOfBytesWritten = fwrite(value, sizeof(*value), count, fileHandle_); \
if (numberOfBytesWritten < count) \
{ \
Platform::GetPlatform_OS()->OutputDebugText("Write operation failed\n"); \
return 0; \
} \
\
/* Return number of elements written, rather than the number of bytes */ \
return numberOfBytesWritten; ///sizeof(*value); \

int Platform_Android_FileSystem_File::Write(const char* value, int count)
{
WRITEMACRO();
}

int Platform_Android_FileSystem_File::Write(const short* value, int count)
{
WRITEMACRO();
}

int Platform_Android_FileSystem_File::Write(const int* value, int count)
{
WRITEMACRO();
}

int Platform_Android_FileSystem_File::Write(const long* value, int count)
{
WRITEMACRO();
}

int Platform_Android_FileSystem_File::Write(const unsigned char* value, int count)
{
WRITEMACRO();
}

int Platform_Android_FileSystem_File::Write(const unsigned short* value, int count)
{
WRITEMACRO();
}

int Platform_Android_FileSystem_File::Write(const unsigned int* value, int count)
{
WRITEMACRO();
}

int Platform_Android_FileSystem_File::Write(const unsigned long* value, int count)
{
WRITEMACRO();
}

int Platform_Android_FileSystem_File::Write(const float* value, int count)
{
WRITEMACRO();
}

int Platform_Android_FileSystem_File::Write(const double* value, int count)
{
WRITEMACRO();
}

int Platform_Android_FileSystem_File::Write(const bool* value, int count)
{
WRITEMACRO();
}


//** Read methods */
#define READMACRO() \
if (fileHandle_==NULL) \
{ \
Platform::GetPlatform_OS()->OutputDebugText("Tried to read from file that is not open for reading\n"); \
return 0; \
} \
\
unsigned long numberOfBytesRead=0; /* Stores the number of bytes read */ \
/* Reads the data from the file */ \
numberOfBytesRead = fread(value, sizeof(*value), count, fileHandle_); \
if (numberOfBytesRead < count) \
{ \
Platform::GetPlatform_OS()->OutputDebugText("Read operation failed\n"); \
return 0; \
} \
\
/* Return number of elements read, rather than the number of bytes */ \
return numberOfBytesRead;


int Platform_Android_FileSystem_File::Read(char* value, int count)
{
READMACRO();
}

int Platform_Android_FileSystem_File::Read(short* value, int count)
{
READMACRO();
}

int Platform_Android_FileSystem_File::Read(int* value, int count)
{
READMACRO();
}

int Platform_Android_FileSystem_File::Read(long* value, int count)
{
READMACRO();
}

int Platform_Android_FileSystem_File::Read(unsigned char* value, int count)
{
READMACRO();
}

int Platform_Android_FileSystem_File::Read(unsigned short* value, int count)
{
READMACRO();
}

int Platform_Android_FileSystem_File::Read(unsigned int* value, int count)
{
READMACRO();
}

int Platform_Android_FileSystem_File::Read(unsigned long* value, int count)
{
READMACRO();
}

int Platform_Android_FileSystem_File::Read(float* value, int count)
{
READMACRO();
}

int Platform_Android_FileSystem_File::Read(double* value, int count)
{
READMACRO();
}

int Platform_Android_FileSystem_File::Read(bool* value, int count)
{
READMACRO();
}



should both work in normal linux convertions too.

Mattias Gustavsson:
very cool! that's great progress!  ;D

Cycl0ne:
Hi,

just to update :-) Still alive. Im waiting for an android upgrade to 2.3 with native c-api for pixie to run. Otherweise under 2.2 i came into alot of problems with java native interface and c. Hopefully my new Android 2.3 Device will be available in 2-3 weeks.

At the moment im looking into pixie a bit further and try to understand everything. Too bad Mattias has left support, or are you still doing something with it? Ive seen some comments where it says: still has to be done ;-)

I got my hands on a VisualStudio 10 Professional. What I read in the installation guide, that VS10 is not supported. Anyone knows whats not supported? Where it hangs? Havent installed the version. Perhaps in the weekend i got some time (after doing some homework for my wife) to check to compile it.

Mattias Gustavsson:
That's good to hear - and thanks for the update :D

And no, I have by no means stopped supporting Pixie - I've had a period of being busy with other things, but are really getting back into things now, and I have plans to make an updated version of Pixie sometime in the future (though it will be some time before I do).

Are you saying you have a problem using Pixie with Visual Studio 10? I'm not sure why that would be...

Navigation

[0] Message Index

[*] Previous page