FILES

files [-? | user | sector [filename]]

This command will allow you to view files as defined in a file sector (more
info below). There is currently no filesystem checking on the disk, so things
like duplicate filenames and bad sector references will not be checked.

For users to have their file sectors be listed under their username, they
must create a text file named '~/.filesector'. Sector numbers must be specified,
separated by a newline ('\n'). Users must own their file sectors, although they
do not have to own the sectors they reference in the file sector itself.

FLAGS:
<none>     Get a list of users and their file sectors
-?         Help (also --help)
user       List files that user has defined
sector     List files defined in given sector
filename   Read the contents of the file to the shell.
           Must be used with 'sector' argument

FILE SECTOR FORMAT:
File sectors begin with three bytes defining the disk number, the 16th byte
where the first sector should begin, and the 16th byte where the last sector
should end. Currently all three of these bytes are unused but for future
compatibility purposes, they should be '\00\00\20'.

Afterwards, the location of data of the disk must be defined using track
numbers (0-159) and the number of the sector (0-17) on that track **in
hexadecimal** (See: hex, trackinfo). Please note that this is NOT the same as
the OVERALL sector number, which is what is used everywhere else. You can use
the `trackinfo` command to get the sector and track numbers of a given sector
and then `hex` to convert them to hexadecimal. Below is an example of finding
sector 629 (sector 17 of track 34), where 0x22 is the track number and 0x11 is
the sector number that would be used for the file sector.

```
jebug29@sectordisk:~$ trackinfo 629
Sector: 629
[ Head 0 | Cylinder 17 | Sector 17 of Track 34 ]

jebug29@sectordisk:~$ hex 34 17
22 11
```

The format for the location information is {track_number, sector number}, and
the user is allowed to specify as many as they can fit into a given file
definition and sector. For example, if I wanted to combine sectors 629 and 14
into one file, I would just add the track and sector info in series:

(Sector 629: track 0x22, sector 0x17), (Sector 14: track 0x00, sector 0x0E)
*Location Information starts at byte 4:*
```
Addr      Data (Hex)                                        Data (ASCII)
00000000  00 00 20 33 17 00 0e                              |.. 3...|
```

After the location information is complete, a filename may be provided. The
filename will be decoded as UTF-8 and there is no character limit with the
exception of that it must fit within the sector. The filename **MUST** end with
\00\FF. This will end the string and close the file definition.
```
Addr      Data (Hex)                                        Data (ASCII)
00000000  00 00 20 33 17 00 0e 66  69 6c 65 6e 61 6d 65 2e  |.. 3...filename.|
00000010  65 78 74 00 ff                                    |ext..|
```

**This completes a file definition.**

For larger lengths of linear sectors, there is an alternative format for
location data. It is {track number, '?' (0x3F), starting_sector, count}

For example, I currently have an image on the disk visualization that takes up
18 sectors, or a 6x3 block. It uses sectors 913-918, 1003-1008, and 1093-1098.

In the first format specified before ({track, sector}), each sector would
need to be specified one by one, like so:
```
Addr      Data (Hex)                                        Data (ASCII)
00000000  00 00 20 32 0d 32 0e 32  0f 32 10 32 11 33 00 37  |.. 2.2.2.2.2.3.7|
00000010  0d 37 0e 37 0f 37 10 37  11 38 00 3c 0d 3c 0e 3c  |.7.7.7.7.8.<.<.<|
00000020  0f 3c 10 3c 11 3d 00 74  61 6e 61 6b 61 2d 6b 75  |.<.<.=.tanaka-ku|
00000030  6e 2e 62 69 6e 00 ff                              |n.bin..|
```

However, this could be far simplified using the second format, like so:
```
Addr      Data (Hex)                                        Data (ASCII)
00000000  00 00 20 32 3f 0d 06 37  3f 0d 06 3c 3f 0d 06 74  |.. 2?..7?..<?..t|
00000010  61 6e 61 6b 61 2d 6b 75  6e 2e 62 69 6e 00 ff     |anaka-kun.bin..|
```

This also saves 24 bytes worth of data.

Here is a breakdown of the above:
```
HEX            ASCII             DESCRIPTION
\00\00\20      ...               Disk 0, Start at 0000, End at 01FF
\32\3f\0d\06   2?..              Track 0x32, '?', Sector 0x0d, Read 6 sectors
                                    (sectors 913-918)
\37\3f\0d\06   7?..              Track 0x37, '?', Sector 0x0d, Read 6 sectors
                                    (sectors 1003-1008)
\3c\3f\0d\06   <?..              Track 0x3c, '?', Sector 0x0d, Read 6 sectors
                                    (sectors 1093-1098)
{}             tanaka-kun.bin    Filename: tanaka-kun.bin
\00\ff         ..                End string, end file descriptor
```

Quick Reference:
```
Bytes  Description
1      Disk number. For now should only be zero
1      Beginning byte [n], where [ n * 16 ] is the first byte of the data
1      Ending byte [n], where [ n * 16 - 1 ] is the last byte of the data
*      {Location Information}
       --Format One (Useful for scattered data):
          {track_number, sector_number} ...
          Example: File on sectors 14, 17, 400, 629
          Hex: 00 0E  00 11  16 04  22 11
       --Format Two (Useful for blocks of linear data):
          {track number, '?' (0x3F), starting_sector, count}
          Example: File on sectors 913-918, 1003-1008, 1093-1098
          Hex: 32 3F 0D 06  37 3F 0D 06  3C 3F 0D 06
*     Filename
1     0x00 End of String
1     0xFF End of Descriptor
```

SEE ALSO: trackinfo, hex, fileinfo, sdist