Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package rs.raf.os.test;
- import rs.raf.os.fat.FAT16;
- import rs.raf.os.fat.FATException;
- public class MockFAT implements FAT16 {
- private int clusterWidth;
- private int clusterCount;
- private int[] clusterData;
- public MockFAT(int clusterWidth) {
- this.clusterWidth = clusterWidth;
- this.clusterCount = 0xFFED;
- }
- public MockFAT(int clusterWidth, int clusterCount) {
- if (clusterCount > 0xFFED) {
- System.err.println("Uneo si mnogo brt " + clusterCount);
- this.clusterCount = 0xFFED;
- }
- this.clusterWidth = clusterWidth;
- this.clusterCount = clusterCount;
- this.clusterData = new int[clusterCount + 2];
- }
- @Override
- public int getEndOfChain() {
- return 0xFFF8;
- }
- @Override
- public int getClusterCount() {
- return clusterCount;
- }
- @Override
- public int getClusterWidth() {
- return clusterWidth;
- }
- @Override
- public int readCluster(int clusterID) throws FATException {
- if (clusterID < 2 || clusterID >= clusterData.length) {
- throw new FATException("Ne valja read");
- }
- return clusterData[clusterID];
- }
- @Override
- public void writeCluster(int clusterID, int valueToWrite) throws FATException {
- if (clusterID < 2 || clusterID >= clusterData.length) {
- throw new FATException("Ne valja write");
- }
- if (valueToWrite > 0xFFED && valueToWrite != 0xFFF8) {
- throw new FATException("Ne valja write 2");
- }
- clusterData[clusterID] = valueToWrite;
- }
- @Override
- public String getString() {
- StringBuilder sb = new StringBuilder();
- sb.append("[");
- for (int i = 2; i < clusterData.length - 1; i++)
- sb.append(clusterData[i] + "|");
- sb.append(clusterData[clusterData.length - 1] + "]");
- return sb.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement