Closed cybaol closed 10 months ago
Hi, my idea was not to replace every boost::filesystem::exists
with std::ifstream(filename).good()
, but only where a std::ifstream
is opened for reading anyways. For example in io/src/ifs_io.cpp: after the check with empty
and exists
, the file is opened anyways with a std::ifstream
, so we could remove boost::filesystem::exists
there and add !fs.good()
after opening.
In other cases, where the file is not opened as a std::ifstream
immediately afterwards, I would not try to replace boost::filesystem::exists
with std::ifstream(filename).good()
. Opening a filestream just to check whether a file exists seems kind of wasteful, and I would assume that Boost's exists is more elegant.
I have come to the conclusion that it does not seem possible to replace everything from boost::filesystem in PCL without using std::filesystem (C++17), at least not in an easy and elegant way. So I think it would be best to focus more on idea 3 from the issue (using both boost::filesystem and std::filesystem, and selecting the appropriate one with the preprocessor).
I believe it would make sense to first check whether the file_name
is empty, before opening the filestream. That way we have made sure that the string contains something. We could also change the error message, for example "No file name given!" instead of "Could not find file ..." (or similar)
Task 3 of #5881