fw4spl
File.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 
8 #include "fwTest/File.hpp"
9 
10 #include <boost/filesystem/path.hpp>
11 #include <fstream>
12 
13 namespace fwTest
14 {
15 
16 bool File::contentEquals(const ::boost::filesystem::path &lfile, const ::boost::filesystem::path &rfile)
17 {
18  using namespace std;
19  const streambuf::int_type eof = streambuf::traits_type::eof();
20 
21  std::ifstream lstream(lfile.c_str());
22  std::ifstream rstream(rfile.c_str());
23 
24  streambuf * lbuf = lstream.rdbuf();
25  streambuf * rbuf = rstream.rdbuf();
26 
27  char lchar, rchar;
28  while (true)
29  {
30  lchar = lbuf->sbumpc();
31  rchar = rbuf->sbumpc();
32 
33  if (lchar == eof && rchar == eof)
34  {
35  return true;
36  }
37 
38  if (lchar != rchar || lchar == eof || rchar == eof )
39  {
40  break;
41  }
42  }
43 
44  return false;
45 }
46 
47 } //namespace fwTest
48 
STL namespace.
Definition: Data.hpp:15