FatFs - Path Names

## Format of the path names

The path name format on the FatFs module is similer to the filename specs of DOS/Windos as follows:

     "[drive#:][/]directory/file"

The FatFs module supports long file name (LFN) and 8.3 format file name (SFN). The LFN can be used when LFN feature is enabled `(_USE_LFN > 0)`. The differences between DOS/Windows are directory separator and logical drive number. The sub directories are separated with a / or \. The logical drive is specified in a numeral with a colon. When the drive number is omitted, it is assumed as default drive (0 or current drive). Leading spaces in the given path name are ignored on non-LFN configuration but valid on LFN configuration.

In default configuration `(_FS_RPATH == 0)`, it does not have a concept of current directory like OS oriented file system. All objects on the volume are always specified in full path name that follows from the root directory. Dot directory names are not allowed. Heading separator is ignored and it can be exist or omitted. The default drive number is fixed to 0.

When relative path feature is enabled `(_FS_RPATH == 1)`, specified path is followed from the root directory if a heading separator is exist. If not, the path is followed from the current directory set with f_chdir function. Dot names are also allowed for the directory name. The default drive number is the current drive number set with f_chdrive function.

Path name | _FS_RPATH == 0 | _FS_RPATH == 1
file.txt | A file in the root directory on the drive 0 | A file in the current directory on the current drive
/file.txt | A file in the root directory on the drive 0 | A file in the root directory on the current drive
| The root directory on the drive 0 | The current directory on the current drive
2: | The root directory on the drive 2 | The current directory on the drive 2
2:file.txt | A file in the root directory on the drive 2 | A file in the current directory on the drive 2
2:/ | The root directory on the drive 2 | The root directory on the drive 2
../file.txt | Invalid name | A file in the parent directory
. | Invalid name | This directory
.. | Invalid name | Parent directory of the current directory
dir1/.. | Invalid name | The current directory
/.. | Invalid name | Invalid name (Cannot use dot names at the root directory)

## Unicode API

The path names are input/output in either OEM code (SBCS/DBCS) or Unicode depends on the configuration options. The type of arguments that specifies the file names are defined as `XCHAR` which is an alias of `char` in default. The code set of the file name string is the OEM code set specifid by `_CODE_PAGE`. When `_LFN_UNICODE` is set to 1 under LFN configuration, the type of the `XCHAR` is switched to `unsigned short` (wide character) to support Unicode. In this case, the LFN feature is fully supported and the Unicode specific characters, such as ✝☪✡☸☭, can also be used for the path name.

## Correspondence between logical and physical drives

The FatFs module has work areas that called file system object for each volume (logical drive). In default, the logical drive is bound to the physical drive that has same drive number, and the first partition is mounted. When `_MULTI_PARTITION == 1` is specified in configuration option, each individual logical drive can be bound to any physical drive/partition. In this case, a drive number resolution table must be defined as follows:

    Example: Logical drive 0-2 are assigned to three pri-partitions on the physical drive 0 (fixed disk)
             Logical drive 3 is assigned to physical drive 1 (removable disk)

    const PARTITION Drives[] = {
        {0, 0},     /* Logical drive 0 ==> Physical drive 0, 1st partition */
        {0, 1},     /* Logical drive 1 ==> Physical drive 0, 2nd partition */
        {0, 2},     /* Logical drive 2 ==> Physical drive 0, 3rd partition */
        {1, 0}      /* Logical drive 3 ==> Physical drive 1 */
    };

There are some considerations when use `_MULTI_PARTITION` configuration.

- Only pri-partition (0-3) can be mounted.
- When the physical drive has no partition table (SFD format), the partition number is ignored.
- The physical drive that has two or more logical drives must be a fixed drive.