Is there a method in C++ for checking if a certain file exists in the directory of the program? For example, checking if there is a file named foobar1.txt, and if there is, open a new file named foobar2.txt? Is this possible without using some external library or platform dependant code?