views:

79

answers:

3

Hello

I wanna check if my string is valid windows file path. I was searching around and it seems that there is no reliable method to do that. Also I checked boost filesystem library , and no obvious function exist to do this check , maybe something like is_valid_windows_name

A: 

You could use _splitpath() function and parse the output (based on it, you could easily say if your path is valid or not).

See MSDN for additional information.

Note that this function is windows-specific.

Kotti
A: 

I do not believe there is a standard c++ api for that.

Note that the Windows API allows more filenames than the Windows Shell (The filenames the user is allowed to use in windws explorer).

You should have a look at the windows shell api.

Another possibility is to use trial and error, this way you are truly independend of the current filesystem.

The easiest way is to disallow

\ / < > | " : ? *

and you should be fine.

codymanix
and '*' and com,lpt,aux,con
Martin Beckett
updated my answer :)
codymanix