2 Copyright (C) 2008 Steve Thomas <SMT837784@yahoo.com>
4 This file is part of RT Perfecter v0.0.
6 RT Perfecter v0.0 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 3 of the License, or
9 (at your option) any later version.
11 RT Perfecter v0.0 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.
16 You should have received a copy of the GNU General Public License
17 along with RT Perfecter v0.0. If not, see <http://www.gnu.org/licenses/>.
25 RTWrite::RTWrite(char *fileName, int maxChainsPerFile)
27 unsigned int len = strlen(fileName);
29 m_file = new char[len + 1];
30 m_fileTemp = new char[len + 21];
31 strncpy(m_file, fileName, len);
36 m_chainsPerFile = maxChainsPerFile;
46 sprintf(m_fileTemp, m_file, m_curFileChains, m_curFile);
47 if (rename("temp.rt", m_fileTemp) != 0)
57 if (m_fileTemp != NULL)
63 void RTWrite::writeChain(RTChainCP *chain)
65 if(chain->startpt == 0 || chain->endpt == 0)
68 if (m_prevEndpt > chain->endpt)
70 printf("**** Error writeChain(): Tring to write unsorted data. (%llu > %llu)****\n", m_prevEndpt, chain->endpt);
75 if(chain->startpt > 0x0000ffffffffffffI64)
77 if(chain->startpt > 0x0000ffffffffffff11u)
80 printf("**** Error writeChain(): Prefix is bigger than 6 bytes. (%llx) %u chains ****\n", chain->startpt, m_curFileChains);
87 m_pFile = fopen("temp.rt", "wb");
94 if (fwrite((void*)chain, 16, 1, m_pFile) != 1)
99 if (fwrite((void*)&chain->checkpoint, 2, 1, m_pFile) != 1)
106 if (m_curFileChains >= m_chainsPerFile)
110 sprintf(m_fileTemp, m_file, m_curFileChains, m_curFile);
111 if (rename("temp.rt", m_fileTemp) != 0)