2 JPC-RR: A x86 PC Hardware Emulator
5 Copyright (C) 2007-2009 Isis Innovation Limited
6 Copyright (C) 2009 H. Ilari Liusvaara
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 2 as published by
10 the Free Software Foundation.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 Based on JPC x86 PC Hardware emulator,
22 A project from the Physics Dept, The University of Oxford
24 Details about original JPC can be found at:
26 www-jpc.physics.ox.ac.uk
30 package org
.jpc
.diskimages
;
35 public abstract class TreeFile
37 protected int clusterSize
; //In sectors.
38 protected int startCluster
; //Root directory can have this negative!!!
39 protected int clusterZeroOffset
; //Quite purely abstract concept. Two cluster sizes before data area start.
40 protected String selfName
;
41 protected TreeFile parent
;
43 protected TreeFile(String self
)
47 clusterZeroOffset
= 0;
52 protected String
getSelfName()
57 protected void parentTo(TreeFile newParent
)
62 protected void doSetClusterSize(int cluster
)
64 clusterSize
= cluster
;
67 public int getClusterSize()
72 protected void setStartCluster(int cluster
)
74 startCluster
= cluster
;
77 public int getStartCluster()
82 public int getEndCluster()
84 return startCluster
+ getSizeInClusters() - 1;
87 protected void doSetClusterZeroOffset(int offset
)
89 clusterZeroOffset
= offset
;
92 public int getSizeInClusters()
94 int sectors
= getSizeInSectors();
95 return (sectors
+ clusterSize
- 1) / clusterSize
;
98 public int getSizeInSectors()
100 int bytes
= getSize();
101 return (bytes
+ 511) / 512;
104 //Recurse and call doSetClusterZeroOffset().
105 public abstract void setClusterZeroOffset(int offset
);
106 //Recurse and call doSetClusterSize().
107 public abstract void setClusterSize(int size
);
108 //Return all-zeroes after file has ended.
109 public abstract void readSector(int sector
, byte[] data
) throws IOException
;
110 //Hint that readSectors have ended.
111 public abstract void readSectorEnd();
112 //Recursively assign clusters to files. Call setStartCluster(base) and return next cluster number.
113 public abstract int assignCluster(int base
);
114 //Return next entry in tree, or null if none exists.
115 public abstract TreeFile
nextFile();
116 //Return next entry from given one.
117 protected abstract TreeFile
nextFile(String key
);
119 public abstract void addFile(TreeFile newFile
) throws Exception
;
120 //Get true size of file.
121 public abstract int getSize();
123 public abstract List
<String
> getComments(String prefix
, String timestamp
);