kolibrios-fun/programs/system/shell/cmd/cmd_info.c
superturbocat2001 ce1620f6a1 Added info command to shell
git-svn-id: svn://kolibrios.org@8075 a494cfbc-eb01-0410-851d-a64ba20cac60
2020-09-21 17:53:00 +00:00

107 lines
3.1 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* 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 <¨¬ï_®¡ê¥ªâ >\n"
#define FILE_NOT_FOUND "Ž¡ê¥ªâ '%s' ­¥ ­ ©¤¥­!\n"
#define OBJECT_INFO "ˆ­ä®à¬ æ¨ï ®¡ ®¡ê¥ªâ¥ '%s':\n\n"
#define TYPE "’¨¯: "
#define DIR "'<27> ¯ª '"
#define PART "'’®¬'"
#define FILE "'” ©«'"
#define CREATED "‘®§¤ ­: %02d.%02d.%02d %02d:%02d:%02d\n"
#define MODIFID "ˆ§¬¥­ñ­: %02d.%02d.%02d %02d:%02d:%02d\n"
#define DATE_TIME " „ â  ‚६ï\n"
#define ATTRIB "€âਡãâë: "
#define RO "'’®«ìª® ¤«ï ç⥭¨ï' "
#define HIDDEN "'‘ªàëâë©' "
#define SYS "'‘¨á⥬­ë©' "
#define NOT_ARCHIV "'<27>¥  à娢­ë©' "
#define FILE_SIZE "\n<> §¬¥à ä ©« : %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;
}