---
name: "file_exists"
section: "3alleg"
platform: "linux"
package: "liballegro-doc"
version: "2:4.2.2-2.2"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/file_exists"
---

# file\_exists(3alleg)

Tells if a file exists. Allegro game programming library.

## NAME

file\_exists - Tells if a file exists. Allegro game programming library.

## SYNOPSIS

**#include \<allegro.h\>**

**int file\_exists(const char \*filename, int attrib, int \*aret);**

## DESCRIPTION

Checks whether a file matching the given name and attributes (see beginning of this chapter) exists. If \`aret' is not NULL, it will be set to the attributes of the matching file. Example:

```
   /* Check for a normal file. */
   if (file_exists("franken.dat", 0, NULL))
      allegro_message("It is alive!\n");
```

## RETURN VALUE

Returns non-zero if the file exists, or zero if it doesn't or the specified attributes mask it out.

## SEE ALSO

[**exists**(3alleg)](/exists/3alleg.md), [**file\_size\_ex**(3alleg)](/file_size_ex/3alleg.md), [**file\_time**(3alleg)](/file_time/3alleg.md)
