- erratic reading caused by using absolute instead of relative position, fixed
This commit is contained in:
		
							parent
							
								
									bcd655fd8d
								
							
						
					
					
						commit
						9363db67f8
					
				@ -487,7 +487,7 @@ uint32_t fat32_read_file_random_access(const Fat32_CtrlBlock *ctrl, const Fat32_
 | 
				
			|||||||
    // reading from a file may involve reading across cluster boundaries
 | 
					    // reading from a file may involve reading across cluster boundaries
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // 1. read the beginning from the first cluster
 | 
					    // 1. read the beginning from the first cluster
 | 
				
			||||||
    uint32_t first_read_len = MIN(read_len, ctrl->bytes_per_sector - pos);
 | 
					    uint32_t first_read_len = MIN(read_len, ctrl->bytes_per_sector - pos_in_sector);
 | 
				
			||||||
    memcpy(p, buffer + pos_in_sector, first_read_len);
 | 
					    memcpy(p, buffer + pos_in_sector, first_read_len);
 | 
				
			||||||
    read_len -= first_read_len; // decrease the total read len with the number of bytes read from the first sector of the file
 | 
					    read_len -= first_read_len; // decrease the total read len with the number of bytes read from the first sector of the file
 | 
				
			||||||
    offset += first_read_len; // advance offset
 | 
					    offset += first_read_len; // advance offset
 | 
				
			||||||
@ -619,7 +619,7 @@ uint32_t fat32_read_file_stream(const Fat32_CtrlBlock *ctrl, Fat32_FileHelper *f
 | 
				
			|||||||
    // reading from a file may involve reading across cluster boundaries
 | 
					    // reading from a file may involve reading across cluster boundaries
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // 1. read the beginning from the first cluster
 | 
					    // 1. read the beginning from the first cluster
 | 
				
			||||||
    uint32_t first_read_len = MIN(read_len, ctrl->bytes_per_sector - seek_hint->pos);
 | 
					    uint32_t first_read_len = MIN(read_len, ctrl->bytes_per_sector - pos_in_sector);
 | 
				
			||||||
    memcpy(p, buffer + pos_in_sector, first_read_len);
 | 
					    memcpy(p, buffer + pos_in_sector, first_read_len);
 | 
				
			||||||
    read_len -= first_read_len; // decrease the total read len with the number of bytes read from the first sector of the file
 | 
					    read_len -= first_read_len; // decrease the total read len with the number of bytes read from the first sector of the file
 | 
				
			||||||
    offset += first_read_len; // advance offset
 | 
					    offset += first_read_len; // advance offset
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user