## Introduction

The CUPS file and directory APIs provide portable interfaces for manipulating files and listing files and directories. Unlike stdio `FILE` streams, the `cupsFile` functions allow you to open more than 256 files at any given time. They also manage the platform-specific details of locking, large file support, line endings (CR, LF, or CR LF), and reading and writing files using Flate ("gzip") compression. Finally, you can also connect, read from, and write to network connections using the `cupsFile` functions.

The `cupsDir` functions manage the platform-specific details of directory access/listing and provide a convenient way to get both a list of files and the information (permissions, size, timestamp, etc.) for each of those files.

The CUPS scheduler (`cupsd`), `mailto` notifier, and many of the CUPS API functions use these functions for everything except console (stdin, stdout, stderr) I/O.

## General Usage

The <cups/dir.h> and <cups/file.h> header files must be included to use the `cupsDir` and `cupsFile` functions, respectively.

Programs using these functions must be linked to the CUPS library: libcups.a, libcups.so.2, libcups.2.dylib, libcups_s.a, or libcups2.lib depending on the platform. The following command compiles myprogram.c using GCC and the CUPS library:

    gcc -o myprogram myprogram.c -lcups

## Compatibility

All of these functions require CUPS 1.2 or higher.