# FS_OpenFileEx[W]

## Syntax

    #include <nitro/fs.h>

    BOOL FS_OpenFileEx(FSFile *file, const char *path, u32 mode);
    BOOL FS_OpenFileExW(FSFile *file, const u16 *path, u32 mode);

## Arguments

file | `FSFile` structure where the handle should be stored.
path | Path name of file.
mode | Combination of `FS_FILEMODE_*` flags that indicate the mode for accessing the file.

## Return Values

`TRUE` if the file handle opens properly; `FALSE` otherwise. In case of failure, use the `FS_GetResultCode` function to get the error details.

## Description

Opens the handle for the specified file.
You can use the `FS_OpenFileEx` function when the path is specified using `Shift_JIS` and the `FS_OpenFileExW` function when the path is specified using `UTF16-LE`. The results that are obtained will be the same. There are several conditions that apply to files that can be opened.

- The file must already exist. It will not be created automatically, even if this function is called with `FS_FILEMODE_W` specified.`FS_CreateFile` must be used to create a new file.
- To avoid unintentional malfunction due to the fact that the functions for file operations supported by the FS library only work for files under 2 GB, this function will always fail and return `FS_RESULT_PERMISSION_DENIED` if you try to open a file 2 GB or larger.
- If you attempt to open a TWL-exclusive file while the system is operating in NITRO mode, the function will fail and return `FS_RESULT_PERMISSION_DENIED`.

The various functions for file access can be called using the handle that is obtained. After using a handle, you must call `FS_CloseFile` to free it.

## Note

- This function cannot be called from the interrupt handler (IRQ mode). Also, in some cases processing may not end if interrupts are still disabled.
- The structures of opened files are associated with system resources so you cannot move or duplicate information even by copying them to other structures as they are. For details, see `FSFile` structure.

## See Also

`FSFile`
`FSDirectoryEntryInfo`
`FS_ReadFile`
`FS_WriteFile`
`FS_SeekFile`

## Revision History

2009/07/14 Added mention that copying structure values is not guaranteed.
2009/06/08 Added link to TWL-specific file explanation.
2009/01/08 Added an explanation about TWL-exclusive files.
2008/09/02 Added notes concerning a Unicode version of the function.
2008/07/16 Revised the description to use `FS_GetResultCode` for getting the error code in cases of failure. Added size restriction of 2 GB.
2008/06/10 Added the fact that files will not be created automatically.
2007/09/18 Initial version.

CONFIDENTIAL