# FS_OpenDirectory[W]

## Syntax

    #include <nitro/fs.h>

    BOOL FS_OpenDirectory(FSFile *dir, const char *path, u32 mode);
    BOOL FS_OpenDirectoryW(FSFile *file, const u16 *path, u32 mode);

## Arguments

dir | `FSFile` structure where the handle is stored
path | Directory's path
mode | Combination of `FS_DIRMODE_*` flags that indicates the mode for accessing the directory

## Return Values

`TRUE` if the directory 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 directory.
You can use the `FS_OpenDirectory` function when the path is specified using `Shift_JIS`, and the `FS_OpenDirectoryW` function when the path is specified using `UTF16-LE`. The results that are obtained will be the same. You can list all entry information in a directory, one at a time, by calling the `FS_ReadDirectory` function with the handle that is obtained. After using a handle, you must call the `FS_CloseDirectory` function to free it.
The function fails and returns `FALSE` in the following situations:

- If the target archive does not support opening directories
- If the specified directory does not exist

## Note

- This function cannot be called from the interrupt handler (IRQ mode). Also, in some cases processing may not end if interrupts are left prohibited.
- Because the structures of opened files are linked with system resources, you cannot move or duplicate the information in these structures by copying them into other structures. For details, see the `FSFile` structure.

## See Also

`FSFile`
`FSDirectoryEntryInfo`
`FSDirectoryEntryInfoW`
`FS_ReadDirectory`
`FS_CloseDirectory`

## Revision History

2009/07/29 Added mention that copying structure values is not guaranteed.
2008/09/02 Added notes concerning a Unicode version of the function.
2008/07/16 Revised Description to use `FS_GetResultCode` for getting the error code in cases of failure.
2007/09/18 Initial version.

CONFIDENTIAL