	MAKE A TREE OUT OF A MESS HARD DISK
	===================================

Disclaimer: I haven't studied any official tree method.
	    The experienced programmer will be horrified
	    by my approach to the problem. 
	    However.....  :-)

This project will try to build a 
a file representating a tree of 
a Mess Hard Disk Structure. 



The user will be able to navigate the tree. 
Most of all, having all the files contained in the tree, 
an automated recursive operation 
on all the files forming the hard disk 
will then be possible. Thus, extracting 
all the files from a Mess Hard Disk will be 
just one single operation.


Abbreviations: 

	DW=double word (32 bits)
	SW=single word (16 bits)
	

Each entry in the tree will represent either a Directory 
or a File. Rather, a pointer to the sector 
containing the Directory or the File will be saved. 
Other vital parameters will be saved on each entry, 
see list below. 


Logic: 

1) For each Directory found on the Hard Disk, all the
   Sub-Directories wil be saved first, and only 
   then will the Files be saved. 

   
2) Next, the first Directory will be taken. 

3) The "Pending Operation" field on its 
   Parent Directory will be marked 
   with 1=Directory under inspection.
   
4) Again, the SubDirectory number (1, 2, 3....)
   will be marked on the "Pending Operation on what directory"
   field on its Parent Directory. If the "Pending Operation 
   on what directory"field on its Parent Directory is zero
   this means that no operation is in progress in any
   SubDirectory.
   
5) All the Directories and Files 
   pertaining to this new SubDirectory will be 
   saved. 
   
6) This process continues until no more SubDirectories 
   are found. Now we will zero-in the 
   "Pending Operation on what directory" and the 
   "Pending Operation" fields in the current  
   directory. Next, we will get back to the last parent Directory,
   and process the next SubDirectory still undone, if it exists. 
   If there is one, mark its number on the "Pending Operation on what directory"
   field e process the next Subdirectory. Otherwise, if there is none,
   mark zero on both the "Pending Operation" and the 
   "Pending Operation on what directory" fields and 
   get back to the Parent Directory again.
   
7) Go on until all the SubDirectories are fully inspected. 

8) Write a routine to erase all the "Pending Operation on what directory"  
   and "Pending Operation" fields.

 
Field Lengths
=============

Each Directory is 34 bytes long +
		   8 bytes for each First Level Subdirectory +
		  14 bytes for each File  


Note
====

1)   The actual Directory and File ASCII names might have been left out
     of this tree, since they could be easily obtained from the real
     hard disk. Nonetheless, they have been added because they greatly
     improve the debugging and readability of the program. 
     
2)   The ongoing operation can be interrupted, and easily resumed later on.
     Marks will be left on the tree that will make resuming easy. 

3)   All numeric values will be stored as follows:
	SW = Single Word, as Microsoft QB Integer (2 bytes), abbreviation=%
	DW = Double Word, as Microsoft QB Long Integer (4 bytes), abbreviation=&. 


	+ DIRECTORY 1 <------------------------------------------------------------------------------+
0000    DW Progressive Entry Number (TreeIndex)                                                      |
0004	DW Sub-Directory Name - Pointer to the sector containing it                                  |
0008    DW Parent Directory - Absolute Pointer to it in this structure (Byte Position)- Zero if Root |
000C    SW Total One-level SubDirectories                                                            |
000E	SW Total Files Pertaining to this Directory                                                  |
0010    SW Pending Operation on what directory (1, 2, 3, ... and so on)                              |
0012    SW Pending operation type                                                                    |
0014    10 Bytes = Sub-Directory Name, in ASCII                                                      |
001E    DW .... spare space                                                                          |
0022    ....                                                                                         |
                                                                                                     |                                                                                                     
0022    DW Absolute Pointer to Sub-Directory 1 - Pointer to the sector containing it  
0026    DW Absolute Pointer to Sub-Directory 1 in this structure (Byte Position) >--------------+    |
002A    DW Absolute Pointer to Sub-Directory 2 - Pointer to the sector containing it            |    |
002E    DW Absolute Pointer to Sub-Directory 2 in this structure (Byte Position)                |    |
0032    DW Absolute Pointer to Sub-Directory 3 - Pointer to the sector containing it            |    |
0036    DW Absolute Pointer to Sub-Directory 3 in this structure (Byte Position)                |    |                    
003A    DW Absolute Pointer to Sub-Directory 4 - Pointer to the sector containing it            |    |
003E    DW Absolute Pointer to Sub-Directory 4 in this structure (Byte Position)                |    |
0042	DW Pointer to the sector containing the the File Name 1 (FDR)                           |    |
0046    10 Bytes = File Name, in ASCII                                                          |    |
0050	DW Pointer to the sector containing the the File Name 2 (FDR)                           |    |
0054    10 Bytes = File Name, in ASCII                                                          |    |
005E	DW Pointer to the sector containing the the File Name 3 (FDR)                           |    |
0062    10 Bytes = File Name, in ASCII                                                          |    |
006C	DW Pointer to the sector containing the the File Name 4 (FDR)                           |    |
0070    10 Bytes = File Name, in ASCII                                                          |    |
0074	DW Pointer to the sector containing the the File Name 5 (FDR)                           |    |
007E    10 Bytes = File Name, in ASCII                                                          |    |
                                                                                                |    |
                                                                                                |    |                                                                                        
                                                                                                |    |
	+ SUB-DIRECTORY 1  <--------------------------------------------------------------------+    |
0000    DW Progressive Entry Number  (TreeIndex)                                                     |
0004	DW Sub-Directory Name - Pointer to the sector containing it                                  |
0008    DW Parent Directory - Absolute Pointer to it in this structure (Byte Position)  >------------+
000C    SW Total One-level SubDirectories                                       
000E	SW Total Files Pertaining to this Sub-Directory                             
0010    SW Pending Operation on what directory (1, 2, 3, ... and so on)         
0012    SW Pending operation type                                               
0014    10 Bytes = Sub-Directory Name, in ASCII     
001E    DW .... spare space                         
0022    ....     


                                                   
                                                                                
0022    DW Absolute Pointer to Sub-Directory 1 - Pointer to the sector containing it  
0026    DW Absolute Pointer to Sub-Directory 1 in this structure (Byte Position)               
002A    DW Absolute Pointer to Sub-Directory 2 - Pointer to the sector containing it           
002E    DW Absolute Pointer to Sub-Directory 2 in this structure (Byte Position)               
0032    DW Absolute Pointer to Sub-Directory 3 - Pointer to the sector containing it           
0036    DW Absolute Pointer to Sub-Directory 3 in this structure (Byte Position)                        
003A    DW Absolute Pointer to Sub-Directory 4 - Pointer to the sector containing it           
003E    DW Absolute Pointer to Sub-Directory 4 in this structure (Byte Position)               
0042	DW Pointer to the sector containing the the File Name 1 (FDR)                          
0046    10 Bytes = File Name, in ASCII                                                         
0050	DW Pointer to the sector containing the the File Name 2 (FDR)                          
0054    10 Bytes = File Name, in ASCII                                                         
005E	DW Pointer to the sector containing the the File Name 3 (FDR)                          
0062    10 Bytes = File Name, in ASCII                                                         
006C	DW Pointer to the sector containing the the File Name 4 (FDR)                          
0070    10 Bytes = File Name, in ASCII                                                         
0074	DW Pointer to the sector containing the the File Name 5 (FDR)                          
007E    10 Bytes = File Name, in ASCII                                                         
   
   
   
   
   Paolo Bagnaresi, 2003 - paolo.bagnaresi@fastwebnet.it       