Skip to content

Commit

Permalink
Moved directory tools to separate files. Reworked readdir_r support.
Browse files Browse the repository at this point in the history
Directory iteration components were moved to separate files to simplify
maintenance of operations.hpp/cpp.

directory_iterator implementation on POSIX platforms has been reworked
to only allocate internal buffer when readdir_r is used. When readdir
is used, the dirent structure returned by readdir is used directly, which
eliminates the potential of buffer overrun in case if some directory name
exceeds the buffer size. This also removes the need to copy dirent members
into the buffer, which improves performance and simplifies maintenance.

For buffer size we now use the max path size as opposed to max filename
size. This is done to minimize the possibility of buffer overruns when
readdir_r is used.

On Windows, use Boost.WinAPI to configure the default target Windows version.
This removes WINVER and _WIN32_WINNT defines in Boost.Filesystem as these
macros should be defined by Boost.WinAPI now.

Additionally, exception.hpp and directory.hpp includes in operations.hpp are
marked as deprecated as operations.hpp do not need those components. Users
are encouraged to include the new headers explicitly in their code, as needed.
  • Loading branch information
Lastique committed Aug 1, 2019
1 parent 400f025 commit c758552
Show file tree
Hide file tree
Showing 14 changed files with 1,861 additions and 1,691 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ project( BoostFilesystem )
add_library( boost_filesystem
src/codecvt_error_category.cpp
src/operations.cpp
src/directory.cpp
src/path.cpp
src/path_traits.cpp
src/portability.cpp
Expand Down
1 change: 1 addition & 0 deletions build/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ project boost/filesystem
SOURCES =
codecvt_error_category
exception
directory
operations
path
path_traits
Expand Down
9 changes: 5 additions & 4 deletions example/simple_ls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
# define BOOST_SYSTEM_NO_DEPRECATED
#endif

#include "boost/filesystem/operations.hpp"
#include "boost/filesystem/path.hpp"
#include "boost/progress.hpp"
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/directory.hpp>
#include <boost/filesystem/path.hpp>
#include <iostream>

namespace fs = boost::filesystem;
Expand Down Expand Up @@ -85,7 +85,8 @@ int main(int argc, char* argv[])
}
else // must be a file
{
std::cout << "\nFound: " << p << "\n";
std::cout << "\nFound: " << p << "\n";
}

return 0;
}
1 change: 1 addition & 0 deletions include/boost/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# include <boost/filesystem/config.hpp>
# include <boost/filesystem/path.hpp>
# include <boost/filesystem/exception.hpp>
# include <boost/filesystem/directory.hpp>
# include <boost/filesystem/operations.hpp>
# include <boost/filesystem/file_status.hpp>
# include <boost/filesystem/convenience.hpp>
Expand Down
Loading

0 comments on commit c758552

Please sign in to comment.