The Boost.Filesystem library provides facilities to manipulate files and directories, and the paths that identify them.
Questions tagged [boost-filesystem]
353 questions
7
votes
2 answers
Why does boost::filesystem::path::string() return by value on Windows and by reference on POSIX?
From boost/filesystem/path.hpp:
# ifdef BOOST_WINDOWS_API
const std::string string() const
{
[...]
}
# else // BOOST_POSIX_API
// string_type is std::string, so there is no conversion
const std::string& string()…

alex
- 2,252
- 4
- 23
- 34
7
votes
2 answers
C++: All boost path operations segfault (OSX / GCC)
I am getting consistent segfaults with almost any operation I am trying to perform with boost path.
(Edit: It appears that all segfaulting functions are related to current_path())
Sample program:
#include
#include…

Amir Abiri
- 8,847
- 11
- 41
- 57
7
votes
2 answers
C++: How do I ignore the first directory path when comparing paths in boost::filesystem?
I'm trying to compare two directories and find what files are different inside. So I'm using a boost::filesystem::recursive_directory_iterator to add all contents of each directory to respective vectors. Then I sort each vector alphabetically and…

Jonathan
- 752
- 1
- 9
- 19
7
votes
2 answers
Traversing a directory with boost::filesystem without throwing exceptions
I have a path to the directory, and I want to traverse through all of its sub-directories, collecting files' pathes by the way.
namespace fs = boost::filesystem;
std::vector traverse_if_directory(fs::path& f) {
std::vector…

Joker_vD
- 3,715
- 1
- 28
- 42
7
votes
2 answers
Is boost::filesystem::directory_iterator invalidated by deletion?
I am iterating through a directory, and when an item matches some criteria, I delete it. Can I do it safely from within the loop, or to I have to save paths in an array and delete then later?
I did not find a relevant information in…

eudoxos
- 18,545
- 10
- 61
- 110
6
votes
2 answers
Missing Exception in Boost Process
I want to use Boost Process eventhough it has not been release yet. I did
svn co svn://svn.boost.org/svn/boost/sandbox/process/ boost-process
added boost-process to include path (-I) and #included but compilation complains about…

Nordlöw
- 11,838
- 10
- 52
- 99
6
votes
2 answers
How to check if path leads to executable file?
I try to create some kind of file browser. I want to know if file under path is executable in a cross-platform way.
How to do such thing with boost::filesystem?

Rella
- 65,003
- 109
- 363
- 636
6
votes
3 answers
how to subtract one path from another?
So... I have a base path and a new path.New path contains in it base path. I need to see what is different in new path. Like we had /home/ and new path is /home/apple/one and I need to get from it apple/one. note - when I would create some path from…

Rella
- 65,003
- 109
- 363
- 636
6
votes
2 answers
boost::filesystem recursively getting size of each file
Why does this code throw an error when the argument is a directory?
Using boost::recursive_directory_iterator and using std::cout statements, I can see that it never prints a directory; only files. But, when I try to call…

cppxor2arr
- 295
- 2
- 12
6
votes
2 answers
Why autoconf isn't detecting boost properly?
I am using autoconf to detect boost libraries, with the support of the autoconf-archive macros and they work fine with system-wide boost libraries, but fail if I manually compile boost in my home directory:
sb@stephane:~/devel/spectra2$ ./configure…

Kjir
- 4,437
- 4
- 29
- 34
6
votes
1 answer
Boost::file_system: Checking error codes
Although I'm using C++11, this question is boost-related, since I'm processing errors from boost::file_system.
In the following situation:
try {
// If p2 doesn't exists, canonical throws an exception
// of No_such_file_or_directory
…

ABu
- 10,423
- 6
- 52
- 103
6
votes
1 answer
How can I determine the owner of a file or directory using boost filesystem?
Possible Duplicate:
Get file's owner and group using boost
I'd like to use boost::filesystem to determine which files and directories/ folders are owned by a particular user.
I need to do this on both Linux (ext3) and Windows (NTFS)…

pugdogfan
- 311
- 3
- 10
5
votes
2 answers
boost filesystem::path constructor std::length_error
i am trying to iterate over a directory using Boost.Filesystem library.
The problem is that when i try to instantiate a path object, i get an std::length_error with the message "string too long" with strings of any length, even for example…

Luca Piccinelli
- 379
- 1
- 17
5
votes
1 answer
Problem linking Boost.Filesystem statically to a shared library
I'm building a shared library with GCC 4.5.2 and Boost 1.46.1 (compiled with --build-type=complete) and this is a command from Makefile which does the linkage part:
$(CXX) -static -lboost_filesystem -fpic -shared $^ -o $@
Everything compiles fine…

szx
- 6,433
- 6
- 46
- 67
5
votes
2 answers
What is BOOST_FILESYSTEM_VERSION 3 analog for BOOST_FILESYSTEM_VERSION 2 path.native_file_string()?
So I try to port my old project (from boost 1.44 to 1.61) I found out that there is no path.native_file_string() in boost::filesystem v3...
So what is analog for path.native_file_string() in boost::filesystem v3? (I do not want to use v2 any more…

Rella
- 65,003
- 109
- 363
- 636