addattr: added support for B_TIME_TYPE.
* Using parsedate().
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#include <Mime.h>
|
#include <Mime.h>
|
||||||
|
|
||||||
#include <fs_attr.h>
|
#include <fs_attr.h>
|
||||||
|
#include <parsedate.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -112,6 +113,15 @@ writeAttr(int fd, type_code type, const char* name, const char* value, size_t le
|
|||||||
return writeAttrValue<uint8>(fd, name, B_BOOL_TYPE, boolValue);
|
return writeAttrValue<uint8>(fd, name, B_BOOL_TYPE, boolValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case B_TIME_TYPE:
|
||||||
|
{
|
||||||
|
time_t timeValue = parsedate(value, time(NULL));
|
||||||
|
if (timeValue < 0)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
return writeAttrValue<time_t>(fd, name, B_TIME_TYPE, timeValue);
|
||||||
|
}
|
||||||
|
|
||||||
case B_STRING_TYPE:
|
case B_STRING_TYPE:
|
||||||
case B_MIME_STRING_TYPE:
|
case B_MIME_STRING_TYPE:
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -64,8 +64,9 @@ const struct {
|
|||||||
|
|
||||||
{B_BOOL_TYPE, "bool"},
|
{B_BOOL_TYPE, "bool"},
|
||||||
|
|
||||||
{B_VECTOR_ICON_TYPE, "icon"},
|
{B_TIME_TYPE, "time"},
|
||||||
|
|
||||||
|
{B_VECTOR_ICON_TYPE, "icon"},
|
||||||
{B_RAW_TYPE, "raw"},
|
{B_RAW_TYPE, "raw"},
|
||||||
};
|
};
|
||||||
const uint32 kNumSupportedTypes = sizeof(kSupportedTypes)
|
const uint32 kNumSupportedTypes = sizeof(kSupportedTypes)
|
||||||
@@ -112,7 +113,7 @@ usage(int returnValue)
|
|||||||
" or: %s [-f value-from-file] [-t type] [ -P ] attr file1 [file2...]\n\n"
|
" or: %s [-f value-from-file] [-t type] [ -P ] attr file1 [file2...]\n\n"
|
||||||
"\t-P : Don't resolve links\n"
|
"\t-P : Don't resolve links\n"
|
||||||
"\tType is one of:\n"
|
"\tType is one of:\n"
|
||||||
"\t\tstring, mime, int, llong, float, double, bool, icon, raw\n"
|
"\t\tstring, mime, int, llong, float, double, bool, time, icon, raw\n"
|
||||||
"\t\tor a numeric value (ie. 0x1234, 42, 'ABCD', ...)\n"
|
"\t\tor a numeric value (ie. 0x1234, 42, 'ABCD', ...)\n"
|
||||||
"\tThe default is \"string\"\n", kProgramName, kProgramName);
|
"\tThe default is \"string\"\n", kProgramName, kProgramName);
|
||||||
|
|
||||||
@@ -121,12 +122,12 @@ usage(int returnValue)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
invalidAttrType(const char *attrTypeName)
|
invalidAttrType(const char* attrTypeName)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: attribute type \"%s\" is not valid\n", kProgramName,
|
fprintf(stderr, "%s: attribute type \"%s\" is not valid\n", kProgramName,
|
||||||
attrTypeName);
|
attrTypeName);
|
||||||
fprintf(stderr, "\tTry one of: string, mime, int, llong, float, double,\n");
|
fprintf(stderr, "\tTry one of: string, mime, int, llong, float, double,\n");
|
||||||
fprintf(stderr, "\t\tbool, icon, raw, or a numeric value (ie. 0x1234, 42, 'ABCD'"
|
fprintf(stderr, "\t\tbool, time, icon, raw, or a numeric value (ie. 0x1234, 42, 'ABCD'"
|
||||||
", ...)\n");
|
", ...)\n");
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user