ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/PrimerMatch/fileStar.cc
Revision: 1.1.1.1 (vendor branch)
Committed: Wed Dec 22 21:37:17 2004 UTC (11 years, 5 months ago) by nje01
Branch: MAIN
CVS Tags: HEAD, RELEASE-20041222, HEAD
Changes since 1.1: +0 -0 lines
Log Message:
Initial primer_match import

Line File contents
1 /**************************************************************************
2 * This code is part of the supporting infrastructure for ATA Mapper.
3 * Copyright (C) 2002,2003,2004 Applera Corporation. All rights reserved.
4 * Author: Nathan Edwards
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received (LICENSE.txt) a copy of the GNU General Public
17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *************************************************************************/
20
21 #include "fileStar.h"
22 #include <iostream>
23
24 #if !defined(NO_STD_NAMESPACE)
25 using namespace std;
26 #endif
27
28 FileStarFile::FileStarFile() {
29 _size = _pos = 0;
30 }
31
32 FileStarFile::FileStarFile(std::string const &infile) {
33 _size = _pos = 0;
34 openBuf(infile);
35 }
36
37 void FileStarFile::openBuf(std::string const &fname) {
38
39 struct stat st;
40 if (stat(fname.c_str(),&st)<0) {
41 perror("FileStarFile::openBuf:stat");
42 exit(1);
43 }
44 _size = st.st_size;
45
46 #if ! defined(__CYGWIN__)
47 bufF = fopen(fname.c_str(),"r");
48 #else
49 bufF = fopen(fname.c_str(),"rb");
50 #endif
51 if (!bufF) {
52 cerr << "couldn't open input file: " << fname << endl;
53 exit(1);
54 }
55 }
56
57 FileStarFile::~FileStarFile() {
58 fclose(bufF);
59 _size=_pos=0;
60 }
61
62 void FileStarFile::reset() {
63 rewind(bufF);
64 _pos=0;
65 }
66
67 FILE_POSITION_TYPE FileStarFile::getPos() const {
68 return _pos;
69 }
70
71 void FileStarFile::setPos(FILE_POSITION_TYPE p) {
72 FSEEK(bufF,p,SEEK_SET);
73 _pos = p;
74 }
75
76 unsigned char FileStarFile::getCharacter(void) {
77 _pos++;
78 return fgetc(bufF);
79 }