Remove redundant file operation functions

This commit is contained in:
EnderIce2
2024-04-01 04:36:11 +03:00
parent bbb67b6a88
commit a49e5e9913
15 changed files with 153 additions and 320 deletions

View File

@ -42,16 +42,14 @@ void cmd_cat(const char *args)
return;
}
int fd = fopen(thisNode->FullPath, "r");
struct stat st;
fstat(fd, &st);
vfs::RefNode *fd = fs->Open(thisNode->FullPath);
char *buffer = new char[st.st_size + 1];
ssize_t rBytes = fread(fd, buffer, st.st_size);
uint8_t *buffer = new uint8_t[fd->Size + 1];
ssize_t rBytes = fd->read(buffer, fd->Size);
if (rBytes > 0)
printf("%s\n", buffer);
else
printf("cat: %s: Could not read file\n", args);
delete[] buffer;
fclose(fd);
delete fd;
}