Forráskód Böngészése

2009-02-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Open file in binary mode.
	* src/CookieStorage.cc
	* src/DHTSetup.cc
	* src/DHTUtil.cc
	* src/Netrc.cc
	* src/NsCookieParser.cc
	* src/ProtocolDetector.cc
	* src/RequestGroupMan.cc
	* src/Signature.cc
	* src/bencode.cc
	* src/download_helper.cc
	* src/option_processing.cc
	* test/CookieParserTest.cc
	* test/DefaultBtProgressInfoFileTest.cc
	* test/FileTest.cc
	* test/GZipDecoderTest.cc
	* test/RequestGroupManTest.cc
	* test/SignatureTest.cc
	* test/SingleFileAllocationIteratorTest.cc
	* test/UriListParserTest.cc
Tatsuhiro Tsujikawa 16 éve
szülő
commit
34d7cd7a70

+ 23 - 0
ChangeLog

@@ -1,3 +1,26 @@
+2009-02-13  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Open file in binary mode.
+	* src/CookieStorage.cc
+	* src/DHTSetup.cc
+	* src/DHTUtil.cc
+	* src/Netrc.cc
+	* src/NsCookieParser.cc
+	* src/ProtocolDetector.cc
+	* src/RequestGroupMan.cc
+	* src/Signature.cc
+	* src/bencode.cc
+	* src/download_helper.cc
+	* src/option_processing.cc
+	* test/CookieParserTest.cc
+	* test/DefaultBtProgressInfoFileTest.cc
+	* test/FileTest.cc
+	* test/GZipDecoderTest.cc
+	* test/RequestGroupManTest.cc
+	* test/SignatureTest.cc
+	* test/SingleFileAllocationIteratorTest.cc
+	* test/UriListParserTest.cc
+
 2009-02-13  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Removed operator[] because it is ambiguous with built-in []

+ 1 - 1
src/CookieStorage.cc

@@ -142,7 +142,7 @@ void CookieStorage::load(const std::string& filename)
 {
   char header[16]; // "SQLite format 3" plus \0
   {
-    std::ifstream s(filename.c_str());
+    std::ifstream s(filename.c_str(), std::ios::binary);
     s.get(header, sizeof(header));
     if(s.bad()) {
       throw RecoverableException

+ 1 - 1
src/DHTSetup.cc

@@ -96,7 +96,7 @@ void DHTSetup::setup(std::deque<Command*>& commands,
     std::string dhtFile = option->get(PREF_DHT_FILE_PATH);
     if(File(dhtFile).isFile()) {
       try {
-	std::ifstream in(dhtFile.c_str());
+	std::ifstream in(dhtFile.c_str(), std::ios::binary);
 	in.exceptions(std::ios::failbit);
 	deserializer.deserialize(in);
 	localNode = deserializer.getLocalNode();

+ 1 - 1
src/DHTUtil.cc

@@ -64,7 +64,7 @@ void DHTUtil::generateRandomData(unsigned char* data, size_t length)
     }
   }
 #else
-  std::ifstream i("/dev/urandom");
+  std::ifstream i("/dev/urandom", std::ios::binary);
   i.read(data, length);
 #endif // HAVE_LIBSSL
 }

+ 1 - 1
src/Netrc.cc

@@ -78,7 +78,7 @@ void Netrc::skipMacdef(std::ifstream& f) const
 void Netrc::parse(const std::string& path)
 {
   authenticators.clear();
-  std::ifstream f(path.c_str());
+  std::ifstream f(path.c_str(), std::ios::binary);
   
   if(!f) {
     throw RecoverableException

+ 1 - 1
src/NsCookieParser.cc

@@ -73,7 +73,7 @@ static Cookie parseNsCookie(const std::string& nsCookieStr)
 
 std::deque<Cookie> NsCookieParser::parse(const std::string& filename)
 {
-  std::ifstream s(filename.c_str());
+  std::ifstream s(filename.c_str(), std::ios::binary);
   if(!s) {
     throw RecoverableException
       (StringFormat("Failed to open file %s", filename.c_str()).str());

+ 2 - 2
src/ProtocolDetector.cc

@@ -55,7 +55,7 @@ bool ProtocolDetector::guessTorrentFile(const std::string& uri) const
   if(!File(uri).isFile()) {
     return false;
   }
-  std::ifstream in(uri.c_str());
+  std::ifstream in(uri.c_str(), std::ios::binary);
   if(in) {
     char head;
     in >> head;
@@ -70,7 +70,7 @@ bool ProtocolDetector::guessMetalinkFile(const std::string& uri) const
   if(!File(uri).isFile()) {
     return false;
   }
-  std::ifstream in(uri.c_str());
+  std::ifstream in(uri.c_str(), std::ios::binary);
   if(in) {
     char head[6];
     in >> std::setw(6) >> head;

+ 2 - 2
src/RequestGroupMan.cc

@@ -573,7 +573,7 @@ bool RequestGroupMan::addServerStat(const SharedHandle<ServerStat>& serverStat)
 
 bool RequestGroupMan::loadServerStat(const std::string& filename)
 {
-  std::ifstream in(filename.c_str());
+  std::ifstream in(filename.c_str(), std::ios::binary);
   if(!in) {
     _logger->error(MSG_OPENING_READABLE_SERVER_STAT_FILE_FAILED, filename.c_str());
     return false;
@@ -590,7 +590,7 @@ bool RequestGroupMan::loadServerStat(const std::string& filename)
 bool RequestGroupMan::saveServerStat(const std::string& filename) const
 {
   std::string tempfile = filename+"__temp";
-  std::ofstream out(tempfile.c_str());
+  std::ofstream out(tempfile.c_str(), std::ios::binary);
   if(!out) {
     _logger->error(MSG_OPENING_WRITABLE_SERVER_STAT_FILE_FAILED,
 		   tempfile.c_str());

+ 1 - 1
src/Signature.cc

@@ -77,7 +77,7 @@ bool Signature::save(const std::string& filepath) const
   if(File(filepath).exists()) {
     return false;
   }
-  std::ofstream out(filepath.c_str());
+  std::ofstream out(filepath.c_str(), std::ios::binary);
   try {
     out.exceptions(std::ios::failbit);
     out << _body;

+ 1 - 1
src/bencode.cc

@@ -439,7 +439,7 @@ BDE decode(const unsigned char* data, size_t length) throw(RecoverableException)
 
 BDE decodeFromFile(const std::string& filename) throw(RecoverableException)
 {
-  std::ifstream f(filename.c_str());
+  std::ifstream f(filename.c_str(), std::ios::binary);
   if(f) {
     return decode(f);
   } else {

+ 1 - 1
src/download_helper.cc

@@ -300,7 +300,7 @@ void createRequestGroupForUriList
 	(StringFormat(EX_FILE_OPEN, op->get(PREF_INPUT_FILE).c_str(),
 		      "No such file").str());
     }
-    std::ifstream f(op->get(PREF_INPUT_FILE).c_str());
+    std::ifstream f(op->get(PREF_INPUT_FILE).c_str(), std::ios::binary);
     createRequestGroupForUriList(result, op, f);
   }
 }

+ 1 - 1
src/option_processing.cc

@@ -126,7 +126,7 @@ void option_processing(Option& op, std::deque<std::string>& uris,
 	ucfname;
 
       if(File(cfname).isFile()) {
-	std::ifstream cfstream(cfname.c_str());
+	std::ifstream cfstream(cfname.c_str(), std::ios::binary);
 	try {
 	  oparser.parse(op, cfstream);
 	} catch(OptionHandlerException& e) {

+ 1 - 1
test/CookieParserTest.cc

@@ -78,7 +78,7 @@ void CookieParserTest::testParse()
 
 void CookieParserTest::testParse_file()
 {
-  std::ifstream f("cookietest.txt");
+  std::ifstream f("cookietest.txt", std::ios::binary);
 
   Cookies cookies = CookieParser().parse(f);
 

+ 2 - 2
test/DefaultBtProgressInfoFileTest.cc

@@ -235,7 +235,7 @@ void DefaultBtProgressInfoFileTest::testSave()
   infoFile.save();
 
   // read and validate
-  std::ifstream in(infoFile.getFilename().c_str());
+  std::ifstream in(infoFile.getFilename().c_str(), std::ios::binary);
 
   //in.exceptions(ios::failbit);
 
@@ -468,7 +468,7 @@ void DefaultBtProgressInfoFileTest::testSave_nonBt()
   infoFile.save();
   
   // read and validate
-  std::ifstream in(infoFile.getFilename().c_str());
+  std::ifstream in(infoFile.getFilename().c_str(), std::ios::binary);
 
   //in.exceptions(ios::failbit);
 

+ 1 - 1
test/FileTest.cc

@@ -194,7 +194,7 @@ void FileTest::testGetBasename()
 void FileTest::testRenameTo()
 {
   std::string fname = "FileTest_testRenameTo.txt";
-  std::ofstream of(fname.c_str());
+  std::ofstream of(fname.c_str(), std::ios::binary);
   of.close();
 
   File f(fname);

+ 2 - 2
test/GZipDecoderTest.cc

@@ -34,8 +34,8 @@ void GZipDecoderTest::testDecode()
   std::string outfile("/tmp/aria2_GZipDecoderTest_testDecode");
 
   char buf[4096];
-  std::ifstream in("gzip_decode_test.gz");
-  std::ofstream out(outfile.c_str());
+  std::ifstream in("gzip_decode_test.gz", std::ios::binary);
+  std::ofstream out(outfile.c_str(), std::ios::binary);
   while(in) {
     in.read(buf, sizeof(buf));
 

+ 1 - 1
test/RequestGroupManTest.cc

@@ -93,7 +93,7 @@ void RequestGroupManTest::testSaveServerStat()
 void RequestGroupManTest::testLoadServerStat()
 {
   File f("/tmp/aria2_RequestGroupManTest_testLoadServerStat");
-  std::ofstream o(f.getPath().c_str());
+  std::ofstream o(f.getPath().c_str(), std::ios::binary);
   o << "host=localhost, protocol=http, dl_speed=0, last_updated=1219505257,"
     << "status=OK";
   o.close();

+ 1 - 1
test/SignatureTest.cc

@@ -36,7 +36,7 @@ void SignatureTest::testSave()
   } 
   CPPUNIT_ASSERT(sig.save(filepath));
   {
-    std::ifstream in(filepath.c_str());
+    std::ifstream in(filepath.c_str(), std::ios::binary);
     std::string fileContent;
     in >> fileContent;
     CPPUNIT_ASSERT_EQUAL(sig.getBody(), fileContent);

+ 1 - 1
test/SingleFileAllocationIteratorTest.cc

@@ -27,7 +27,7 @@ void SingleFileAllocationIteratorTest::testAllocate()
   std::string dir = "/tmp";
   std::string fname = "aria2_SingleFileAllocationIteratorTest_testAllocate";
   std::string fn = dir+"/"+fname;
-  std::ofstream of(fn.c_str());
+  std::ofstream of(fn.c_str(), std::ios::binary);
   of << "0123456789";
   of.close();
 

+ 1 - 1
test/UriListParserTest.cc

@@ -40,7 +40,7 @@ std::string UriListParserTest::list2String(const std::deque<std::string>& src)
 
 void UriListParserTest::testHasNext()
 {
-  std::ifstream in("filelist1.txt");
+  std::ifstream in("filelist1.txt", std::ios::binary);
 
   UriListParser flp(in);