very basic boost::filesystem::path question
Hi boosters I have a very basic question. Why does path("s:/dbgdata/testdata.2") throw the exception boost::filesystem::filesystem_error with the errormessage "boost::filesystem::path: invalid name "s:" in path: "s:/dbgdata/testdata.2"? It certainly looks as if I've overlooked something quite fundamental. I'm using MSVC 8-0 Beta 2 and boost version 1.32.0. Kind regards Peter Koch Larsen
try passing boost::filesystem::native as the second arg to path()
On 7/13/05, Peter Koch Larsen
Hi boosters
I have a very basic question. Why does path("s:/dbgdata/testdata.2") throw the exception boost::filesystem::filesystem_error with the errormessage "boost::filesystem::path: invalid name "s:" in path: "s:/dbgdata/testdata.2"? It certainly looks as if I've overlooked something quite fundamental.
I'm using MSVC 8-0 Beta 2 and boost version 1.32.0.
Kind regards Peter Koch Larsen
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Cory Nelson http://www.int64.org
On 7/13/05, Peter Koch Larsen
wrote: I have a very basic question. Why does path("s:/dbgdata/testdata.2") throw the exception boost::filesystem::filesystem_error with the errormessage "boost::filesystem::path: invalid name "s:" in path: "s:/dbgdata/testdata.2"? It certainly looks as if I've overlooked something quite fundamental.
I'm using MSVC 8-0 Beta 2 and boost version 1.32.0.
Cory Nelson wrote:
try passing boost::filesystem::native as the second arg to path()
Also note that '/' isn't a native directory separator on Windows. Use '\' instead. You might also like to disable the checker that is throwing these exceptions. See http://www.boost.org/libs/filesystem/doc/path.htm#name_check%AD_mechanism and the associated member functions static name_check default_name_check( name_check new_check ); Angus
On 7/14/05, Angus Leeming
Also note that '/' isn't a native directory separator on Windows. Use '\' instead.
Though it *is* supported by the Microsoft runtime (and presumably all compiler vendors runtimes on Windows), so it ought to be acceptable for use in a portable filesystem API, no? -- Caleb Epstein caleb dot epstein at gmail dot com
Caleb Epstein wrote:
Also note that '/' isn't a native directory separator on Windows. Use '\' instead.
Though it *is* supported by the Microsoft runtime (and presumably all compiler vendors runtimes on Windows), so it ought to be acceptable for use in a portable filesystem API, no?
I guess that you should really be directing that question to Beman. Meanwhile, "ought" isn't going to help the OP to get his code to run... -- Angus
At 01:27 2005-07-14, you wrote:
On 7/13/05, Peter Koch Larsen
wrote: I have a very basic question. Why does path("s:/dbgdata/testdata.2") throw the exception boost::filesystem::filesystem_error with the errormessage "boost::filesystem::path: invalid name "s:" in path: "s:/dbgdata/testdata.2"? It certainly looks as if I've overlooked something quite fundamental.
I'm using MSVC 8-0 Beta 2 and boost version 1.32.0.
Cory Nelson wrote:
try passing boost::filesystem::native as the second arg to path()
Also note that '/' isn't a native directory separator on Windows. Use '\' instead.
'/' works just fine in Windows, always has except from a command shell if it's an error in boost, then there is an error in boost
You might also like to disable the checker that is throwing these exceptions. See http://www.boost.org/libs/filesystem/doc/path.htm#name_check%AD_mechanism and the associated member functions static name_check default_name_check( name_check new_check );
Angus
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Victor A. Wagner Jr. http://rudbek.com The five most dangerous words in the English language: "There oughta be a law"
Victor A. Wagner Jr. wrote:
'/' works just fine in Windows, always has except from a command shell if it's an error in boost, then there is an error in boost
I am using Boost.filesystem for my filemanager and I also noticed that it's extremely harsh with naming conventions for paths. However, since this discussion comes up periodically, I recall that someone said that's because the library is also supposed to run on more exotic platforms which use a totally different syntax for addressing files than the average Linux or Windows user is used to. Though I can't recall the name, a (today quite dated) OS was mentioned, which doesn't use slashes or backslashes at all to address files. That's why using both slashes and backslashes is platform dependent and that's also why filesystem throws when you don't use native together with '/' or '\'. (Then again however the native keyword looks rather useless, because there *is* no syntax which works for all platforms and so you are forced to use native). -- Matthias Kaeppler
At 01:46 AM 7/15/2005, you wrote:
Victor A. Wagner Jr. wrote:
'/' works just fine in Windows, always has except from a command shell if it's an error in boost, then there is an error in boost
I am using Boost.filesystem for my filemanager and I also noticed that it's extremely harsh with naming conventions for paths.
Drive letters (i.e. "c:") and backslashes in particular will cause it to throw an exception if you don't use the 'native' flag. I used this simple test program: path p1("/this/is/a/test"); cout << p1.string() << endl; path p2("\\this\\is\\a\\test", native); cout << p2.string() << endl; Notice that the native flag is required for the second path. The separators are translated to forward slashes internally by the library so the output of the above two paths is the same.
(Then again however the native keyword looks rather useless, because there *is* no syntax which works for all platforms and so you are forced to use native).
I believe that it uses forward slashes internally and converts to native format when asked (at least on Win32). I also understand (but could be mistaken) that the next version (with I18N support) does away with the native checks. Jason
-- Matthias Kaeppler
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Also note that '/' isn't a native directory separator on Windows. Use '\' instead.
'/' works just fine in Windows, always has except from a command shell if it's an error in boost, then there is an error in boost
I thought so too until win98 proved me wrong : Executing FindFirstFileA with a path like c:/* yields wrong results for win98... and the app was linked to the vc7 runtimes. -seb
participants (8)
-
Angus Leeming
-
Caleb Epstein
-
Cory Nelson
-
Jason Stewart
-
Matthias Kaeppler
-
Peter Koch Larsen
-
Seb Martel
-
Victor A. Wagner Jr.