vrijdag 10 december 2010

C++ - see if a file exists without opening it

Opening files can have quite an effect on performance. So if you just want to know if a file is there you might not want to open it. Instead you could use the _access method to see if a file exists. More information can be found on MSDN here http://msdn.microsoft.com/en-us/library/1w06ktdy(v=VS.71).aspx
If the method returns a -1 and errno is set to ENOENT then the file does not exist. Set the mode parameter of the _access method to 0 to check for existence only.

Geen opmerkingen:

Een reactie posten