Stream a file (only works for uncompressed files)
(&self, path: &str)
| 108 | |
| 109 | /// Get a direct slice (only works for uncompressed files) |
| 110 | pub fn get_file_slice(&self, path: &str) -> io::Result<&[u8]> { |
| 111 | let entry = self |
| 112 | .index |
| 113 | .get(path) |
| 114 | .ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, "File not found"))?; |
| 115 | |
| 116 | if entry.flags & FLAG_COMPRESSED != 0 { |
| 117 | return Err(io::Error::other( |
| 118 | "Cannot get slice of compressed file (use read_file)", |
| 119 | )); |
| 120 | } |
| 121 | |
| 122 | let range = checked_entry_range(self.data.len(), entry)?; |
| 123 | Ok(&self.data[range]) |
| 124 | } |
| 125 | |
| 126 | /// Stream a file (only works for uncompressed files) |
| 127 | pub fn stream_file(&self, path: &str) -> io::Result<PerroAssetsFile> { |
| 128 | let entry = self |
| 129 | .index |
| 130 | .get(path) |
| 131 | .ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, "File not found"))?; |
| 132 |
no test coverage detected