https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/access-waccess?redirectedfrom=MSDN&view=vs-2019
int _access(
const char *path,
int mode
);
When used with files, the _access function determines whether the specified file or directory exists and has the attributes specified by the value of mode. When used with directories, _access determines only whether the specified directory exists; in Windows 2000 and later operating systems, all directories have read and write access.
mode value Checks file for
00 Existence only
02 Write-only
04 Read-only
06 Read and write
// crt_access.c
// compile with: /W1
// This example uses _access to check the file named
// crt_ACCESS.C to see if it exists and if writing is allowed.
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
// Check for existence.
if( (_access( "crt_ACCESS.C", 0 )) != -1 )
{
printf_s( "File crt_ACCESS.C exists.\n" );
// Check for write permission.
// Assume file is read-only.
if( (_access( "crt_ACCESS.C", 2 )) == -1 )
printf_s( "File crt_ACCESS.C does not have write permission.\n" );
}
}