X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=mothurout.cpp;h=3205ae794165a5b8c045c473403d8a66b1b54f90;hb=a150db3c2bfd7b76420048a1e94ebe397f2c6045;hp=c2ef698db8ed4d9c0769fcd4295a27a886c65bfc;hpb=81a56b9cea37749c5d4a7646a8d6148a4703bfc3;p=mothur.git diff --git a/mothurout.cpp b/mothurout.cpp index c2ef698..3205ae7 100644 --- a/mothurout.cpp +++ b/mothurout.cpp @@ -1154,7 +1154,43 @@ vector MothurOut::divideFile(string filename, int& proc) { exit(1); } } - +/**************************************************************************************************/ +int MothurOut::divideFile(string filename, int& proc, vector& files) { + try{ + + vector filePos = divideFile(filename, proc); + + for (int i = 0; i < (filePos.size()-1); i++) { + + //read file chunk + ifstream in; + openInputFile(filename, in); + in.seekg(filePos[i]); + unsigned long int size = filePos[(i+1)] - filePos[i]; + char* chunk = new char[size]; + in.read(chunk, size); + in.close(); + + //open new file + string fileChunkName = filename + "." + toString(i) + ".tmp"; + ofstream out; + openOutputFile(fileChunkName, out); + + out << chunk << endl; + out.close(); + delete[] chunk; + + //save name + files.push_back(fileChunkName); + } + + return 0; + } + catch(exception& e) { + errorOut(e, "MothurOut", "divideFile"); + exit(1); + } +} /***********************************************************************/ bool MothurOut::isTrue(string f){