Well, i did a little googling and found two options.
/* ACCESS.C: This example uses _access to check the
* file named "ACCESS.C" to see if it exists and if
* writing is allowed.
*/
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
/* Check for existence */
if( (_access( "ACCESS.C", 0 )) != -1 )
{
printf( "File ACCESS.C exists\n" );
/* Check for write permission */
if( (_access( "ACCESS.C", 2 )) != -1 )
printf( "File ACCESS.C has write permission\n" );
}
}
//mode Value Checks File For
//00 Existence only
//02 Write permission
//04 Read permission
//06 Read and write permission
and the other one is:
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
int FileExists(char *filename)
{
struct _stat buf;
int status;
status = _stat(filename,&buf);
if(status==0) return(1);
else return(0);
}
If the file exists, it will return 1. If there is no file, you get back 0.
This is a Win32 version. If you are not in Win32, it will probably be
stat() without an underscore in front.
Give it a try, and let me know how it works out for you!
found them on this topic:
http://www.experts-exchange.com/Programming/Programming_Languages/C/Q_11129365.html
On Wed, 02 Feb 2005 08:40:28 -0600, Jeffrey botman Broome
<[EMAIL PROTECTED]> wrote:
> Frank Weima wrote:
> > Hi,
> >
> > I tried the folowing:
>
> <snip>
>
> Where did you put the code (in which .cpp file)?
>
> Also, opening the file to check for existence is considered bad form
> since you are changing the modification date of the file when you do
> this. Something like _stat() doesn't change any of the file properties.
>
> --
> Jeffrey "botman" Broome
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives, please
> visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
>
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders