still trying to read a file
This commit is contained in:
+21
-7
@@ -1,6 +1,7 @@
|
||||
#include "../include/vfs.h"
|
||||
#include "../include/stdio.h"
|
||||
#include "../include/string.h"
|
||||
#include "../include/paging.h"
|
||||
|
||||
l9660_fs global_fs;
|
||||
|
||||
@@ -48,25 +49,38 @@ void list_files(l9660_dir *dir)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
size_t vfs_read_file(l9660_file *file, uint8_t* buffer)
|
||||
//TODO: fix invalid opcode exception that somehow happens when the memcpy is called with buffer+total_read address being 0xE0008CA0
|
||||
size_t vfs_read_file(l9660_file *file, uint8_t* buffer, size_t final_size)
|
||||
{
|
||||
size_t total_read = 0;
|
||||
l9660_status status;
|
||||
|
||||
for(;;) {
|
||||
char buf[128];
|
||||
size_t read;
|
||||
l9660_read(file, buf, 128, &read);
|
||||
status = l9660_read(file, buf, 128, &read);
|
||||
|
||||
if (status != L9660_OK) {
|
||||
printf("An error occurred during file read!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
printf("total_read: %X status: %X buffer+total_read: %X/%X read: %X\n", total_read, status, buffer + total_read, final_size, read);
|
||||
if(buffer+total_read == 0xE0008CA0)
|
||||
{
|
||||
printf("ERROR ERROR\n");
|
||||
printf("get_physaddr: %X", get_physaddr((void*)0xE0008CA0));
|
||||
}
|
||||
|
||||
//check for EOF
|
||||
if (read == 0)
|
||||
break;
|
||||
|
||||
memcpy(buffer, buf, 128);
|
||||
buffer += 128;
|
||||
memcpy(buffer + total_read, buf, read);
|
||||
total_read += read;
|
||||
}
|
||||
|
||||
//reset the current position to the original position
|
||||
buffer -= total_read;
|
||||
printf("total_read: %X\n", total_read);
|
||||
|
||||
return total_read;
|
||||
}
|
||||
Reference in New Issue
Block a user