2 * Copyright 2006, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT license.
10 #include <TypeConstants.h>
17 get_type(type_code type
)
19 static char buffer
[32];
22 case B_MIME_STRING_TYPE
:
52 case B_MINI_ICON_TYPE
:
54 case B_LARGE_ICON_TYPE
:
59 int32 missed
= 0, shift
= 24;
61 for (int32 i
= 0; i
< 4; i
++, shift
-= 8) {
62 value
[i
] = uint8(type
>> shift
);
63 if (value
[i
] < ' ' || value
[i
] > 127) {
70 sprintf(buffer
, "'%c%c%c%c'", value
[0], value
[1], value
[2], value
[3]);
72 sprintf(buffer
, "0x%08lx", type
);
80 main(int argc
, char *argv
[])
82 const char *program
= strrchr(argv
[0], '/');
88 if (argc
< 2 || !strcmp(argv
[1], "--help") || !strcmp(argv
[1], "-h")) {
89 printf("usage: %s <filename> [<filename> ...]\n", program
);
95 for (int i
= 1; i
< argc
; ++i
) {
96 BFile
file(argv
[i
], B_READ_ONLY
);
98 status_t status
= file
.InitCheck();
100 fprintf(stderr
, "%s: opening file failed for \"%s\": %s\n",
101 program
, argv
[i
], strerror(status
));
105 BResources resources
;
106 status
= resources
.SetTo(&file
);
107 if (status
!= B_OK
) {
108 fprintf(stderr
, "%s: opening resources failed for \"%s\": %s\n",
109 program
, argv
[i
], strerror(status
));
113 printf("File: %s\n", argv
[i
]);
114 printf(" Type ID Size Name\n");
115 printf("----------- ----- -------- -------------------------------\n");
122 while (resources
.GetResourceInfo(index
++, &type
, &id
, &name
, &size
)) {
123 printf("%11s %6ld %9ld \"%s\"\n",
124 get_type(type
), id
, size
, name
);
130 printf("\n%Ld bytes total in resources.\n", total
);