aboutsummaryrefslogtreecommitdiff
path: root/paludis/repositories/unavailable/unavailable_repository_file.cc
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-02-09 21:35:39 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-02-09 21:35:39 +0000
commit8772b7a5c74c3254a53e70a922e9e0a2bc1c09c3 (patch)
treedb429b81a81135f285ed2ff16c873d65f09a813f /paludis/repositories/unavailable/unavailable_repository_file.cc
parentd946b89871e6dad288440d5fd1ad29bfcd1dff1d (diff)
downloadpaludis-8772b7a5c74c3254a53e70a922e9e0a2bc1c09c3.tar.gz
paludis-8772b7a5c74c3254a53e70a922e9e0a2bc1c09c3.tar.xz
Avoid std::ifstream and std::ofstream.
Unfortunately std::ifstream and std::ofstream are allowed to fail in unobvious ways when given a duff file. In particular, gcc won't error out when a std::ifstream is created for a directory until the first read occurs. So we write our own stream buffer classes that do error checking and throw useful exceptions on error, and use those instead.
Diffstat (limited to 'paludis/repositories/unavailable/unavailable_repository_file.cc')
-rw-r--r--paludis/repositories/unavailable/unavailable_repository_file.cc8
1 files changed, 3 insertions, 5 deletions
diff --git a/paludis/repositories/unavailable/unavailable_repository_file.cc b/paludis/repositories/unavailable/unavailable_repository_file.cc
index dc406e05e..8c395e690 100644
--- a/paludis/repositories/unavailable/unavailable_repository_file.cc
+++ b/paludis/repositories/unavailable/unavailable_repository_file.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -25,11 +25,11 @@
#include <paludis/util/log.hh>
#include <paludis/util/simple_parser.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/safe_ifstream.hh>
#include <paludis/name.hh>
#include <paludis/version_spec.hh>
#include <paludis/literal_metadata_key.hh>
#include <list>
-#include <fstream>
using namespace paludis;
using namespace paludis::unavailable_repository;
@@ -69,9 +69,7 @@ UnavailableRepositoryFile::end() const
void
UnavailableRepositoryFile::_load(const FSEntry & f)
{
- std::ifstream file(stringify(f).c_str());
- if (! file)
- throw UnavailableRepositoryConfigurationError("Cannot read '" + stringify(f) + "'");
+ SafeIFStream file(f);
std::string line;
while (std::getline(file, line))