Boost logo

Boost Users :

Subject: [Boost-users] boost::filesystem::native
From: Christopher J. Pisz (cpisz_at_[hidden])
Date: 2016-11-10 15:05:00


I did a Google search to see how to check if a given path is valid,
preferably using boost.

It brought me here:

http://stackoverflow.com/questions/10426671/how-to-check-if-path-is-valid-in-boostfilesystem

Great! I say to myself.
I then Google up the boost doc here:
http://www.boost.org/doc/libs/1_62_0/libs/filesystem/doc/portability_guide.htm

I then write myself a test:

     #include <iostream>
     #include <sstream>

     #include <boost/filesystem.hpp>

     int main()
     {
         const std::string test1 = "D:\\Programing Projects\\Git
Workspace\\Common\\x64\\Debug";
         const std::string test2 = "D:\Programing Projects\\Git
Workspace\\Common\\x64\\Debug\\";
         const std::string test3 = "D:/Programing Projects/Git
Workspace/Common/x64/Debug";
         const std::string test4 = "D:/Programing Projects/Git
Workspace/Common/x64/Debug/";

         if (!boost::filesystem::native(test1))
         {
             std::cout << "Boost says the following path is not valid
for the native operating system: " << test1 << std::endl;
         }

         if (!boost::filesystem::native(test2))
         {
             std::cout << "Boost says the following path is not valid
for the native operating system: " << test2 << std::endl;
         }

         if (!boost::filesystem::native(test3))
         {
         std::cout << "Boost says the following path is not valid for
the native operating system: " << test3 << std::endl;
         }

         if (!boost::filesystem::native(test4))
         {
             std::cout << "Boost says the following path is not valid
for the native operating system: " << test4 << std::endl;

         }

         return 0;
     }

The Test's Output:

     Boost says the following path is not valid for the native operating
system: D:\Programing Projects\Git Workspace\Common\x64\Debug
     Boost says the following path is not valid for the native operating
system: D:Programing Projects\Git Workspace\Common\x64\Debug\
     Boost says the following path is not valid for the native operating
system: D:/Programing Projects/Git Workspace/Common/x64/Debug
     Boost says the following path is not valid for the native operating
system: D:/Programing Projects/Git Workspace/Common/x64/Debug/

What is wrong with that path that it says it is not valid for my native
Windows 10 operating system?


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