h6. [[FileCore]] h6(. » [[FileCore Technical Details|Technical Details]] h6((. » Directories h2(#dirs). Directories h3(#dirtypes). Types of Directories There are two different types of directories that [[FileCore]] currently supports. They are: table(bordered). |_<^{width:12em}. Directories |_<^{width:12em}. Size (entries) |_<^{width:12em}. Size (bytes) |_<^{width:12em}. Top bit set chars | |<^. "Old":#formatold |<^. 47 |<^. 1280 |<^. No | |<^. "New":#formatnew |<^. 77 |<^. 2048 |<^. Yes | Both Diretory Types are very similar in their structure, but with subtle differences. Both are detailed separately so they can be understood more easily. h3(#formatold). Format of Old Directory Type The directory format is as follows: table(bordered). |_<^{width:12em}. Data Field |_<^. Description | |<^. "DirHeader":#olddirhead|<^. Specifies the start of a Directory | |<^. "Entries":#oldentries [__n__][1] |<^. Specifies attributes such as Load/Address and Read/Write access for each entry| |<^. "DirTail":#olddirtail |<^. Specifies other miscellaneous attributes such as name and disc address of parent | fn1. Where _n_ = 47 h4(#olddirhead). DirHeaders table(bordered). |_<^{width:12em}. Name |_<^{width:4em}. Bytes |_<^. Meaning | |<^. StartMasSeq |<^. 1 |<^. Update sequence number to check dir start with dir end | |<^. StartName |<^. 4 |<^. 'Hugo' or 'Nick'[2] | fn2. For reasons of compatability, "L-format":FileCore%20Overview#discformats discs should use 'Hugo'. For all other formats, either 'Nick' or 'Hugo' can be used. h4(#oldentries). Entries table(bordered). |_<^{width:12em}. Name |_<^{width:4em}. Bytes |_<^. Meaning | |<^. DirObName |<^. 10 |<^. Name of object | |<^. DirLoad |<^. 4 |<^. Load address of object | |<^. DirExec |<^. 4 |<^. Exec address of object | |<^. DirLen |<^. 4 |<^. Length of object | |<^. DirIndDiscAdd |<^. 3 |<^. Indirect disc address of object | |<^. OldDirObSeq |<^. 1 |<^. ??? | h4(#olddirtail). DirTails table(bordered). |_<^{width:12em}. Name |_<^{width:4em}. Bytes |_<^. Meaning | |<^. OldDirLastMark |<^. 1 |<^. 0 to indicate end of entries | |<^. OldDirName |<^. 10 |<^. Directory name | |<^. OldDirParent |<^. 3 |<^. Indirect disc address of parent directory | |<^. OldDirTitle |<^. 19 |<^. Directory title | |<^. Reserved |<^. 14 |<^. Reserved – must be zero | |<^. EndMasSeq |<^. 1 |<^. To match with StartMasSeq | |<^. EndName |<^. 4 |<^. 'Hugo' or 'Nick', to match with StartName | |<^. DirCheckByte |<^. 1 |<^. Check byte on directory | <br /> h3(#formatnew). Format of New Directory Type The directory format is as follows: table(bordered). |_<^{width:12em}. Data Field |_<^. Description | |<^. "DirHeader":#newdirhead|<^. Specifies the start of a Directory | |<^. "Entries":#newentries [__n__][3] |<^. Specifies attributes such as Load/Address and Read/Write access for each entry| |<^. "DirTail":#newdirtail |<^. Specifies other miscellaneous attributes such as name and disc address of parent | fn3. Where _n_ = 77 h4(#newdirhead). DirHeaders table(bordered). |_<^{width:12em}. Name |_<^{width:4em}. Bytes |_<^. Meaning | |<^. StartMasSeq |<^. 1 |<^. Update sequence number to check dir start with dir end | |<^. StartName |<^. 4 |<^. 'Hugo' or 'Nick'[4] | fn4. For reasons of compatability, "L-format":FileCore%20Overview#discformats discs should use 'Hugo'. For all other formats, either 'Nick' or 'Hugo' can be used. h4(#newentries). Entries table(bordered). |_<^{width:12em}. Name |_<^{width:4em}. Bytes |_<^. Meaning | |<^. DirObName |<^. 10 |<^. Name of object | |<^. DirLoad |<^. 4 |<^. Load address of object | |<^. DirExec |<^. 4 |<^. Exec address of object | |<^. DirLen |<^. 4 |<^. Length of object | |<^. DirIndDiscAdd |<^. 3 |<^. Indirect disc address of object | |<^. NewDirAtts |<^. 1 |<^. Object attributes | h4. NewDirAtts Format table(bordered). |_<^{width:4em}. Bit |_<^. Meaning when set | |<^. 0 |<^. Object has owner read access | |<^. 1 |<^. Object has ownver write access | |<^. 2 |<^. Object is locked | |<^. 3 |<^. Object is a directory | |<^. 4 |<^. Object is executable[5] | |<^. 5 |<^. Object has public read access | |<^. 6 |<^. Object has public write access | |<^. 7 |<^. Reserved (must be zero) | fn5. Bit 4 is treated as a second owner read bit; if either this bit or bit 0 are set, the object is treated as having owner read access h4(#newdirtail). DirTails table(bordered). |_<^{width:12em}. Name |_<^{width:4em}. Bytes |_<^. Meaning | |<^. NewDirLastMark |<^. 1 |<^. 0 to indicate end of entries | |<^. Reserved |<^. 2 |<^. Reserved – must be zero | |<^. NewDirParent |<^. 3 |<^. Indirect disc address of parent directory | |<^. NewDirTitle |<^. 19 |<^. Directory title | |<^. NewDirName |<^. 10 |<^. Directory name | |<^. EndMasSeq |<^. 1 |<^. To match with StartMasSeq | |<^. EndName |<^. 4 |<^. 'Hugo' or 'Nick', to match with StartName | |<^. DirCheckByte |<^. 1 |<^. Check byte on directory | <br /> h4. Notes The last entry is indicated by there being a 0 in the first byte of the next entry’s DirObName. The xxxDirLastMark entry is there so that when the directory is full, and hence the last entry is not followed by a null DirObName, it is still followed by a null byte to indicate the end of the directory. DirObNames and DirNames are control character terminated, and may be the full length of the fields they occupy (in which case there is no terminator). The indirect disc address of an object on an old map disc is the most significant 3 bytes of its physical disc address. The indirect disc address of an object on a new map disc is the least significant 3 bytes of its internal disc address. <br /> h2(#calc). Calculations h3(#calcmasseq). Calculating StartMasSeq and EndMasSeq StartMasSeq and EndMasSeq are there to check whether the directory was completely written out when it was last written out. For an unbroken directory they are always equal, and are increased by one (wrapping at 255 back to 0) whenever the directory is updated. This means that if the writing of the directory was stopped halfway through then the start and end master sequence numbers will not be the same, and so the directory will then be identified as broken. Their values should equal each other, but, apart from that, they can be anything. <br /> h3(#calcdircheckbyte). Calculating DirCheckByte This is an accumulation of the used bytes in a directory. The used bytes are all the bytes excluding the hole between the last directory entry and the beginning of the structure at the tail of the directory. The generation of the check byte is best described as an algorithm: Starting at 0 an accumulation process is performed on a number of values. Whatever the sort of the value (byte or word) it is accumulated in the same way. Assuming r0 is the accumulation register and r1 the value to accumulate this is the accumulation performed: <pre>EOR r0, r1, r0, ROR #13</pre> * All the whole words at the start of the directory are accumulated. This will leave a number of bytes (0 to 3) in the last directory entry (or at the end of the start structure in a directory if it’s empty) * The last few bytes at the start of the directory are accumulated individually * The first few bytes at the beginning of the end structure of the directory are accumulated. This is done to leave only a whole number of words left in the directory to be accumulated * The last whole words in the directory are accumulated, except the very last word which is excluded as it contains the check byte * The accumulated word has its four bytes exclusive ORd (EOR) together. This value is the check byte