Is there a ready function to check if the string contains a valid file name? C ++ language.
And let's define the following points:
- What OS are we working on? It is clear that under Linux you can easily create files with names like COM1, from which Windows can tear down the roof.
- What file systems do we use? On fat12, it is potentially impossible to create files with names other than 8.3. And there are limitations on the number of characters on other filesystems.
- Do we need this to create a file with some name, or do we just take a path from the shit and do something there? And if this is the way that why we initially do not use the functions of working with paths: they must return valid values. And when creating your own directory-file, you always need to check the error codes and analyze where the jamb happened (you didn’t have enough rights, you didn’t have enough space, the media was not available or the wrong characters were in the way).
What do you mean by the term "Valid file name?"
If you need to check whether such a file exists, you can use the function from Boost'a