mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 21:30:04 +00:00 
			
		
		
		
	service/fs: Update file size on write
The file's size is stored in FileSessionSlot and retrieved when the game calls GetSize. However, it is not updated when the file is written to, which can possibly change the file size. Therefore, this can cause GetSize to return incorrect results.
This commit is contained in:
		
							parent
							
								
									cd46e62ad4
								
							
						
					
					
						commit
						fc251b32b0
					
				
					 1 changed files with 5 additions and 1 deletions
				
			
		|  | @ -90,7 +90,7 @@ void File::Write(Kernel::HLERequestContext& ctx) { | ||||||
| 
 | 
 | ||||||
|     IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); |     IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); | ||||||
| 
 | 
 | ||||||
|     const FileSessionSlot* file = GetSessionData(ctx.Session()); |     FileSessionSlot* file = GetSessionData(ctx.Session()); | ||||||
| 
 | 
 | ||||||
|     // Subfiles can not be written to
 |     // Subfiles can not be written to
 | ||||||
|     if (file->subfile) { |     if (file->subfile) { | ||||||
|  | @ -103,6 +103,10 @@ void File::Write(Kernel::HLERequestContext& ctx) { | ||||||
|     std::vector<u8> data(length); |     std::vector<u8> data(length); | ||||||
|     buffer.Read(data.data(), 0, data.size()); |     buffer.Read(data.data(), 0, data.size()); | ||||||
|     ResultVal<std::size_t> written = backend->Write(offset, data.size(), flush != 0, data.data()); |     ResultVal<std::size_t> written = backend->Write(offset, data.size(), flush != 0, data.data()); | ||||||
|  | 
 | ||||||
|  |     // Update file size
 | ||||||
|  |     file->size = backend->GetSize(); | ||||||
|  | 
 | ||||||
|     if (written.Failed()) { |     if (written.Failed()) { | ||||||
|         rb.Push(written.Code()); |         rb.Push(written.Code()); | ||||||
|         rb.Push<u32>(0); |         rb.Push<u32>(0); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue