boost-filesystem

boost::filesystem::path for unicode file paths?

Is there a way to use boost::filesystem::path with unicode file paths? In particular I'd like to use it with std::wstring instead of std::string. I'm working on the windows platform and I need to sometimes process a filepath that has a unicode char in it. ...

Should boost::filesystem::exists really throw an exception for removable media device with no media?

I've run into a bit of an odd circumstance while using boost::filesystem::exists. If you attempt to check for the existance of a file on a drive that isn't ready or has no media in it, it throws a basic_filesystem_error. As far as I'm concerned for most all uses of bfs::exists, if a drive isn't ready it means the file doesn't exist. I...

Is there an easier way to pop off a directory from boost::filesystem::path?

I have a relative path (e.g. "foo/bar/baz/quux.xml") and I want to pop a directory off so that I will have the subdirectory + file (e.g. "bar/baz/quux.xml"). You can do this with path iterators, but I was hoping there was something I was missing from the documentation or something more elegant. Below is the code that I used. #include ...

Boost Filesystem Library Visual C++ Compile Error

I'm having the following issue just trying to compile/run some of the example programs with the Boost Filesystem Library. I'm using MS-Visual C++ with Visual Studio .NET (2003). I've installed the Boost libraries, version 1.38 and 1.39 (just in case there was a version problem) using the BoostPro installers. If I just try to include...

Installing Boost libraries on Snow Leopard

I have followed the directions on the boost website. I have put the boost dir in the path. I still cannot compile a C++ program using the boost libraries. I am specifically trying to use the filesystem library. Any help is greatly appreciated. --TJB ...

Cross-platform library for manipulating Windows paths?

I am writing a cross-platform application that needs to inspect and manipulate Windows-paths. Specifically, for the particular problem I am having now, I need to know if a path is absolute or relative. The current code uses boost::filesystem::path which of course works like a charm on Windows: boost::filesystem::path the_path(the_path...

How do I copy files and folders using boost and Visual Studio 2005?

I'm trying to use boost::filesystem to copy files and folders (just like a standard copy a folder and paste it in windows explorer). Although I've been to the boost::filesystem documentation, I still don't really know how to go about doing this. Do you have to recursively go though each directory (creating it) and find each file copyi...

expand file names that have environment variables in their path

What's the best way to expand ${MyPath}/filename.txt to /home/user/filename.txt or %MyPath%/filename.txt to c:\Documents and settings\user\filename.txt with out traversing the path string looking for environement variables directly? I see that wxWidgets has a wxExpandEnvVars function. I can't use wxWidgets in this case, so I was...

Boost Filesystem Compile Error

I'm writing some code that utilizes the boost filesystem library. Here is an excerpt of my code: artist = (this->find_diff(paths_iterator->parent_path(), this->m_input_path) == 1) ? (*(paths_iterator->parent_path().end() - 1)) : (*(paths_iterator->parent_path().end() - 2)); album = (this->find_diff(paths_iterator->parent_path(), this->m...

Boost Filesystem createdirectories on Linux replacing "/" with "\"

When using Boost Filesystem's createdirectory (and createdirectories) function in the following example, "/" is being replaced with "\". boost::filesystem::path path ("/data/configSet"); boost::filesystem::create_directory(path); This code snipped produces a directory called "data\configSet", instead of creating a subdirectory of "con...

boost::filesystem exists() on directory path fails, but is_directory() is ok

I'm getting path to current directory with boost filesystem, then checking if the directory exists. is_directory() is ok, but exists() fails on the same path, am I missing something? Example code (boost 1.35): #include <boost/filesystem/operations.hpp> #include <boost/filesystem/path.hpp> namespace fs = boost::filesystem; // the pat...

What is best way to convert a file URL to a BOOST filesystem path in C++?

Hello I'm writing a library that has filenames as inputs. One feature that I'm trying to include is to allow the user to pass in file URLs or file paths, because sometimes the input is generated from parsing XML, other time it's not. I'm using the boost filesystem to manipulate the path, and is wondering what is the best way to conver...

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 --with-boost=/home/sb/local/ checking for a BSD-compatible install... /usr/bin/install -c...

Implementing Qt File Dialog with a Different File System Library (boost)

Hi, I am writing an application which requires me to use another file system and file engine handlers and not the qt's default ones. Basically what I want to be able to do is to use qt's file dialog but have an underlying file system handler (for example built using boost file system library) of mine handling all the operations with reg...

Compose path (with boost::filesystem)

I have a file that describes input data, which is split into several other files. In my descriptor file, I first give the path A that tells where all the other files are found. The originator may set either a relative (to location of the descriptor file) or absolute path. When my program is called, the user gives the name of the descri...

trouble with boost::filesystem::wrecursive_directory_iterator

I'm trying to write a program to help me manage my iTunes library, including removing duplicates and cataloging certain things. At this point I'm still just trying to get it to walk through all the folders, and have run into a problem: I have a small amount of Japanese music, where the artist and/or album is written in Japanese characte...

Why is there no boost::filesystem::move_file?

Hi, I'm using boost filesystem to replace windows C++ functions like CopyFile and MoveFile get some kind of portability between windows and linux. I'm using copy_file but I have not been able to find anything that moves files like a 'move_file' function. Do boost have a move file function? I would very much prefer to use boost, but al...

Explain boost::filesystem's portable generic path format in C++

I am trying to understand portable generic path format and everything is not clicking. Can someone please explain this in terms of examples? I also have been told that I can use the forward slash in windows because windows understands both. Also is it considered good/safe style to use forward slash in windows? ...

C++: How to modify a files 'created' timestamp?

I need to modify the 'created' (if exists), 'modified' and 'accessed' timestamps of a file. Ideally this would be a platform-independent solution. I've looked around the boost libraries but I can't see anything relevant. The nearest I've found to something relevant is this for Windows. Can anyone help? Thanks. ...

boost::filesystem::path and std::string

Hi, I have a String class which has a member std::string. One of the constructor is String (std::string s) { // member: std::string _mString; _mString = s; // error on path assignment } I now have functions that take String as parameter, e.g. Load(String path); but it turns out that boost::filesystem::path::string() is inc...