Skip to content

Commit

Permalink
FINAL COMMIT
Browse files Browse the repository at this point in the history
  • Loading branch information
GoDillonAudris512 committed Apr 29, 2023
1 parent 05b4cc3 commit 0a9cae3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/user/cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ void copy(char* args_val, int (*args_info)[2], int args_count) {
};
memcpy(&(srcReq.name), srcName, 8);
memcpy(&(srcReq.ext), srcExt, 3);
uint32_t retCode;
int retCode;

interrupt(0, (uint32_t) &srcReq, (uint32_t) &retCode, 0x0);

Expand Down
14 changes: 12 additions & 2 deletions src/user/ls.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
void printDirectoryTable() {
for (int i = 1; i < 63; i++) {
if (dir_table.table[i].user_attribute == UATTR_NOT_EMPTY) {
put(dir_table.table[i].name, BIOS_LIGHT_BLUE);
if (dir_table.table[i].name[7] != '\0') {
putn(dir_table.table[i].name, BIOS_LIGHT_BLUE, 8);
}
else {
put(dir_table.table[i].name, BIOS_LIGHT_BLUE);
}
if (dir_table.table[i].attribute != ATTR_SUBDIRECTORY && strlen(dir_table.table[i].ext) != 0) {
put(".", BIOS_LIGHT_BLUE);
putn(dir_table.table[i].ext, BIOS_LIGHT_BLUE, 3);
Expand All @@ -18,7 +23,12 @@ void printDirectoryTable() {
}
}
if (dir_table.table[63].user_attribute == UATTR_NOT_EMPTY) {
put(dir_table.table[63].name, BIOS_LIGHT_BLUE);
if (dir_table.table[63].name[7] != '\0') {
putn(dir_table.table[63].name, BIOS_LIGHT_BLUE, 8);
}
else {
put(dir_table.table[63].name, BIOS_LIGHT_BLUE);
}
if (dir_table.table[63].attribute != ATTR_SUBDIRECTORY && strlen(dir_table.table[63].ext) != 0) {
put(".", BIOS_LIGHT_BLUE);
putn(dir_table.table[63].ext, BIOS_LIGHT_BLUE, 3);
Expand Down
19 changes: 10 additions & 9 deletions src/user/mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bool remove_mv(char* args_val, int (*args_info)[2], int args_count) {
bool directoryNotFound = FALSE;

// If path is not absolute, set the currently visited directory to current working directory
if (!isPathAbsolute(args_val, args_info, args_count-1)) {
if (!isPathAbsolute(args_val, args_info, args_count)) {
dest_search_directory_number = current_directory;
}

Expand Down Expand Up @@ -106,9 +106,9 @@ bool remove_mv(char* args_val, int (*args_info)[2], int args_count) {
i++;
}
if (i < lenName) { // Jika ada extension
if (lenName-i-1 > 3) { // Jika extension lebih dari 3 karakter
break;
}
if (lenName-i-1 > 3) { // Jika extension lebih dari 3 karakter
break;
}
memcpy(name, args_val + posName, i);
if (*(args_val + posName + i + 1) != 0x0A) {
memcpy(extension, args_val + posName + i + 1, lenName-i-1);
Expand Down Expand Up @@ -150,9 +150,10 @@ bool remove_mv(char* args_val, int (*args_info)[2], int args_count) {
.buffer_size = 0
};
memcpy(&(destReq.name), name, 8);
uint32_t retCode;
memcpy(&(destReq.ext), extension, 3);
uint32_t retCode = 0;

if (directoryNotFound) {
if (directoryNotFound || fileFound) {
// Check if it is a file or it doesnt exist
interrupt(3, (uint32_t) &destReq, (uint32_t) &retCode, 0x0);
if (retCode != 0) {
Expand All @@ -168,7 +169,6 @@ bool remove_mv(char* args_val, int (*args_info)[2], int args_count) {
}
return FALSE;
}
return TRUE;
}
else {
// Directory
Expand All @@ -190,10 +190,11 @@ bool remove_mv(char* args_val, int (*args_info)[2], int args_count) {
}
return FALSE;
}
return TRUE;
}
return TRUE;
}


bool copy_mv(char* args_val, int (*args_info)[2], int args_count) {
/* Searches if the destination exists and if it is a file or directory.
Returns 1 if it is a file, 0 if it is a directory, -1 if it is not found */
Expand Down Expand Up @@ -527,7 +528,7 @@ bool copy_mv(char* args_val, int (*args_info)[2], int args_count) {
};
memcpy(&(srcReq.name), srcName, 8);
memcpy(&(srcReq.ext), srcExt, 3);
uint32_t retCode;
int retCode = 0;

interrupt(0, (uint32_t) &srcReq, (uint32_t) &retCode, 0x0);

Expand Down
4 changes: 2 additions & 2 deletions src/user/rm.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ void remove(char* args_val, int (*args_info)[2], int args_count) {
};
memcpy(&(destReq.name), name, 8);
memcpy(&(destReq.ext), extension, 3);
uint32_t retCode;
int retCode = 0;

if (directoryNotFound) {
if (directoryNotFound || fileFound) {
// Check if it is a file or it doesnt exist
interrupt(3, (uint32_t) &destReq, (uint32_t) &retCode, 0x0);
if (retCode != 0) {
Expand Down

0 comments on commit 0a9cae3

Please sign in to comment.