0

How can I verify (in Visual C++ in MS VS 2013) that the string contents fits to fully qualified path to folder or relative qualified path to folder? I have the following code:

 int _tmain(int argc, _TCHAR* argv[])
 {
      // If command line contains a path to folder:
      if (argc == 2)
      {
       string folderPath = argv[1];

       // If this path doesn't exceed 248 characters:
       if (folderPath.size() <= MAX_PATH - 12)
       {
            /*
                    Here I must verify that the value of folderPath string variable
                    fits to fully qualified or relative qualified path to folder.
                */
           }
      }

      return 0;
 }

Is there any function in Visual C++ that can verify that the value of folderPath string variable fits to fully or relative qualified path to folder? My application is C++ console application without MFC support and I don't use BOOST. In my application I use multibyte character set but not unicode. I'll be very appreciative for the help.

user3769902
  • 415
  • 2
  • 5
  • 20
  • Aren't you already doing that? Edit: Oh. I see. You want to fully qualify the input. – drescherjm Dec 10 '14 at 14:41
  • Do you know about extended length paths? http://stackoverflow.com/questions/3591840/are-extended-length-paths-safe-to-use – drescherjm Dec 10 '14 at 14:42
  • I not need to use the extended length path. I need to use 260 character path with 8.3 naming rules. – user3769902 Dec 10 '14 at 14:48
  • Are you asking how to verify that `folderPath` contains the name of a valid folder? Use [GetFileAttributes](http://msdn.microsoft.com/en-us/library/windows/desktop/aa364944%28v=vs.85%29.aspx) and check to see if the [FILE_ATTRIBUTE_DIRECTORY](http://msdn.microsoft.com/en-us/library/windows/desktop/gg258117%28v=vs.85%29.aspx) flag is set. – jliv902 Dec 10 '14 at 14:55
  • No the OP is asking after conversion (most likely using a winapi function to convert) to a fully qualified or relative path will the path be valid? – drescherjm Dec 10 '14 at 15:02
  • http://msdn.microsoft.com/en-us/library/windows/desktop/bb773660%28v=vs.85%29.aspx – Xearinox Dec 10 '14 at 17:20
  • What do you mean by "fits to"? Fits into? I'm not seeing any buffers. – Igor Skochinsky Dec 15 '14 at 17:54

0 Answers0