* Added a "listres" command (also to the image).
* Fixed building "stdbins that need libbe.so" for R5/Dano target. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16313 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -15,8 +15,8 @@ if $(TARGET_ARCH) = x86 {
|
||||
BEOS_BIN = addattr alert arp basename beep cat catattr chgrp chmod chop chown clear
|
||||
clockconfig cmp comm cp copyattr csplit cut date dd desklink df diff dirname dstcheck
|
||||
du echo eject env error factor false ffm find finddir fortune funzip gawk $(X86_ONLY)gdb
|
||||
grep groups gzip head id ifconfig iroster isvolume join keymap kill
|
||||
less lessecho lesskey link listarea listattr listdev listimage listport listsem
|
||||
grep groups gzip head id ifconfig iroster isvolume join keymap kill less lessecho
|
||||
lesskey link listarea listattr listdev listimage listport listres listsem
|
||||
ln locate logger logname ls lsindex makebootable md5sum mimeset mkdir mkindex
|
||||
modifiers mount mountvolume mv open pathchk ping play ppp_up pppconfig ps pwd
|
||||
query quit renice rm rmattr rmindex rmdir roster safemode screen_blanker sed settype
|
||||
|
||||
+2
-1
@@ -68,6 +68,7 @@ StdBinCommands
|
||||
ffm.cpp
|
||||
iroster.cpp
|
||||
listattr.cpp
|
||||
listres.cpp
|
||||
mimeset.cpp
|
||||
mkindex.cpp
|
||||
modifiers.cpp
|
||||
@@ -81,7 +82,7 @@ StdBinCommands
|
||||
shutdown.cpp
|
||||
version.cpp
|
||||
# yes.cpp
|
||||
: libbe.so ;
|
||||
: be ;
|
||||
|
||||
AddResources mimeset : mimeset.rdef ;
|
||||
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright 2006, Axel Dörfler, [email protected].
|
||||
* Distributed under the terms of the MIT license.
|
||||
*/
|
||||
|
||||
|
||||
#include <File.h>
|
||||
#include <Mime.h>
|
||||
#include <Resources.h>
|
||||
#include <TypeConstants.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
static const char *
|
||||
get_type(type_code type)
|
||||
{
|
||||
static char buffer[32];
|
||||
|
||||
switch (type) {
|
||||
case B_MIME_STRING_TYPE:
|
||||
return "MIME String";
|
||||
case B_RAW_TYPE:
|
||||
return "Raw Data";
|
||||
|
||||
case B_STRING_TYPE:
|
||||
return "Text";
|
||||
case B_INT64_TYPE:
|
||||
return "Int-64";
|
||||
case B_UINT64_TYPE:
|
||||
return "Uint-64";
|
||||
case B_INT32_TYPE:
|
||||
return "Int-32";
|
||||
case B_UINT32_TYPE:
|
||||
return "Uint-32";
|
||||
case B_INT16_TYPE:
|
||||
return "Int-16";
|
||||
case B_UINT16_TYPE:
|
||||
return "Uint-16";
|
||||
case B_INT8_TYPE:
|
||||
return "Int-8";
|
||||
case B_UINT8_TYPE:
|
||||
return "Uint-8";
|
||||
case B_BOOL_TYPE:
|
||||
return "Boolean";
|
||||
case B_FLOAT_TYPE:
|
||||
return "Float";
|
||||
case B_DOUBLE_TYPE:
|
||||
return "Double";
|
||||
|
||||
case 'MICN':
|
||||
return "Mini Icon";
|
||||
case 'ICON':
|
||||
return "Icon";
|
||||
|
||||
default:
|
||||
{
|
||||
int32 missed = 0, shift = 24;
|
||||
uint8 value[4];
|
||||
for (int32 i = 0; i < 4; i++, shift -= 8) {
|
||||
value[i] = uint8(type >> shift);
|
||||
if (value[i] < ' ' || value[i] > 127) {
|
||||
value[i] = '.';
|
||||
missed++;
|
||||
}
|
||||
}
|
||||
|
||||
if (missed < 2)
|
||||
sprintf(buffer, "'%c%c%c%c'", value[0], value[1], value[2], value[3]);
|
||||
else
|
||||
sprintf(buffer, "0x%08lx", type);
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
const char *program = strrchr(argv[0], '/');
|
||||
if (program == NULL)
|
||||
program = argv[0];
|
||||
else
|
||||
program++;
|
||||
|
||||
if (argc < 2 || !strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) {
|
||||
printf("usage: %s <filename> [<filename> ...]\n", program);
|
||||
return 1;
|
||||
}
|
||||
|
||||
off_t total = 0;
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
BFile file(argv[i], B_READ_ONLY);
|
||||
|
||||
status_t status = file.InitCheck();
|
||||
if (status < B_OK) {
|
||||
fprintf(stderr, "%s: opening file failed for \"%s\": %s\n",
|
||||
program, argv[i], strerror(status));
|
||||
return 1;
|
||||
}
|
||||
|
||||
BResources resources;
|
||||
status = resources.SetTo(&file);
|
||||
if (status != B_OK) {
|
||||
fprintf(stderr, "%s: opening resources failed for \"%s\": %s\n",
|
||||
program, argv[i], strerror(status));
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("File: %s\n", argv[i]);
|
||||
printf(" Type ID Size Name\n");
|
||||
printf("----------- ----- -------- -------------------------------\n");
|
||||
|
||||
int32 index = 0;
|
||||
const char* name;
|
||||
type_code type;
|
||||
size_t size;
|
||||
int32 id;
|
||||
while (resources.GetResourceInfo(index++, &type, &id, &name, &size)) {
|
||||
printf("%11s %6ld %9ld \"%s\"\n",
|
||||
get_type(type), id, size, name);
|
||||
|
||||
total += size;
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n%Ld bytes total in resources.\n", total);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user