fixed sextestream for windows
This commit is contained in:
@@ -20,10 +20,20 @@ namespace
|
||||
{
|
||||
protected:
|
||||
uint8_t lastOutput[FULL_SEXTET_COUNT];
|
||||
RageFile * out;
|
||||
|
||||
#ifdef _WIN32
|
||||
HANDLE out;
|
||||
#else
|
||||
RageFile* out;
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
#ifdef _WIN32
|
||||
SextetImpl(HANDLE file) {
|
||||
#else
|
||||
SextetImpl(RageFile * file) {
|
||||
#endif
|
||||
out = file;
|
||||
|
||||
// Ensure a non-match the first time
|
||||
@@ -33,9 +43,13 @@ namespace
|
||||
virtual ~SextetImpl() {
|
||||
if(out != nullptr)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
CloseHandle(out);
|
||||
#else
|
||||
out->Flush();
|
||||
out->Close();
|
||||
RageUtil::SafeDelete(out);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,8 +64,19 @@ namespace
|
||||
{
|
||||
if(out != nullptr)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
DWORD cbWritten;
|
||||
bool fSuccess = WriteFile(
|
||||
out, // pipe handle
|
||||
buffer, // message
|
||||
FULL_SEXTET_COUNT, // message length
|
||||
&cbWritten, // bytes written
|
||||
NULL); // not overlapped
|
||||
|
||||
#else
|
||||
out->Write(buffer, FULL_SEXTET_COUNT);
|
||||
out->Flush();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Remember last message
|
||||
@@ -109,19 +134,52 @@ inline RageFile * openOutputStream(const RString& filename)
|
||||
return file;
|
||||
}
|
||||
|
||||
LightsDriver_SextetStreamToFile::LightsDriver_SextetStreamToFile(RageFile * file)
|
||||
#ifdef _WIN32
|
||||
LightsDriver_SextetStreamToFile::LightsDriver_SextetStreamToFile(HANDLE file)
|
||||
{
|
||||
_impl = new SextetImpl(file);
|
||||
}
|
||||
#else
|
||||
LightsDriver_SextetStreamToFile::LightsDriver_SextetStreamToFile(RageFile* file)
|
||||
{
|
||||
_impl = new SextetImpl(file);
|
||||
}
|
||||
#endif // _WIN32
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
LightsDriver_SextetStreamToFile::LightsDriver_SextetStreamToFile(const RString& filename)
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
_impl = new SextetImpl(CreateFile(
|
||||
filename, // pipe name
|
||||
GENERIC_WRITE,
|
||||
0, // no sharing
|
||||
NULL, // default security attributes
|
||||
OPEN_EXISTING, // opens existing pipe
|
||||
0, // default attributes
|
||||
NULL));
|
||||
#else
|
||||
_impl = new SextetImpl(openOutputStream(filename));
|
||||
#endif
|
||||
}
|
||||
|
||||
LightsDriver_SextetStreamToFile::LightsDriver_SextetStreamToFile()
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
_impl = new SextetImpl(CreateFile(
|
||||
g_sSextetStreamOutputFilename.Get(), // pipe name
|
||||
GENERIC_WRITE,
|
||||
0, // no sharing
|
||||
NULL, // default security attributes
|
||||
OPEN_EXISTING, // opens existing pipe
|
||||
0, // default attributes
|
||||
NULL));
|
||||
#else
|
||||
_impl = new SextetImpl(openOutputStream(g_sSextetStreamOutputFilename));
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -16,15 +16,18 @@
|
||||
|
||||
#include "LightsDriver.h"
|
||||
#include "RageFile.h"
|
||||
#ifdef _WIN32
|
||||
#include "Windows.h"
|
||||
#endif
|
||||
|
||||
class LightsDriver_SextetStream : public LightsDriver
|
||||
{
|
||||
public:
|
||||
LightsDriver_SextetStream();
|
||||
virtual ~LightsDriver_SextetStream();
|
||||
virtual void Set(const LightsState *ls);
|
||||
virtual void Set(const LightsState* ls);
|
||||
protected:
|
||||
void * _impl;
|
||||
void* _impl;
|
||||
};
|
||||
|
||||
class LightsDriver_SextetStreamToFile : public LightsDriver_SextetStream
|
||||
@@ -35,7 +38,11 @@ public:
|
||||
|
||||
// The file object passed here should already be open, and will be
|
||||
// flushed, closed, and deleted in the destructor.
|
||||
LightsDriver_SextetStreamToFile(RageFile * file);
|
||||
#ifdef _WIN32
|
||||
LightsDriver_SextetStreamToFile(HANDLE file);
|
||||
#else
|
||||
LightsDriver_SextetStreamToFile(RageFile* file);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user