# FS_*FileAuto,FS_*DirectoryAuto

## Syntax

    #include <nitro/fs.h>

    BOOL FS_CreateFileAuto(const char *path, u32 permit);
    BOOL FS_DeleteFileAuto(const char *path);
    BOOL FS_RenameFileAuto(const char *src, const char *dst);
    BOOL FS_CreateDirectoryAuto(const char *path, u32 permit);
    BOOL FS_DeleteDirectoryAuto(const char *path);
    BOOL FS_RenameDirectoryAuto(const char *src, const char *dst);

## Arguments

These are the same as those of the normal functions without the "`Auto`" suffix.

## Return Values

These are the same as those of the normal functions without the "`Auto`" suffix.

## Description

Except for the fact that the directory operations performed on the target path will be automatically supplemented, these are the same as the normal functions without the "`Auto`" suffix. The following operations are supplemented as follows with these functions.

- If the creation path for `Create` or the destination path for `Rename` are under a directory that does not exist, all subdirectories leading to these paths will be created automatically. If the intended process fails, the directories that were created automatically will be deleted.
- If a directory to be deleted with `Delete` is not empty, all items under that directory will be deleted.

## Note

- This function cannot be called from the interrupt handler (IRQ mode). Also note that in some cases processing may not end if interrupts are left prohibited.
- Because these functions automatically supplement directory operations, it is possible for them to succeed in path operations that would normally fail using the normal functions. Extreme care must be taken regarding their usage.

      Safe Example:
        // Debugging will be more effective if only constant strings are ever used.
        // We recommend using these "Auto" functions for convenience, in a way that is limited to a single purpose.
        static const char *dir = "tmp:/workdir/";
        FS_DeleteDirectoryAuto(dir);

      Dangerous Example:
        // Dynamically generated paths are more inclined to bugs.
        // In situations that rely on the operating environment, either this kind of usage should be avoided or extreme caution must be exercised.
        STD_SPrintf(path, "savedata:/users/%s/", newUserName);
        FS_CreateDirectoryAuto(path);

- If these functions fail, `FS_GetArchiveResultCode()` cannot be used to check the exact error details.

## See Also

`FS_CreateDirectory FS_DeleteDirectory FS_RenameDirectory FS_CreateFile FS_DeleteFile FS_RenameFile`

## Revision History

2008/01/25 Initial version.

CONFIDENTIAL