Root/
Source at commit 1275 created 12 years 11 months ago. By meklort, Remove unused file. Fixup makefiles some more - boot2 compiles again. | |
---|---|
1 | /*␊ |
2 | * Copyright (c) 2011 Evan Lojewski. All rights reserved.␊ |
3 | *␊ |
4 | */␊ |
5 | #include <Disk.hpp>␊ |
6 | ␊ |
7 | Disk* Disk::gFirstDisk = NULL;␊ |
8 | ␊ |
9 | ␊ |
10 | Disk::Disk()␊ |
11 | {␊ |
12 | ␉mNextDisk = NULL;␊ |
13 | mName = NULL;␊ |
14 | mPartitions = NULL;␊ |
15 | ␊ |
16 | ␉// Add disk entry to list␊ |
17 | ␉␊ |
18 | ␉Disk* list = gFirstDisk;␊ |
19 | ␉if(!list) gFirstDisk = this;␊ |
20 | ␉else {␊ |
21 | ␉␉while(list->getNextDisk())␊ |
22 | ␉␉{␊ |
23 | ␉␉␉list = list->getNextDisk();␊ |
24 | ␉␉}␊ |
25 | ␉␉// Last disk found, add use to the end of the list␊ |
26 | ␉␉␊ |
27 | ␉␉list->setNextDisk(this);␊ |
28 | ␉}␊ |
29 | ␊ |
30 | }␊ |
31 | ␊ |
32 | Disk::~Disk()␊ |
33 | {␊ |
34 | ␉// remove disk entry from list␊ |
35 | ␉if(getPrevDisk() != NULL) getPrevDisk()->setNextDisk(getNextDisk());␊ |
36 | ␉else gFirstDisk = NULL;␊ |
37 | }␊ |
38 | ␊ |
39 | Partition* Disk::getPartition(UInt32 index)␊ |
40 | {␊ |
41 | PartitionList* current = mPartitions;␊ |
42 | while(current)␊ |
43 | {␊ |
44 | if(current->entry->getPartitionNumber() == index)␊ |
45 | {␊ |
46 | return current->entry;␊ |
47 | }␊ |
48 | else␊ |
49 | {␊ |
50 | current = current->next;␊ |
51 | }␊ |
52 | }␊ |
53 | ␊ |
54 | return NULL;␊ |
55 | }␊ |
56 | ␊ |
57 | void Disk::addPartition(Partition* partition)␊ |
58 | {␊ |
59 | PartitionList* list = new PartitionList;␊ |
60 | list->entry = partition;␊ |
61 | list->next = mPartitions;␊ |
62 | mPartitions = list;␊ |
63 | } |