boost::filesystem::path throws exception: invalid name
My code looks something like this: try{ fs::path full_path (fs::initial_path()); full_path = fs::system_complete(fs::path(filePath, fs::native)); fs::create_directories(full_path); INFO << "Directory successfully created: " << full_path.native_directory_string() << std::endl; retval = true; }catch(std::exception& ex){ WARN << "Could not create directory: " << filePath << " " << ex.what() << std::endl; } return retval; ========== When filePath is "c:\a\b\", boost throws an exception saying invalid path name c:\a\b\ in path "c:\a\b\" when filePath is "c:\\a\\b\\", boost throws exactly the same exception when filePath is "c:/a/b/", the exception string changes saying invalid path name "c:" in path "c:/a/b/" What am I doing wrong? -Vivek
Set boost::filesystem::default_name_check(boost::filesystem::native); before
using path objects as boost uses posix name checking by default. This has
been changed in boost version 1.34.
On 5/23/07, Vivek Nallur
My code looks something like this:
try{ fs::path full_path (fs::initial_path()); full_path = fs::system_complete(fs::path(filePath, fs::native)); fs::create_directories(full_path); INFO << "Directory successfully created: " << full_path.native_directory_string() << std::endl; retval = true; }catch(std::exception& ex){ WARN << "Could not create directory: " << filePath << " " << ex.what() << std::endl; } return retval;
==========
When filePath is "c:\a\b\", boost throws an exception saying invalid path name c:\a\b\ in path "c:\a\b\" when filePath is "c:\\a\\b\\", boost throws exactly the same exception when filePath is "c:/a/b/", the exception string changes saying invalid path name "c:" in path "c:/a/b/"
What am I doing wrong?
-Vivek _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
That results in a compiler error:
C2039 : default_name_check is not a member of boost::filesystem
-Vivek
On 23/05/07, Arthur Carlsson
Set boost::filesystem::default_name_check(boost::filesystem::native); before using path objects as boost uses posix name checking by default. This has been changed in boost version 1.34.
On 5/23/07, Vivek Nallur
wrote: My code looks something like this:
try{ fs::path full_path (fs::initial_path()); full_path = fs::system_complete(fs::path(filePath,
fs::native));
fs::create_directories(full_path); INFO << "Directory successfully created: " << full_path.native_directory_string() <<
std::endl;
retval = true; }catch(std::exception& ex){ WARN << "Could not create directory: " << filePath << " " << ex.what() << std::endl; } return retval;
==========
When filePath is "c:\a\b\", boost throws an exception saying invalid path name c:\a\b\ in path "c:\a\b\" when filePath is "c:\\a\\b\\", boost throws exactly the same exception when filePath is "c:/a/b/", the exception string changes saying invalid path name "c:" in path "c:/a/b/"
What am I doing wrong?
-Vivek _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Sorry, my bad. The 'default_name_check' exists in the
boost::filesystem::path namespace and not boost::filesystem.
However, it has no effect. In other words, I still get the invalid
name exception.
I'm using Boost-1.33.1 on a windows box.
-Vivek
On 23/05/07, Vivek Nallur
That results in a compiler error:
C2039 : default_name_check is not a member of boost::filesystem
-Vivek
On 23/05/07, Arthur Carlsson
wrote: Set boost::filesystem::default_name_check(boost::filesystem::native); before using path objects as boost uses posix name checking by default. This has been changed in boost version 1.34.
On 5/23/07, Vivek Nallur
wrote: My code looks something like this:
try{ fs::path full_path (fs::initial_path()); full_path = fs::system_complete(fs::path(filePath,
fs::native));
fs::create_directories(full_path); INFO << "Directory successfully created: " << full_path.native_directory_string() <<
std::endl;
retval = true; }catch(std::exception& ex){ WARN << "Could not create directory: " << filePath << " " << ex.what() << std::endl; } return retval;
==========
When filePath is "c:\a\b\", boost throws an exception saying invalid path name c:\a\b\ in path "c:\a\b\" when filePath is "c:\\a\\b\\", boost throws exactly the same exception when filePath is "c:/a/b/", the exception string changes saying invalid path name "c:" in path "c:/a/b/"
What am I doing wrong?
-Vivek _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Is there any mechanism to force boost to check the native filesystem
for a path format? Adding
default_name_check(boost::filesystem::native) does not seem to help.
I'm still getting the invalid name exception.
-Vivek
On 23/05/07, Vivek Nallur
Sorry, my bad. The 'default_name_check' exists in the boost::filesystem::path namespace and not boost::filesystem.
However, it has no effect. In other words, I still get the invalid name exception.
I'm using Boost-1.33.1 on a windows box.
-Vivek
On 23/05/07, Vivek Nallur
wrote: That results in a compiler error:
C2039 : default_name_check is not a member of boost::filesystem
-Vivek
On 23/05/07, Arthur Carlsson
wrote: Set boost::filesystem::default_name_check(boost::filesystem::native); before using path objects as boost uses posix name checking by default. This has been changed in boost version 1.34.
On 5/23/07, Vivek Nallur
wrote: My code looks something like this:
try{ fs::path full_path (fs::initial_path()); full_path = fs::system_complete(fs::path(filePath,
fs::native));
fs::create_directories(full_path); INFO << "Directory successfully created: " << full_path.native_directory_string() <<
std::endl;
retval = true; }catch(std::exception& ex){ WARN << "Could not create directory: " << filePath << " " << ex.what() << std::endl; } return retval;
==========
When filePath is "c:\a\b\", boost throws an exception saying invalid path name c:\a\b\ in path "c:\a\b\" when filePath is "c:\\a\\b\\", boost throws exactly the same exception when filePath is "c:/a/b/", the exception string changes saying invalid path name "c:" in path "c:/a/b/"
What am I doing wrong?
-Vivek _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On 23/05/07, Vivek Nallur
Is there any mechanism to force boost to check the native filesystem for a path format? Adding default_name_check(boost::filesystem::native) does not seem to help. I'm still getting the invalid name exception.
The obligatory checking has been entirely removed in 1.34, so upgrading may be an acceptable solution. ~ Scott McMurray
Hi Vivek,
On 5/23/07, Vivek Nallur
My code looks something like this:
fwiw, the following code works just fine with 1.33.1 on Windows (and you do not need to use default_name_check if don't need to do this for every path) namespace fs = boost::filesystem; fs::path foo_path("c:\\a\\b", fs::native); fs::path bar_path(fs::initial_path()); If you can post the actual code that is causing you problems, it might help to spot the error. Levent -- Server Levent Yilmaz Mechanical Engineering University of Pittsburgh
My code looks like this:
namespace fs = boost::filesystem;
fs::path full_path(fs::initial_path());
try{
full_path = fs::system_complete(fs::path(filePath, fs::native));
...
fs::create_directories(full_path);
}catch(exception& ex){
std::cout << ex.what() << std::endl;
}
Here, 'filePath' is a const char*, that is passed in, which is of the
form "c:\\a\\b\\"
Upon execution, boost throws an exception saying 'invalid name'. If I
change all the back-slashes to slashes, the exception stating 'invalid
name' still contains "c:" as the offending string.
regs
Vivek
On 23/05/07, Server Levent Yilmaz
Hi Vivek,
On 5/23/07, Vivek Nallur
wrote: My code looks something like this:
fwiw, the following code works just fine with 1.33.1 on Windows (and you do not need to use default_name_check if don't need to do this for every path)
namespace fs = boost::filesystem; fs::path foo_path("c:\\a\\b", fs::native); fs::path bar_path(fs::initial_path());
If you can post the actual code that is causing you problems, it might help to spot the error.
Levent
-- Server Levent Yilmaz Mechanical Engineering University of Pittsburgh _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Funnily enough,
full_path = fs::system_complete(fs::path(filePath, fs::no_check));
works on my windows machine!
-Vivek
On 23/05/07, Vivek Nallur
My code looks like this:
namespace fs = boost::filesystem;
fs::path full_path(fs::initial_path()); try{ full_path = fs::system_complete(fs::path(filePath, fs::native)); ... fs::create_directories(full_path); }catch(exception& ex){ std::cout << ex.what() << std::endl; }
Here, 'filePath' is a const char*, that is passed in, which is of the form "c:\\a\\b\\"
Upon execution, boost throws an exception saying 'invalid name'. If I change all the back-slashes to slashes, the exception stating 'invalid name' still contains "c:" as the offending string.
regs Vivek
On 23/05/07, Server Levent Yilmaz
wrote: Hi Vivek,
On 5/23/07, Vivek Nallur
wrote: My code looks something like this:
fwiw, the following code works just fine with 1.33.1 on Windows (and you do not need to use default_name_check if don't need to do this for every path)
namespace fs = boost::filesystem; fs::path foo_path("c:\\a\\b", fs::native); fs::path bar_path(fs::initial_path());
If you can post the actual code that is causing you problems, it might help to spot the error.
Levent
-- Server Levent Yilmaz Mechanical Engineering University of Pittsburgh _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (4)
-
Arthur Carlsson
-
me22
-
Server Levent Yilmaz
-
Vivek Nallur