# 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 should be stored.
path | Directory's path
mode | Specifies the combination of FS_DIRMODE_* flags that indicate the mode for accessing the directory.

## Return Values

Returns TRUE if the directory handle opens properly; FALSE otherwise. In case of failure, use `FS_GetResultCode()` 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 within a directory, one at a time, by calling `FS_ReadDirectory()` with the handle that is obtained. After using a handle, you must call `FS_CloseDirectory()` to free it. The function 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.

## See Also

`FSFile FSDirectoryEntryInfo FSDirectoryEntryInfoW
FS_ReadDirectory FS_CloseDirectory`

## Revision History

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.
2007/09/18 Initial version.

CONFIDENTIAL