2 ******************************************************************************
7 *CREATE DATE : 2010-9-15
8 *UPDATE DATE : 2010-9-15
9 *UPDATE BY : Zhou Guyue
10 *******************************************************************************
20 * FUNCTION: open sfs file
21 * PARAMETER: outfiles : outfile name.
22 writeFr : whether writer frequence file.
23 doBay : whether do Bay.
24 doJoint : whether do Joint
25 * RETURN: OPENSFS_ERROR:if can not open file ,OPENSFS_SUCC : if can open file.
27 int Files::OpenSfsfile(const string outfiles
, const int writeFr
, const int doBay
, const int doJoint
)
29 //generete the output filenames
32 printf("Must supply -outfiles (-fai)\n");
36 fSFSall
= outfiles
+ ".sfs";
37 fFreq
= outfiles
+ ".frq";
38 fJoint
= outfiles
+ ".bjoint";
40 //open the persite FILE streams
44 //freqfile.open(fFreq.c_str());
45 freqfile
= getFILE(fFreq
.c_str(),"w");
50 //sfsfile.open(fSFSall.c_str());
51 sfsfile
= getFILE(fSFSall
.c_str(),"w");
52 //sfsfile-open(fSFSall.c_str());
56 //jointSfsfile.clear();
57 //jointSfsfile.open(fJoint.c_str(), ios::binary);
58 jointSfsfile
= getFILE(fJoint
.c_str(),"w");
60 if ((writeFr
&& !freqfile
) || (doBay
&& !sfsfile
) || (doJoint
&& !jointSfsfile
))
62 cerr
<< "\topen sfs file failed!" << endl
;
71 * FUNCTION: get file in mode
72 * PARAMETER: fname : file name , mode : write.
75 FILE* Files::getFILE(const char*fname
,const char* mode
)
78 if(NULL
== (fp
= fopen(fname
, mode
)))
80 fprintf(stderr
,"\t->Error opening FILE handle for file:%s exiting\n",fname
);