summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/tools.c b/tools.c
index 6a98bf6..c9a3a44 100644
--- a/tools.c
+++ b/tools.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.c 2.14 2011/04/29 14:51:14 kls Exp $
+ * $Id: tools.c 2.17 2011/08/15 13:35:23 kls Exp $
*/
#include "tools.h"
@@ -261,7 +261,7 @@ int numdigits(int n)
bool isnumber(const char *s)
{
- if (!*s)
+ if (!s || !*s)
return false;
do {
if (!isdigit(*s))
@@ -270,6 +270,21 @@ bool isnumber(const char *s)
return true;
}
+int64_t StrToNum(const char *s)
+{
+ char *t = NULL;
+ int64_t n = strtoll(s, &t, 10);
+ if (t) {
+ switch (*t) {
+ case 'T': n *= 1024;
+ case 'G': n *= 1024;
+ case 'M': n *= 1024;
+ case 'K': n *= 1024;
+ }
+ }
+ return n;
+}
+
cString AddDirectory(const char *DirName, const char *FileName)
{
return cString::sprintf("%s/%s", DirName && *DirName ? DirName : ".", FileName);
@@ -556,7 +571,10 @@ time_t LastModifiedTime(const char *FileName)
cTimeMs::cTimeMs(int Ms)
{
- Set(Ms);
+ if (Ms >= 0)
+ Set(Ms);
+ else
+ begin = 0;
}
uint64_t cTimeMs::Now(void)