Boost logo

Boost Users :

From: Simon Lundell (simon.lundell_at_[hidden])
Date: 2006-04-03 04:49:48


Dear all,

I am experiencing problems with boost::filesystem on files that contains
a plus (+) sign. Below is a minimal example to test this. the line:

boost::filesystem::path p_plus("filename+.txt");

throws an exception if the filename contains a plus.

Any help or hints would be greatly appreciated.

Best regards,
Simon

output:
*****************
Contents of filename-.txt

Filesystem error caught, reason: boost::filesystem::path: invalid name
"filename+.txt" in path: "filename+.txt"
*****************

source:
*************
#include <iostream>
#include <cstdlib>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/exception.hpp>
#include <boost/filesystem/fstream.hpp>
using namespace std;
int main(int argc, char *argv[]){

  try{
    boost::filesystem::path p_minus("filename-.txt");
    boost::filesystem::ifstream ifs_minus(p_minus,ios::in );

    cout<<ifs_minus.rdbuf();

  }catch ( boost::filesystem::filesystem_error const &fse){
     cout << "Filesystem error caught, reason: "<<fse.what() << endl;
  }
 
  try{
     boost::filesystem::path p_plus("filename+.txt");
     boost::filesystem::ifstream ifs_plus(p_plus,ios::in );

     cout<<ifs_plus.rdbuf();

  }catch ( boost::filesystem::filesystem_error const &fse){
     cout << "Filesystem error caught, reason: "<<fse.what() << endl;
  }
   

  return 0;
}
*****************


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net