SDDS ToolKit Programs and Libraries for C and Python
All Classes Files Functions Variables Macros Pages
fexists.c File Reference

Detailed Description

Implementation of file existence checking function.

License
This file is distributed under the terms of the Software License Agreement found in the file LICENSE included with this distribution.
Author
C. Saunders, R. Soliday

Definition in file fexists.c.

#include "mdb.h"

Go to the source code of this file.

Functions

long fexists (const char *filename)
 Checks if a file exists.
 

Function Documentation

◆ fexists()

long fexists ( const char * filename)

Checks if a file exists.

This function attempts to open the specified file in read mode. If the file is successfully opened, it indicates that the file exists and the function returns 1. Otherwise, it returns 0.

Parameters
filenameThe name of the file to check for existence.
Returns
Returns 1 if the file exists, otherwise returns 0.

Definition at line 27 of file fexists.c.

27 {
28 FILE *fp;
29
30 if ((fp = fopen(filename, FOPEN_READ_MODE))) {
31 fclose(fp);
32 return (1);
33 }
34 return (0);
35}