Skip to content

Commit

Permalink
Compute File Size is incorrect #11, thank you @alank2
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanizag committed Jan 2, 2024
1 parent 70cff27 commit c743b29
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/bdos_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,12 +491,11 @@ fn compute_file_size_internal(env: &mut BdosEnvironment, fcb: &Fcb) -> io::Resul

let file_size = os_file.metadata()?.len();
let mut record = file_size / RECORD_SIZE as u64;
if record % RECORD_SIZE as u64 != 0 {
if file_size % RECORD_SIZE as u64 != 0 {
// We need integer division rounding up.
record += 1;
}

record += 1;
if record >= 65536 {
record = 65536;
}
Expand Down

0 comments on commit c743b29

Please sign in to comment.