[dad864]: effect.cpp  Maximize  Restore  History

Download this file

64 lines (50 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// effect.cpp: implementation of the Ceffect class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include <fcntl.h>
#include "chitem.h"
#include "effect.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Ceffect::Ceffect()
{
}
Ceffect::~Ceffect()
{
}
int Ceffect::WriteEffectToFile(int fhandle, int calculate)
{
if(calculate) return sizeof(eff_header);
memcpy(header.filetype,"EFF V2.0",8);
memcpy(header.signature,"EFF V2.0",8);
if(write(fhandle,&header,sizeof(eff_header) )!=sizeof(eff_header) )
{
return -2;
}
return 0;
}
int Ceffect::ReadEffectFromFile(int fhandle, int maxlen)
{
if(maxlen==-1) maxlen=filelength(fhandle);
if(!maxlen) return -2; //short file, invalid item
if(read(fhandle,&header,sizeof(eff_header) )!=sizeof(eff_header) )
{
return -2; // short file, invalid item
}
if(memcmp(header.filetype,"EFF ",4) )
{
return -2;
}
if(header.revision[0]!='V')
{
return -2;
}
return 0;
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks