[mlpack-git] [mlpack] LoadSave Unit test fails Windows x64 (#468)
Joseph Mariadassou
notifications at github.com
Sun Nov 8 22:58:23 EST 2015
Foolewing msessage sent to Conrad:
In Windows, the following program prints "Not good"when the input file is a text file with CR-LF line endings. More comments inline
`int main() {
std::fstream ifs;
ifs.open(fname, std::fstream::in);
if (ifs) {
std::istream& is = ifs;
auto loadType = arma::diskio::guess_file_type(is);
std::cout << "Load type" << loadType << std::endl;
// output is 0 unknown
// this is for the same reason the following program prints "Not Good"
// So I removed the is.good() test in guess_file_type.
// Now the loadType is 5 (raw_binary) because the last two characters are '\0'.
// I guess you have to read character by character until end of file.
is.clear(); // get length of file:
is.seekg(0, std::ios::end);
is.clear();
auto length= is.tellg();
is.seekg(0, is.beg);
// allocate memory:
char * buffer = new char[length];
// read data as a block:
is.read(buffer, length);
std::cout << length << " "<< (is.good()?"Good":"Not Good") << std::endl;
ifs.close();
// print content:
std::cout.write(buffer, length);
delete[] buffer;
}
return 0;
}`
---
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/issues/468#issuecomment-154912104
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20151108/7d01eeac/attachment-0001.html>
More information about the mlpack-git
mailing list