- fat32: returning -1 on file open failure
This commit is contained in:
		
							parent
							
								
									d07827a66a
								
							
						
					
					
						commit
						4d2118023e
					
				@ -520,9 +520,21 @@ uint32_t fat32_read_file_random_access(const Fat32_CtrlBlock *ctrl, const Fat32_
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// -----------------
 | 
					// -----------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Open file.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * @param ctrl pointer to FAT32 control block
 | 
				
			||||||
 | 
					 * @param path full file path
 | 
				
			||||||
 | 
					 * @param file_helper pointer to file helper object
 | 
				
			||||||
 | 
					 * @return int 0 if successful, -1 on failure
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
int fat32_open_file(const Fat32_CtrlBlock *ctrl, const char *path, Fat32_FileHelper *file_helper) {
 | 
					int fat32_open_file(const Fat32_CtrlBlock *ctrl, const char *path, Fat32_FileHelper *file_helper) {
 | 
				
			||||||
    uint32_t file_entry_ba;
 | 
					    uint32_t file_entry_ba;
 | 
				
			||||||
    const Fat32_FileEntry *entry = fat32_locate_file(ctrl, path, &file_entry_ba);
 | 
					    const Fat32_FileEntry *entry = fat32_locate_file(ctrl, path, &file_entry_ba);
 | 
				
			||||||
 | 
					    if (entry == NULL) { // if cannot open file, then return -1
 | 
				
			||||||
 | 
					        return -1;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    uint32_t first_cluster = fat32_get_first_cluster(entry);
 | 
					    uint32_t first_cluster = fat32_get_first_cluster(entry);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // store data usable for identifying file on the storage
 | 
					    // store data usable for identifying file on the storage
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user