mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-10 23:09:18 +00:00
Remove redundant file operation functions
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
@ -167,11 +167,10 @@ void StartKernelShell()
|
||||
bool upperCase = false;
|
||||
bool tabDblPress = false;
|
||||
|
||||
int kfd = fopen("/dev/key", "r");
|
||||
if (kfd < 0)
|
||||
vfs::RefNode *kfd = fs->Open("/dev/key");
|
||||
if (kfd == nullptr)
|
||||
{
|
||||
KPrint("Failed to open keyboard device! %s",
|
||||
strerror(kfd));
|
||||
KPrint("Failed to open keyboard device!");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -216,7 +215,7 @@ void StartKernelShell()
|
||||
CurY.store(__cy);
|
||||
CurHalt.store(false);
|
||||
|
||||
nBytes = fread(kfd, scBuf, 2);
|
||||
nBytes = kfd->read(scBuf, 2);
|
||||
if (nBytes == 0)
|
||||
continue;
|
||||
if (nBytes < 0)
|
||||
|
Reference in New Issue
Block a user