RAII for auto-closing file streams
Small fixes I didn't want to include in unrelated PRs.
There are a few left in `storage.cpp` but since it's a single function
in 600 lines of code, I didn't want to touch the mess. The others are
safe to remove, cucumber and test run on Finland gives 👍.
This commit is contained in:
@@ -94,7 +94,6 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
||||
util::SimpleLogger().Write(logWARNING) << timestamp_path << " not found";
|
||||
}
|
||||
getline(timestamp_stream, m_timestamp);
|
||||
timestamp_stream.close();
|
||||
}
|
||||
if (m_timestamp.empty())
|
||||
{
|
||||
@@ -144,7 +143,6 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
||||
BOOST_ASSERT((std::abs(m_coordinate_list->at(i).lat) >> 30) == 0);
|
||||
BOOST_ASSERT((std::abs(m_coordinate_list->at(i).lon) >> 30) == 0);
|
||||
}
|
||||
nodes_input_stream.close();
|
||||
|
||||
boost::filesystem::ifstream edges_input_stream(edges_file, std::ios::binary);
|
||||
unsigned number_of_edges = 0;
|
||||
@@ -172,8 +170,6 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
||||
++compressed;
|
||||
}
|
||||
}
|
||||
|
||||
edges_input_stream.close();
|
||||
}
|
||||
|
||||
void LoadCoreInformation(const boost::filesystem::path &core_data_file)
|
||||
@@ -224,7 +220,6 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
||||
geometry_stream.read((char *)&(m_geometry_list[0]),
|
||||
number_of_compressed_geometries * sizeof(extractor::CompressedEdgeContainer::CompressedEdge));
|
||||
}
|
||||
geometry_stream.close();
|
||||
}
|
||||
|
||||
void LoadRTree()
|
||||
@@ -250,7 +245,6 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << "list of street names is empty";
|
||||
}
|
||||
name_stream.close();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -194,7 +194,6 @@ unsigned readHSGRFromStream(const boost::filesystem::path &hsgr_file,
|
||||
hsgr_input_stream.read(reinterpret_cast<char *>(&edge_list[0]),
|
||||
number_of_edges * sizeof(EdgeT));
|
||||
}
|
||||
hsgr_input_stream.close();
|
||||
|
||||
return number_of_nodes;
|
||||
}
|
||||
|
||||
@@ -191,9 +191,6 @@ class StaticRTree
|
||||
processed_objects_count += current_leaf.object_count;
|
||||
}
|
||||
|
||||
// close leaf file
|
||||
leaf_node_file.close();
|
||||
|
||||
std::uint32_t processing_level = 0;
|
||||
while (1 < tree_nodes_in_level.size())
|
||||
{
|
||||
@@ -257,8 +254,6 @@ class StaticRTree
|
||||
BOOST_ASSERT_MSG(0 < size_of_tree, "tree empty");
|
||||
tree_node_file.write((char *)&size_of_tree, sizeof(std::uint32_t));
|
||||
tree_node_file.write((char *)&m_search_tree[0], sizeof(TreeNode) * size_of_tree);
|
||||
// close tree node file.
|
||||
tree_node_file.close();
|
||||
}
|
||||
|
||||
explicit StaticRTree(const boost::filesystem::path &node_file,
|
||||
@@ -287,7 +282,7 @@ class StaticRTree
|
||||
{
|
||||
tree_node_file.read((char *)&m_search_tree[0], sizeof(TreeNode) * tree_size);
|
||||
}
|
||||
tree_node_file.close();
|
||||
|
||||
// open leaf node file and store thread specific pointer
|
||||
if (!boost::filesystem::exists(leaf_file))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user