DIR improvements
Added drive label and file size.
This commit is contained in:
parent
b0ba6e4c0a
commit
2c374335ab
|
@ -44,20 +44,23 @@ const t_cli_command g_cli_commands[] = {
|
|||
{ "?", "? -- print this helpful message", cmd_help },
|
||||
{ "HELP", "HELP -- print this helpful message", cmd_help },
|
||||
{ "CLS", "CLS -- clear the screen", cmd_cls },
|
||||
// { "DEL", "DEL <path> -- delete a file or directory", cmd_del },
|
||||
{ "DIR", "DIR <path> -- print directory listing", cmd_dir },
|
||||
{ "DUMP", "DUMP <address> [<count>] -- print a memory dump", mem_cmd_dump},
|
||||
{ "LOAD", "LOAD <path> -- load a file into memory", cmd_load },
|
||||
{ "PEEK8", "PEEK8 <address> -- print the byte at the address in memory", mem_cmd_peek8},
|
||||
{ "PEEK16", "PEEK16 <address> -- print the 16-bit word at the address in memory", mem_cmd_peek16},
|
||||
{ "PEEK32", "PEEK32 <address> -- print the 32-bit long word at the address in memory", mem_cmd_peek32},
|
||||
{ "POKE8", "POKE8 <address> <value> -- write the byte value to the address in memory", mem_cmd_poke8},
|
||||
{ "POKE16", "POKE16 <address> <value> -- write the 16-bit word value to the address in memory", mem_cmd_poke16},
|
||||
{ "POKE32", "POKE32 <address> <value> -- write the 32-bit long word value to the address in memory", mem_cmd_poke32},
|
||||
// { "MKDIR", "MKDIR <path> -- create a directory", cmd_mkdir },
|
||||
{ "PEEK8", "PEEK8 <address> -- print the byte at the address in memory", mem_cmd_peek8 },
|
||||
{ "PEEK16", "PEEK16 <address> -- print the 16-bit word at the address in memory", mem_cmd_peek16 },
|
||||
{ "PEEK32", "PEEK32 <address> -- print the 32-bit long word at the address in memory", mem_cmd_peek32 },
|
||||
{ "POKE8", "POKE8 <address> <value> -- write the byte value to the address in memory", mem_cmd_poke8 },
|
||||
{ "POKE16", "POKE16 <address> <value> -- write the 16-bit word value to the address in memory", mem_cmd_poke16 },
|
||||
{ "POKE32", "POKE32 <address> <value> -- write the 32-bit long word value to the address in memory", mem_cmd_poke32 },
|
||||
// { "REN", "REN <old path> <new path> -- rename a file or directory", cmd_rename },
|
||||
{ "RUN", "RUN <path> -- execute a binary file", cmd_run },
|
||||
{ "GETTIME", "GETTIME -- prints the current time", cmd_gettime },
|
||||
{ "SETTIME", "SETTIME -- sets the current time", cmd_settime },
|
||||
{ "SYSINFO", "SYSINFO -- prints information about the system", cmd_sysinfo },
|
||||
{ "TESTIDE", "TESTIDE -- fetches and prints the IDE MBR repeatedly", cmd_testide},
|
||||
{ "TESTIDE", "TESTIDE -- fetches and prints the IDE MBR repeatedly", cmd_testide },
|
||||
{ "TYPE", "TYPE <path> -- print the contents of a text file", cmd_type },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
|
|
@ -55,9 +55,66 @@ short cmd_run(short screen, int argc, char * argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a directory
|
||||
*/
|
||||
short cmd_mkdir(short screen, int argc, char * argv[]) {
|
||||
|
||||
TRACE("cmd_mkdir");
|
||||
|
||||
if (argc > 1) {
|
||||
short result = fsys_mkdir(argv[1]);
|
||||
if (result < 0) {
|
||||
log_num(LOG_ERROR, "Unable to create directory: ", result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Delete a file
|
||||
*/
|
||||
short cmd_del(short screen, int argc, char * argv[]) {
|
||||
|
||||
TRACE("cmd_del");
|
||||
|
||||
if (argc > 1) {
|
||||
short result = fsys_delete(argv[1]);
|
||||
if (result < 0) {
|
||||
log_num(LOG_ERROR, "Unable to delete: ", result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Rename a file or directory
|
||||
*/
|
||||
extern short cmd_rename(short screen, int argc, char * argv[]) {
|
||||
|
||||
TRACE("cmd_rename");
|
||||
|
||||
if (argc > 2) {
|
||||
short result = fsys_rename(argv[1], argv[2]);
|
||||
if (result < 0) {
|
||||
log_num(LOG_ERROR, "Unable to rename: ", result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
short cmd_dir(short screen, int argc, char * argv[]) {
|
||||
short result;
|
||||
char buffer[80];
|
||||
t_file_info my_file;
|
||||
char * path = "";
|
||||
char label[40];
|
||||
|
||||
log_num(LOG_INFO, "cmd_dir: ", argc);
|
||||
|
||||
|
@ -68,15 +125,30 @@ short cmd_dir(short screen, int argc, char * argv[]) {
|
|||
log3(LOG_INFO, "Attempting to read directory for [", path, "]\n");
|
||||
short dir = fsys_opendir(path);
|
||||
if (dir >= 0) {
|
||||
result = fsys_getlabel(path, label);
|
||||
if ((result == 0) && (strlen(label) > 0)) {
|
||||
sprintf(buffer, "Drive: %s\n", label);
|
||||
chan_write(screen, buffer, strlen(buffer));
|
||||
}
|
||||
|
||||
while (1) {
|
||||
short result = fsys_readdir(dir, &my_file);
|
||||
if ((result == 0) && (my_file.name[0] != 0)) {
|
||||
|
||||
if ((my_file.attributes & AM_HID) == 0) {
|
||||
print(screen, my_file.name);
|
||||
if (my_file.attributes & AM_DIR) {
|
||||
print(screen, "/");
|
||||
sprintf(buffer, "%s/\n", my_file.name);
|
||||
|
||||
} else {
|
||||
if (my_file.size < 1024) {
|
||||
sprintf(buffer, "%-20.20s %d\n", my_file.name, (int)my_file.size);
|
||||
} else if (my_file.size < 1024*1024) {
|
||||
sprintf(buffer, "%-20.20s %d KB\n", my_file.name, (int)my_file.size / 1024);
|
||||
} else {
|
||||
sprintf(buffer, "%-29.20s %d MB\n", my_file.name, (int)my_file.size / (1024*1024));
|
||||
}
|
||||
chan_write(screen, buffer, strlen(buffer));
|
||||
}
|
||||
print(screen, "\n");
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
|
|
|
@ -20,6 +20,21 @@ extern short cmd_run(short screen, int argc, char * argv[]);
|
|||
*/
|
||||
extern short cmd_dir(short screen, int argc, char * argv[]);
|
||||
|
||||
/*
|
||||
* Create a directory
|
||||
*/
|
||||
extern short cmd_mkdir(short screen, int argc, char * argv[]);
|
||||
|
||||
/*
|
||||
* Delete a file or directory
|
||||
*/
|
||||
extern short cmd_del(short screen, int argc, char * argv[]);
|
||||
|
||||
/*
|
||||
* Rename a file or directory
|
||||
*/
|
||||
extern short cmd_rename(short screen, int argc, char * argv[]);
|
||||
|
||||
/*
|
||||
* Print the contents of a file to the screen
|
||||
*/
|
||||
|
|
|
@ -553,12 +553,41 @@ short fsys_mount(short bdev) {
|
|||
if (fres != FR_OK) {
|
||||
DEBUG("Unable to mount drive:");
|
||||
DEBUG(drive);
|
||||
return fres;
|
||||
return fatfs_to_foenix(fres);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the label for the drive holding the path
|
||||
*
|
||||
* Inputs:
|
||||
* path = path to the drive
|
||||
* label = buffer that will hold the label... should be at least 35 bytes
|
||||
*/
|
||||
short fsys_getlabel(char * path, char * label) {
|
||||
TRACE("fsys_getlabel");
|
||||
|
||||
FRESULT fres = f_getlabel(path, label, 0);
|
||||
if (fres != FR_OK) {
|
||||
return fatfs_to_foenix(fres);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the label for the drive holding the path
|
||||
*
|
||||
* Inputs:
|
||||
* path = path to the drive
|
||||
* label = buffer that holds the label
|
||||
*/
|
||||
short fsys_setlabel(char * path, char * label) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Default loader to be used if file extension does not match a known file format
|
||||
* but a destination address is provided
|
||||
|
|
|
@ -125,6 +125,24 @@ extern short fsys_findfirst(const char * path, const char * pattern, p_file_info
|
|||
*/
|
||||
extern short fsys_findnext(short dir, p_file_info file);
|
||||
|
||||
/*
|
||||
* Get the label for the drive holding the path
|
||||
*
|
||||
* Inputs:
|
||||
* path = path to the drive
|
||||
* label = buffer that will hold the label... should be at least 35 bytes
|
||||
*/
|
||||
extern short fsys_getlabel(char * path, char * label);
|
||||
|
||||
/*
|
||||
* Set the label for the drive holding the path
|
||||
*
|
||||
* Inputs:
|
||||
* path = path to the drive
|
||||
* label = buffer that holds the label
|
||||
*/
|
||||
extern short fsys_setlabel(char * path, char * label);
|
||||
|
||||
/**
|
||||
* Create a directory
|
||||
*
|
||||
|
|
|
@ -507,7 +507,7 @@ void text_put_raw(short screen, char c) {
|
|||
|
||||
case CHAR_TAB:
|
||||
text_get_xy(screen, &x, &y);
|
||||
y = (y & 0x07) + 8;
|
||||
x = x + 8;
|
||||
text_set_xy(screen, x, y);
|
||||
break;
|
||||
|
||||
|
|
3730
src/foenixmcp.s68
3730
src/foenixmcp.s68
File diff suppressed because it is too large
Load diff
8112
src/mapfile
8112
src/mapfile
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue