Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions src/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,71 @@ void ShellExecuteCommand(char* p, bool* pbExit)
{
KePrintMemoryMapInfo();
}
else if (strcmp (token, "cp") == 0)
{
char* fileName = Tokenize (&state, NULL, " ");

char* fileName2 = Tokenize (&state, NULL, " ");
int fd = FiOpen(fileName, O_RDONLY);
Comment thread
isaacgravenor marked this conversation as resolved.
Outdated
if(fd<0) {
LogMsg("File not found: %s", fileName);
FiClose(fd);
return;
}
else {
Comment thread
isaacgravenor marked this conversation as resolved.
Outdated

FiSeek(fd, 0, SEEK_END);

unsigned int sz;
sz = FiTell(fd);
FiSeek(fd, 0, SEEK_SET);
char* data = (char*)MmAllocate(sz+1);
Comment thread
isaacgravenor marked this conversation as resolved.
Outdated
FiRead(fd, data, sz);
FiClose (fd);

fd = FiOpen(fileName2, O_CREAT | O_RDWR);
FiWrite(fd, data, sz);
FiClose (fd);
LogMsg("Done.");
return;
}
}

else if (strcmp (token, "mv") == 0)
{
char* fileName = Tokenize (&state, NULL, " ");
char* fileName2 = Tokenize (&state, NULL, " ");
int fd = FiOpen(fileName, O_RDONLY);
Comment thread
isaacgravenor marked this conversation as resolved.
Outdated
if(fd<0) {
LogMsg("File not found: %s", fileName);
FiClose(fd);
return;
}
else {

FiSeek(fd, 0, SEEK_END);

unsigned int sz;
sz = FiTell(fd);
FiSeek(fd, 0, SEEK_SET);
char* data = (char*)MmAllocate(sz+1);
Comment thread
isaacgravenor marked this conversation as resolved.
Outdated
FiRead(fd, data, sz);
FiClose (fd);

fd = FiOpen(fileName2, O_CREAT | O_RDWR);
FiWrite(fd, data, sz);
FiClose (fd);
// Get rid of the file.
int io = FiUnlinkFile (fileName);
Comment thread
isaacgravenor marked this conversation as resolved.
Outdated
if (io < 0)
{
LogMsg("mv: couldn't remove %s: %s", fileName, GetErrNoString(io));
return;
}

LogMsg("Done");
}
}
else if (strcmp (token, "ls") == 0)
{
enum
Expand Down