| 136 | | try { |
|---|
| 137 | | delete []finalpos; |
|---|
| 138 | | finalpos = new char[]; |
|---|
| 139 | | filelist = [(self.finalpos, 'finalpos')]; |
|---|
| 140 | | for(var, filename in filelist) { |
|---|
| 141 | | file = open(os.path.join(datap[0], filename+datap[1]+'.db'), 'rb'); |
|---|
| 142 | | while (1) { |
|---|
| 143 | | try var.fromfile(file, 1000000); |
|---|
| 144 | | except EOFError break; |
|---|
| 145 | | } |
|---|
| 146 | | } |
|---|
| 147 | | file.close(); |
|---|
| | 138 | String fn = ... "/finalpos" ...; |
|---|
| | 139 | ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| | 140 | if (file.is_open()) { |
|---|
| | 141 | ifstream::pos_type size = file.tellg(); |
|---|
| | 142 | delete [] finalpos; |
|---|
| | 143 | finalpos = new char[size]; |
|---|
| | 144 | file.seekg (0, ios::beg); |
|---|
| | 145 | file.read (memblock, size); |
|---|
| | 146 | file.close(); |
|---|
| 331 | | |
|---|
| 332 | | filelist = [(self.posTable, 'posTable'), (self.mainlistArr, 'lists'), |
|---|
| 333 | | (self.finalposC, 'finalposC')]; |
|---|
| 334 | | for(var, filename in filelist) { |
|---|
| 335 | | file = open(os.path.join(datap[0], filename + datap[1] + '.db'), 'wb'); |
|---|
| 336 | | var.tofile(file); |
|---|
| 337 | | file.close(); |
|---|
| 338 | | } |
|---|
| 339 | | } |
|---|
| 340 | | |
|---|
| 341 | | Algo_movelist::filelist = ['posTable', 'lists', 'finalposC']; |
|---|
| 342 | | |
|---|
| 343 | | |
|---|
| | 331 | // FIXME |
|---|
| | 332 | extract datap0, datap1 from datap |
|---|
| | 333 | |
|---|
| | 334 | String fn = datap0 + "/posTable" + datap1 + ".db"; // FIXME: linux specific!? |
|---|
| | 335 | ofstream file(fn, ios::out|ios::trunc|ios::binary) // FIXME: careful with ios::trunc |
|---|
| | 336 | file.write(posTable, posTableSize); // FIXME: posTable is vector, posTableSize does not exist |
|---|
| | 337 | file.close(); |
|---|
| | 338 | |
|---|
| | 339 | fn = datap0 + "/lists" + datap1 + ".db"; // FIXME: linux specific!? |
|---|
| | 340 | file(fn, ios::out|ios::trunc|ios::binary) // FIXME: careful with ios::trunc |
|---|
| | 341 | file.write(mainlistArr, mainlistArrSize); // FIXME: mainlistArr is vector!, mainlistArrSize does not exist |
|---|
| | 342 | file.close(); |
|---|
| | 343 | |
|---|
| | 344 | fn = datap0 + "/finalposC" + datap1 + ".db"; // FIXME: linux specific!? |
|---|
| | 345 | file(fn, ios::out|ios::trunc|ios::binary) // FIXME: careful with ios::trunc |
|---|
| | 346 | file.write(finalposC, finalposCSize); |
|---|
| | 347 | file.close(); |
|---|
| | 348 | } |
|---|
| 347 | | // FIXME |
|---|
| 348 | | |
|---|
| 349 | | try { |
|---|
| 350 | | posTable = array('L'); |
|---|
| 351 | | mainlistArr = array('B'); |
|---|
| 352 | | finalposC = array('B'); |
|---|
| 353 | | filelist = [(self.mainlistArr, 'lists'), (self.posTable, 'posTable'), |
|---|
| 354 | | (self.finalposC, 'finalposC')]; |
|---|
| 355 | | for (var, filename in filelist) { |
|---|
| 356 | | file = open(os.path.join(datap[0], filename+datap[1]+'.db'), 'rb'); |
|---|
| 357 | | while (1) { |
|---|
| 358 | | try var.fromfile(file, 1000000); |
|---|
| 359 | | except EOFError break; |
|---|
| 360 | | } |
|---|
| 361 | | } |
|---|
| 362 | | file.close(); |
|---|
| | 352 | String fn = ... "/finalposC" ...; // FIXME |
|---|
| | 353 | ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| | 354 | if (file.is_open()) { |
|---|
| | 355 | ifstream::pos_type size = file.tellg(); |
|---|
| | 356 | delete [] finalposC; |
|---|
| | 357 | finalposC = new char[size]; |
|---|
| | 358 | file.seekg (0, ios::beg); |
|---|
| | 359 | file.read (memblock, size); |
|---|
| | 360 | file.close(); |
|---|
| | 361 | } |
|---|
| | 362 | else { |
|---|
| | 363 | cout << "Unable to open file"; |
|---|
| | 364 | return 0; |
|---|
| | 365 | } |
|---|
| | 366 | String fn = ... "/lists" ...; // FIXME |
|---|
| | 367 | ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| | 368 | if (file.is_open()) { |
|---|
| | 369 | ifstream::pos_type size = file.tellg(); |
|---|
| | 370 | delete [] mainlistArr; |
|---|
| | 371 | mainlistArr = new char[size]; |
|---|
| | 372 | file.seekg (0, ios::beg); |
|---|
| | 373 | file.read (memblock, size); |
|---|
| | 374 | file.close(); |
|---|
| | 375 | } |
|---|
| | 376 | else { |
|---|
| | 377 | cout << "Unable to open file"; |
|---|
| | 378 | return 0; |
|---|
| | 379 | } |
|---|
| | 380 | String fn = ... "/posTable" ...; // FIXME |
|---|
| | 381 | ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| | 382 | if (file.is_open()) { |
|---|
| | 383 | ifstream::pos_type size = file.tellg(); |
|---|
| | 384 | delete [] posTable; |
|---|
| | 385 | posTable = new char[size]; // FIXME: not a char array??? |
|---|
| | 386 | file.seekg (0, ios::beg); |
|---|
| | 387 | file.read (memblock, size); |
|---|
| | 388 | file.close(); |
|---|
| 793 | | int Algo_hash::retrieve_db(datap) { |
|---|
| 794 | | try { |
|---|
| 795 | | self.hashT = array('l'); |
|---|
| 796 | | self.hash = array('B'); |
|---|
| 797 | | filelist = [(self.hash, self.filename), (self.hashT, self.filename + 'T')]; |
|---|
| 798 | | for (var, filename in filelist) { |
|---|
| 799 | | file = open(os.path.join(datap[0], filename+datap[1]+'.db'), 'rb'); |
|---|
| 800 | | while (1) { |
|---|
| 801 | | try var.fromfile(file, 1000000); |
|---|
| 802 | | except EOFError break; |
|---|
| 803 | | } |
|---|
| 804 | | } |
|---|
| 805 | | file.close(); |
|---|
| 806 | | return 1; |
|---|
| 807 | | } |
|---|
| 808 | | except IOError return 0; |
|---|
| | 821 | int Algo_hash::retrieve_db(PyObject* datap) { |
|---|
| | 822 | String fn = ... filename ...; // FIXME |
|---|
| | 823 | ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| | 824 | if (file.is_open()) { |
|---|
| | 825 | ifstream::pos_type size = file.tellg(); |
|---|
| | 826 | delete [] hash; |
|---|
| | 827 | hash = new char[size]; // FIXME: not a char array? |
|---|
| | 828 | file.seekg (0, ios::beg); |
|---|
| | 829 | file.read (memblock, size); |
|---|
| | 830 | file.close(); |
|---|
| | 831 | } |
|---|
| | 832 | else { |
|---|
| | 833 | cout << "Unable to open file"; |
|---|
| | 834 | return 0; |
|---|
| | 835 | } |
|---|
| | 836 | String fn = ... filename + "T" ...; // FIXME |
|---|
| | 837 | ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| | 838 | if (file.is_open()) { |
|---|
| | 839 | ifstream::pos_type size = file.tellg(); |
|---|
| | 840 | delete [] hashT; |
|---|
| | 841 | hashT = new char[size]; |
|---|
| | 842 | file.seekg (0, ios::beg); |
|---|
| | 843 | file.read (memblock, size); |
|---|
| | 844 | file.close(); |
|---|
| | 845 | } |
|---|
| | 846 | else { |
|---|
| | 847 | cout << "Unable to open file"; |
|---|
| | 848 | return 0; |
|---|
| | 849 | } |
|---|
| | 850 | return 0; |
|---|
| 1125 | | |
|---|
| 1126 | | file = open(os.path.join(datap[0], 'movesarr' + datap[1] + '.db'), 'wb'); |
|---|
| 1127 | | self.movesArr.tofile(file); |
|---|
| | 1161 | // FIXME |
|---|
| | 1162 | extract datap0, datap1 from datap |
|---|
| | 1163 | |
|---|
| | 1164 | String fn = datap0 + "/movesarr" + datap1 + ".db"; // FIXME: linux specific!? |
|---|
| | 1165 | ofstream file(fn, ios::out|ios::trunc|ios::binary) // FIXME: careful with ios::trunc |
|---|
| | 1166 | file.write(movesArr, movesArrSize); |
|---|
| | 1167 | file.close(); |
|---|
| | 1168 | |
|---|
| | 1169 | fn = datap0 + "/moveints" + datap1 + ".db"; // FIXME: linux specific!? |
|---|
| | 1170 | file(fn, ios::out|ios::trunc|ios::binary) // FIXME: careful with ios::trunc |
|---|
| | 1171 | file.write(moveIntsArr, moveIntsArrSize); |
|---|
| 1139 | | try { |
|---|
| 1140 | | self.movesArr = array('L'); |
|---|
| 1141 | | self.moveIntsArr = array('L'); |
|---|
| 1142 | | filelist = [(self.movesArr, 'movesarr'), (self.moveIntsArr, 'moveints')]; |
|---|
| 1143 | | for(var, filename in filelist) { |
|---|
| 1144 | | file = open(os.path.join(datap[0], filename+datap[1]+'.db'), 'rb'); |
|---|
| 1145 | | while (1) { |
|---|
| 1146 | | try var.fromfile(file, 1000000); |
|---|
| 1147 | | except EOFError break; |
|---|
| 1148 | | } |
|---|
| 1149 | | } |
|---|
| 1150 | | file.close() |
|---|
| 1151 | | return 1; |
|---|
| 1152 | | } |
|---|
| 1153 | | except IOError return 0; |
|---|
| | 1178 | String fn = ... "/movesarr" ...; // FIXME |
|---|
| | 1179 | ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| | 1180 | if (file.is_open()) { |
|---|
| | 1181 | ifstream::pos_type size = file.tellg(); |
|---|
| | 1182 | delete [] movesArr; |
|---|
| | 1183 | movesArr = new char[size]; // FIXME: not a char array? |
|---|
| | 1184 | file.seekg (0, ios::beg); |
|---|
| | 1185 | file.read (memblock, size); |
|---|
| | 1186 | file.close(); |
|---|
| | 1187 | } |
|---|
| | 1188 | else { |
|---|
| | 1189 | cout << "Unable to open file"; |
|---|
| | 1190 | return 0; |
|---|
| | 1191 | } |
|---|
| | 1192 | String fn = ... "/moveints" ...; // FIXME |
|---|
| | 1193 | ifstream file (fn, ios::in|ios::binary|ios::ate); |
|---|
| | 1194 | if (file.is_open()) { |
|---|
| | 1195 | ifstream::pos_type size = file.tellg(); |
|---|
| | 1196 | delete [] moveIntsArr; |
|---|
| | 1197 | moveIntsArr = new char[size]; // FIXME: not a char array? |
|---|
| | 1198 | file.seekg (0, ios::beg); |
|---|
| | 1199 | file.read (memblock, size); |
|---|
| | 1200 | file.close(); |
|---|
| | 1201 | } |
|---|
| | 1202 | else { |
|---|
| | 1203 | cout << "Unable to open file"; |
|---|
| | 1204 | return 0; |
|---|
| | 1205 | } |
|---|
| | 1206 | return 0; |
|---|