Skip to content

Commit

Permalink
bug fix in function to calculate the offset to a cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
KleyLima committed Jul 16, 2020
1 parent d3aa869 commit ca30bd5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/ram.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def new_file(self):
self.files.append(File(fat_map=self.fat.dump))

def calc_offset_to_cluster(self):
cluster = input("Input the cluster that you want the offset to(hex): ")
cluster = input("Input the cluster that you want the offset to(hex): ").upper()
offset = Hex.calc_cluster_hex(reserved_area_size=self.reserved_area_size.vl_hex, fats_size=self.fats_size.vl_hex
, root_dir_size=self.root_dir_size.vl_hex, cluster=cluster,
cluster_size=self.bytes_sector_hex.vl_hex)
Expand Down
1 change: 1 addition & 0 deletions utils/hex.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def calc_by_bc(self, other):
@staticmethod
def calc_cluster_hex(reserved_area_size, fats_size, root_dir_size, cluster, cluster_size):
cmd = f"echo 'obase=16;ibase=16;{reserved_area_size}+{fats_size}+{root_dir_size}+(({cluster}-2)*{cluster_size})' | bc"
print(f"PG({cluster})= {reserved_area_size}+{fats_size}+{root_dir_size}+(({cluster}-2)*{cluster_size})")
out = subprocess.run(cmd, stdout=subprocess.PIPE, shell=True)
return out.stdout.decode('utf-8')[:-1]

Expand Down

0 comments on commit ca30bd5

Please sign in to comment.