astrors-fork 0.1.9

(FORK) Astronomical package to deal with FITS (compressed also) and WCS, still in development.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use std::io::{self, Read, Seek, SeekFrom};
use std::fs::File;

pub fn buffer_has_more_data(file: &mut File) -> io::Result<bool> {
    let current_pos = file.seek(SeekFrom::Current(0))?; // Save current position

    let mut buffer = [0; 1]; // Small buffer to attempt reading
    let bytes_read = file.read(&mut buffer)?; // Attempt to read

    file.seek(SeekFrom::Start(current_pos))?; // Restore original position

    Ok(bytes_read != 0) // If bytes_read is 0, we're at EOF
}