---
name: "SDL_AsyncIOFromFile"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_AsyncIOFromFile"
---

# SDL\_AsyncIOFromFile(3)

Use this function to create a new SDL\_AsyncIO object for reading from and/or writing to a named file.

## NAME

SDL\_AsyncIOFromFile - Use this function to create a new  **SDL\_AsyncIO**\
  object for reading from and/or writing to a named file.

## HEADER FILE

Defined in SDL3/SDL\_asyncio.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**SDL\_AsyncIO \* SDL\_AsyncIOFromFile(const char \*file, const char \*mode);**

## DESCRIPTION

The **mode** string understands the following values:

• "r": Open a file for reading only. It must exist.

• "w": Open a file for writing only. It will create missing files or\
   truncate existing ones.

• "r+": Open a file for update both reading and writing. The file must\
   exist.

• "w+": Create an empty file for both reading and writing. If a file with\
   the same name already exists its content is erased and the file is\
   treated as a new empty file.

There is no "b" mode, as there is only "binary" style I/O, and no "a" mode for appending, since you specify the position when starting a task.

This function supports Unicode filenames, but they must be encoded in UTF-8 format, regardless of the underlying operating system.

This call is \_not\_ asynchronous; it will open the file before returning, under the assumption that doing so is generally a fast operation. Future reads and writes to the opened file will be async, however.

## FUNCTION PARAMETERS

- *file*

  a UTF-8 string representing the filename to open.

- *mode*

  an ASCII string representing the mode to be used for opening the file.

## RETURN VALUE

( **SDL\_AsyncIO**\
  \*) Returns a pointer to the

**SDL\_AsyncIO**\
  structure that is created or NULL on failure; call  **SDL\_GetError** () for more information.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_CloseAsyncIO**(3)](/SDL_CloseAsyncIO/3.md), **•**(3), [**SDL\_ReadAsyncIO**(3)](/SDL_ReadAsyncIO/3.md), **•**(3), [**SDL\_WriteAsyncIO**(3)](/SDL_WriteAsyncIO/3.md)
