# FS_COMMAND_SEEKDIR

## Definition

  `FSResult FS_ARCHIVE_PROC_FUNC(FSFile *p_file, FSCommandType command /* = FS_COMMAND_SEEKDIR */);
  `

## Description

Operating specifications for the archive command `FS_COMMAND_SEEKDIR` are shown below:

Arguments passed to this command

>     This command takes as a command argument the variable arg.seekdir that is stored in p_file.

>     This variable is defined in nitro/fs/file.h as shown below:

>     typedef struct {
>     FSDirPos        pos;
>     } FSSeekDirInfo;

> Argument content is listed below:

Arguments | Content
`pos` | The directory position to be moved is stored in a `FSDirPos` type. The `FS_COMMAND_READDIR` command generates this value.

Actions required of this command

>     It sets the p_file variable prop.dir as shown below:

>     Sets the directory position that is held by the argument pos in prop.dir.pos.
>     If both pos.index and pos.pos are 0, it signifies the top of the directory array position.

>     The set values are used by subsequent FS_COMMAND_SEEKDIR and FS_COMMAND_READDIR commands.
>     You may determine your own meanings for the pos name variables as long as they are appropriate arguments for these commands.

>     Sets the index for the parent directory at the directory position indicated by the argument pos in prop.dir.parent.
>     pos.own_id = 0" signifies the root directory.
>     In the case of the root directory, this sets the total number of directories into prop.dir.parent.

>     The set values are used by subsequent FS_COMMAND_GETPATH commands.

Default Implementation

> The command sets values based on the following determinants:

prop.dir.pos.arc | Uses the arguments as-is
prop.dir.pos.own_id | Uses the arguments as-is
prop.dir.pos.index | The position at which the next FNT directory entry resides. (Conforms to NitroROM format)
prop.dir.pos.pos | If the next directory entry is a file, that file's index This value increments by one each time `FS_COMMAND_READDIR` completes successfully. (Conforms to NitroROM format)
prop.dir.parent | Parent directory's index, or total number of directories. (Conforms to NitroROM format)

> As long as the archive's FNT conforms to the NitroROM format (determined by using the archive read callback function), this information is acquired from the FNT entry block that is indicated by `pos.own_id`.

Command Results

>     If this command returns FS_RESULT_SUCCESS, p_file becomes a handle that contains directory position information.
>     Subsequently the FS_IsDir function returns TRUE.
>     It can also be used as an argument in functions that operate on directories.

Functions that use this command

> FS_SeekDir `FS_RewindDir`
> (indirectly from the default `FS_FINDPATH` command) FS_ChangeDir FS_OpenFile `FS_ConvertPathToFileID`
> (indirectly from the default FS_GETPATH command) FS_GetPathName FS_GetPathLength

## See Also

`FSArchive`, `FS_ARCHIVE_PROC_FUNC`, `FS_COMMAND_*`, `FS_SetArchiveProc`

## Revision History

07/12/2004 Initial version.