kolibrios/programs/system/shell/cmd/cmd_info.c

107 lines
3.1 KiB
C
Raw Normal View History

/* turbocat2001 */
#if LANG_ENG
#define HELP "info <object_name>\n"
#define FILE_NOT_FOUND "Object '%s' not found!\n"
#define OBJECT_INFO "Object '%s' information:\n\n"
#define TYPE "Type: "
#define DIR "'Folder'"
#define PART "'Part'"
#define FILE "'File'"
#define CREATED "Created: %02d.%02d.%02d %02d:%02d:%02d\n"
#define MODIFID "Modified: %02d.%02d.%02d %02d:%02d:%02d\n"
#define DATE_TIME " Date Time\n"
#define ATTRIB "Attributes: "
#define RO "'Read only' "
#define HIDDEN "'Hidden' "
#define SYS "'System' "
#define NOT_ARCHIV "'Not archived' "
#define FILE_SIZE "\nFile size: %u KB (%u B)\n"
#elif LANG_RUS
#define HELP "info <<3C><><EFBFBD>_<EFBFBD><5F><EFBFBD><EAA5AA>>\n"
#define FILE_NOT_FOUND "<22><><EFBFBD> '%s' <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n"
#define OBJECT_INFO "<22><><EFBFBD><EFBFBD><EFBFBD><E0ACA0><EFBFBD> <20><> <20><><EFBFBD><EAA5AA> '%s':\n\n"
#define TYPE "<22><><EFBFBD>: "
#define DIR "'<27><><EFBFBD><EFBFBD><EFBFBD>'"
#define PART "'<27><><EFBFBD>'"
#define FILE "'<27><><EFBFBD><EFBFBD>'"
#define CREATED "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: %02d.%02d.%02d %02d:%02d:%02d\n"
#define MODIFID "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: %02d.%02d.%02d %02d:%02d:%02d\n"
#define DATE_TIME " <20><><EFBFBD><EFBFBD> <20><EFBFBD>\n"
#define ATTRIB "<22><><EFBFBD><E0A8A1><EFBFBD>: "
#define RO "'<27><><EFBFBD><20><><EFBFBD> <20><EFBFBD><E2A5AD>' "
#define HIDDEN "'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' "
#define SYS "'<27><><EFBFBD><EFBFBD><E2A5AC><EFBFBD>' "
#define NOT_ARCHIV "'<27><> <20><><EFBFBD><E5A8A2><EFBFBD>' "
#define FILE_SIZE "\n<><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><E4A0A9>: %u K<> (%u <20>)\n"
#endif
int cmd_info(char param[])
{
byte is_dir=0, is_part=0; // Folder or part?
char* argv[100];
if(1 != parameters_prepare(param, argv)) //get number of parameters
{
printf(HELP);
return TRUE;
}
FS_struct_BDVK *info=NULL; // BDVK struct define
info=get_bdvk(argv[0]); // Get file info (BDVK)
if(info==NULL)
{
printf(FILE_NOT_FOUND, argv[0]);
return TRUE;
}
printf(OBJECT_INFO, argv[0]);
printf(TYPE);
if (info->attrib & (1 << 4))
{
printf(DIR);
is_dir=1;
}
else if (info->attrib & (1 << 3))
{
printf(PART);
is_part=1;
}
else
{
printf(FILE);
}
printf("\n\n");
printf(DATE_TIME); // Show date and time
printf(CREATED, info->c_date.d, info->c_date.m, info->c_date.y, info->c_time.h, info->c_time.m, info->c_time.s);
printf(MODIFID, info->m_date.d, info->m_date.m, info->m_date.y, info->m_time.h, info->m_time.m, info->m_time.s);
printf("\n");
printf(ATTRIB); // Show Attributes
if (info->attrib & (1 << 0))
{
printf(RO);
}
if (info->attrib & (1 << 1))
{
printf(HIDDEN);
}
if (info->attrib & (1 << 2))
{
printf(SYS);
}
if (info->attrib & (1 << 5))
{
printf(NOT_ARCHIV);
}
printf("\n");
if (!is_dir && (info->size)>=0 && !is_part) // If dir or part then not show file size
{
printf(FILE_SIZE, info->size/1024, info->size);
}
return TRUE;
}