Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::filesystem path problem under WINDOWS
From: avanindra singh (singh_avanindra_at_[hidden])
Date: 2010-12-13 12:53:49


Hi Jeff,
Thanks for the reply.

I caught the exception using this code:
  try{   create_directory(bundle_path);  }  catch(boost::system::system_error const &e)  {   cerr<<diagnostic_information(e)<<endl;  }

The printed output was
Throw in function (unknown)Dynamic exception type: class boost::exception_detail::clone_impl<struct boost::exception_detail::error_info_injector<class boost::filesystem::basic_filesystem_error<class boost::filesystem::basic_path<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct boost::filesystem::path_traits> > > >std::exception::what: boost::filesystem::create_directory: The filename, directory name, or volume label syntax is incorrect: "E:\doggy"

Can you point me what mistake I am doing here?..I believe the syntax of path is correct.
ThanksAvanindra
--- On Mon, 13/12/10, Jeff Flinn <TriumphSprint2000_at_[hidden]> wrote:

From: Jeff Flinn <TriumphSprint2000_at_[hidden]>
Subject: Re: [Boost-users] boost::filesystem path problem under WINDOWS
To: boost-users_at_[hidden]
Date: Monday, 13 December, 2010, 8:33 PM

avanindra singh wrote:
> Hi,
>  Here is the code snippet I am using under windows in VS2008.
>  #define BOOST_WINDOWS_PATH
> #define BOOST_WINDOWS_API

You shouldn't be manually defining these, and would normally get a compile error...

> #include "stdafx.h"

but you probably are configure to use precompiled headers, so anything before stdafx.h is ignored.

> #include <boost/filesystem/operations.hpp>
> #include <boost/filesystem/fstream.hpp>
> #include <iostream>
> #include "string"
> #include "conio.h"
> #include "vector"
>  using namespace std;
> using namespace boost::filesystem;
>    int _tmain(int argc, _TCHAR* argv[])
> {
> string _path = "E:\\doggy";
> path dir_path(_path.c_str());
> vector< pair<string,bool> > _file_jpeg_pair;
> string full_list_path = _path+"\\" + "list.txt";
> string bundle_path_str = _path+"\\" + "bundle";
> path bundle_path(_path.c_str());
> //creating bundle directory
> cout<<bundle_path<<endl;
> //if( !exists( bundle_path ) )
> create_directory(bundle_path);
> cout<<"directory created "<<endl;
> getch();
> return 0;
> }
>   This code is giving run time unhandled exception, so for that matter any other call of boost filesystem.

Catch the unhandled exception and see what the problem is. Filesystem throws boost::system::system_error exceptions.

> Strange thing is the Windows path E:\doggy is being printed as E:/doggy, seems like the path is getting converted to POSIX format.

Depending on the boost filesystem version you can ask for native formatted strings.

Jeff

_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users



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