33#define MAXSYSLOGBUF 256
41 if (len > 0 && len <
int(
sizeof(fmt)))
44 syslog(priority,
"ERROR: the following VDR message has no thread id! Format string too long, use a shorter one (max is %d)",
MAXSYSLOGBUF - 14);
45 vsyslog(priority, format, ap);
57ssize_t
safe_read(
int filedes,
void *buffer,
size_t size)
60 ssize_t p = read(filedes, buffer, size);
61 if (p < 0 && errno == EINTR) {
62 dsyslog(
"EINTR while reading from file handle %d - retrying", filedes);
69ssize_t
safe_write(
int filedes,
const void *buffer,
size_t size)
72 ssize_t written = size;
73 const unsigned char *ptr = (
const unsigned char *)buffer;
75 p = write(filedes, ptr, size);
78 dsyslog(
"EINTR while writing to file handle %d - retrying", filedes);
86 return p < 0 ? p : written;
98 int w = write(fd, Data + written, Length);
107 Poller.
Poll(RetryMs);
108 if (TimeoutMs > 0 && (TimeoutMs -= t.
Elapsed()) <= 0)
121 int l =
max(dest ? strlen(dest) : 0, strlen(src)) + 1;
122 dest = (
char *)realloc(dest, l);
126 esyslog(
"ERROR: out of memory");
135char *
strn0cpy(
char *dest,
const char *src,
size_t n)
140 for ( ; --n && (*dest = *src) != 0; dest++, src++) ;
161 if (!s || !s1 || !*s1 || !s2 || strcmp(s1, s2) == 0)
164 if (
char *p = strstr(s, s1)) {
171 if (
char *NewBuffer = (
char *)realloc(s, l + l2 - l1 + 1))
174 esyslog(
"ERROR: out of memory");
180 memmove(sof + l2, sof + l1, l - of - l1 + 1);
185 }
while (p = strstr(q, s1));
190const char *
strchrn(
const char *s,
char c,
size_t n)
196 if (*s == c && --n == 0)
217 const char *p = strrchr(s, 0);
219 if (*p == c && --n == 0)
227 const char *p = strrchr(s, c);
228 return p ? p + 1 : s;
234 for (
char *p = s + strlen(s) - 1; p >= s; p--) {
251 memmove(p + 1, q, strlen(q) + 1);
255 memmove(s, t, strlen(t) + 1);
271 else if (t != s && n == 0) {
290 if (strchr(chars, *p)) {
292 buffer =
MALLOC(
char, 2 * strlen(s) + 1);
293 t = buffer + (p - s);
294 s = strcpy(buffer, s);
310 int l = strlen(name);
312 while (
const char *p = strstr(t, name)) {
314 if (p == s || *(p - 1) <=
' ') {
334 memmove(s, s + n, l - n + 1);
352 const char *se = s + strlen(s) - 1;
353 const char *pe = p + strlen(p) - 1;
355 if (*pe-- != *se-- || (se < s && pe >= p))
390 int64_t n = strtoll(s, &t, 10);
406 if (strcmp(*a, s) == 0)
421 if (*FileName ==
'/')
423 return cString::sprintf(
"%s/%s", DirName && *DirName ? DirName :
".", FileName);
426#define DECIMAL_POINT_C '.'
430 static lconv *loc = localeconv();
432 char buf[strlen(s) + 1];
436 *p = *loc->decimal_point;
451 static lconv *loc = localeconv();
453 snprintf(buf,
sizeof(buf), Format, d);
462 snprintf(buf,
sizeof(buf),
"%d", n);
469 if (stat(File1, &st) == 0) {
470 dev_t dev1 = st.st_dev;
471 if (stat(File2, &st) == 0)
472 return st.st_dev == dev1;
486 struct statfs statFs;
487 if (statfs(Directory, &statFs) == 0) {
488 double blocksPerMeg = 1024.0 * 1024.0 / statFs.f_bsize;
490 *UsedMB = int((statFs.f_blocks - statFs.f_bfree) / blocksPerMeg);
491 Free = int(statFs.f_bavail / blocksPerMeg);
501 if (stat(DirName, &ds) == 0) {
502 if (S_ISDIR(ds.st_mode)) {
503 if (access(DirName, R_OK | W_OK | X_OK) == 0)
506 esyslog(
"ERROR: can't access %s", DirName);
509 esyslog(
"ERROR: %s is not a directory", DirName);
516bool MakeDirs(
const char *FileName,
bool IsDirectory)
519 char *s = strdup(FileName);
523 while ((p = strchr(p,
'/')) != NULL || IsDirectory) {
527 if (stat(s, &fs) != 0 || !S_ISDIR(fs.st_mode)) {
528 dsyslog(
"creating directory %s", s);
529 if (mkdir(s, ACCESSPERMS) == -1) {
547 if (stat(FileName, &st) == 0) {
548 if (S_ISDIR(st.st_mode)) {
552 while ((e = d.
Next()) != NULL) {
554 if (FollowSymlinks) {
556 if (lstat(buffer, &st2) == 0) {
557 if (S_ISLNK(st2.st_mode)) {
558 int size = st2.st_size + 1;
559 char *l =
MALLOC(
char, size);
560 int n = readlink(buffer, l, size - 1);
574 else if (errno != ENOENT) {
579 dsyslog(
"removing %s", *buffer);
580 if (remove(buffer) < 0)
589 dsyslog(
"removing %s", FileName);
590 if (remove(FileName) < 0) {
595 else if (errno != ENOENT) {
604 bool HasIgnoredFiles =
false;
609 while ((e = d.
Next()) != NULL) {
610 if (strcmp(e->d_name,
"lost+found")) {
613 if (stat(buffer, &st) == 0) {
614 if (S_ISDIR(st.st_mode)) {
618 else if (RemoveThis && IgnoreFiles &&
StrInArray(IgnoreFiles, e->d_name))
619 HasIgnoredFiles =
true;
629 if (RemoveThis && empty) {
630 if (HasIgnoredFiles) {
631 while (*IgnoreFiles) {
633 if (access(buffer, F_OK) == 0) {
634 dsyslog(
"removing %s", *buffer);
635 if (remove(buffer) < 0) {
643 dsyslog(
"removing %s", DirName);
644 if (remove(DirName) < 0) {
662 while (size >= 0 && (e = d.
Next()) != NULL) {
665 if (stat(buffer, &st) == 0) {
666 if (S_ISDIR(st.st_mode)) {
683 else if (errno != ENOENT)
692 char *TargetName = canonicalize_file_name(FileName);
695 TargetName = strdup(FileName);
704 for (
int n = 0; n < 10; n++) {
710 if (access(buf, F_OK) != 0) {
712 gettimeofday(&tp1, NULL);
713 int f = open(buf, O_WRONLY | O_CREAT, DEFFILEMODE);
716 if (fdatasync(f) < 0)
720 gettimeofday(&tp2, NULL);
721 double seconds = (((
long long)tp2.tv_sec * 1000000 + tp2.tv_usec) - ((
long long)tp1.tv_sec * 1000000 + tp1.tv_usec)) / 1000000.0;
723 dsyslog(
"SpinUpDisk took %.2f seconds", seconds);
730 esyslog(
"ERROR: SpinUpDisk failed");
736 if (Create && access(FileName, F_OK) != 0) {
737 isyslog(
"creating file '%s'", FileName);
738 int f = open(FileName, O_WRONLY | O_CREAT, DEFFILEMODE);
744 if (utime(FileName, NULL) == -1 && errno != ENOENT)
751 if (stat(FileName, &fs) == 0)
759 if (stat(FileName, &fs) == 0)
775#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
776#define MIN_RESOLUTION 5
777 static bool initialized =
false;
778 static bool monotonic =
false;
782 if (clock_getres(CLOCK_MONOTONIC, &tp) == 0) {
783 long Resolution = tp.tv_nsec;
785 if (tp.tv_sec == 0 && tp.tv_nsec <= MIN_RESOLUTION * 1000000) {
786 if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) {
787 dsyslog(
"cTimeMs: using monotonic clock (resolution is %ld ns)", Resolution);
791 esyslog(
"cTimeMs: clock_gettime(CLOCK_MONOTONIC) failed");
794 dsyslog(
"cTimeMs: not using monotonic clock - resolution is too bad (%jd s %ld ns)", intmax_t(tp.tv_sec), tp.tv_nsec);
797 esyslog(
"cTimeMs: clock_getres(CLOCK_MONOTONIC) failed");
801 if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
802 return (uint64_t(tp.tv_sec)) * 1000 + tp.tv_nsec / 1000000;
803 esyslog(
"cTimeMs: clock_gettime(CLOCK_MONOTONIC) failed");
808# warning Posix monotonic clock not available
811 if (gettimeofday(&t, NULL) == 0)
812 return (uint64_t(t.tv_sec)) * 1000 + t.tv_usec / 1000;
852#define MT(s, m, v) ((*(s) & (m)) == (v))
853 if (
MT(s, 0xE0, 0xC0) &&
MT(s + 1, 0xC0, 0x80))
855 if (
MT(s, 0xF0, 0xE0) &&
MT(s + 1, 0xC0, 0x80) &&
MT(s + 2, 0xC0, 0x80))
857 if (
MT(s, 0xF8, 0xF0) &&
MT(s + 1, 0xC0, 0x80) &&
MT(s + 2, 0xC0, 0x80) &&
MT(s + 3, 0xC0, 0x80))
869 case 2:
return ((*s & 0x1F) << 6) | (*(s + 1) & 0x3F);
870 case 3:
return ((*s & 0x0F) << 12) | ((*(s + 1) & 0x3F) << 6) | (*(s + 2) & 0x3F);
871 case 4:
return ((*s & 0x07) << 18) | ((*(s + 1) & 0x3F) << 12) | ((*(s + 2) & 0x3F) << 6) | (*(s + 3) & 0x3F);
886 *s++ = ((c >> 6) & 0x1F) | 0xC0;
887 *s = (c & 0x3F) | 0x80;
893 *s++ = ((c >> 12) & 0x0F) | 0xE0;
894 *s++ = ((c >> 6) & 0x3F) | 0x80;
895 *s = (c & 0x3F) | 0x80;
901 *s++ = ((c >> 18) & 0x07) | 0xF0;
902 *s++ = ((c >> 12) & 0x3F) | 0x80;
903 *s++ = ((c >> 6) & 0x3F) | 0x80;
904 *s = (c & 0x3F) | 0x80;
916 while (*s && Symbols--) {
962 while (*s && --Size > 0) {
964 *a++ = (
uchar)(*s++);
981 while (*a && NumChars < Size) {
982 if (Max >= 0 && NumSyms++ >= Max)
990 if (NumChars + sl <= Size) {
1000 if (NumChars < Size)
1015 cd = iconv_open(ToCode, FromCode);
1023 if (
cd != (iconv_t)-1)
1031 if (!strcasestr(CharacterTable,
"UTF-8")) {
1034 for (
int i = 0; i < 128; i++)
1038 const char *s = csc.
Convert(buf);
1052 if (
cd != (iconv_t)-1 && From && *From) {
1053 char *FromPtr = (
char *)From;
1054 size_t FromLength = strlen(From);
1057 int NewLength =
max(
length, FromLength * 2);
1058 if (
char *NewBuffer = (
char *)realloc(
result, NewLength)) {
1063 esyslog(
"ERROR: out of memory");
1072 char *Converted = ToPtr;
1073 while (FromLength > 0) {
1074 if (iconv(
cd, &FromPtr, &FromLength, &ToPtr, &ToLength) ==
size_t(-1)) {
1075 if (errno == E2BIG || errno == EILSEQ && ToLength < 1) {
1079 size_t d = ToPtr -
result;
1081 int NewLength =
length + r;
1082 if (
char *NewBuffer = (
char *)realloc(
result, NewLength)) {
1084 Converted =
result = NewBuffer;
1087 esyslog(
"ERROR: out of memory");
1093 if (errno == EILSEQ) {
1100 else if (errno != E2BIG)
1114 s = TakePointer ? (
char *)S : S ? strdup(S) : NULL;
1133 s = String.
s ? strdup(String.
s) : NULL;
1143 if (
this == &String)
1146 s = String.
s ? strdup(String.
s) : NULL;
1152 if (
this != &String) {
1165 s = String ? strdup(String) : NULL;
1172 int l1 =
s ? strlen(
s) : 0;
1173 int l2 = strlen(String);
1174 if (
char *p = (
char *)realloc(
s, l1 + l2 + 1)) {
1176 strcpy(
s + l1, String);
1179 esyslog(
"ERROR: out of memory");
1187 int l1 =
s ? strlen(
s) : 0;
1189 if (
char *p = (
char *)realloc(
s, l1 + l2 + 1)) {
1195 esyslog(
"ERROR: out of memory");
1205 if (Index >= 0 && Index < l)
1221 if (!fmt || vasprintf(&buffer, fmt, ap) < 0) {
1222 esyslog(
"error in vasprintf('%s', ...)", fmt);
1223 buffer = strdup(
"???");
1232 if (!fmt || vasprintf(&buffer, fmt, ap) < 0) {
1233 esyslog(
"error in vasprintf('%s', ...)", fmt);
1234 buffer = strdup(
"???");
1242 WeekDay = WeekDay == 0 ? 6 : WeekDay - 1;
1243 if (0 <= WeekDay && WeekDay <= 6) {
1245 const char *day =
tr(
"MonTueWedThuFriSatSun");
1257 return WeekDayName(localtime_r(&t, &tm_r)->tm_wday);
1262 WeekDay = WeekDay == 0 ? 6 : WeekDay - 1;
1264 case 0:
return tr(
"Monday");
1265 case 1:
return tr(
"Tuesday");
1266 case 2:
return tr(
"Wednesday");
1267 case 3:
return tr(
"Thursday");
1268 case 4:
return tr(
"Friday");
1269 case 5:
return tr(
"Saturday");
1270 case 6:
return tr(
"Sunday");
1271 default:
return "???";
1287 tm *tm = localtime_r(&t, &tm_r);
1288 snprintf(buffer,
sizeof(buffer),
"%s %02d.%02d. %02d:%02d", *
WeekDayName(tm->tm_wday), tm->tm_mday, tm->tm_mon + 1, tm->tm_hour, tm->tm_min);
1295 if (ctime_r(&t, buffer)) {
1296 buffer[strlen(buffer) - 1] = 0;
1306 tm *tm = localtime_r(&t, &tm_r);
1309 strftime(p,
sizeof(buf) - (p - buf),
"%d.%m.%Y", tm);
1317 tm *tm = localtime_r(&t, &tm_r);
1318 strftime(buf,
sizeof(buf),
"%d.%m.%y", tm);
1326 strftime(buf,
sizeof(buf),
"%R", localtime_r(&t, &tm_r));
1332#define JPEGCOMPRESSMEM 500000
1352 int Used = jcd->
size;
1354 if (
uchar *NewBuffer = (
uchar *)realloc(jcd->
mem, NewSize)) {
1355 jcd->
size = NewSize;
1356 jcd->
mem = NewBuffer;
1359 esyslog(
"ERROR: out of memory");
1363 cinfo->dest->next_output_byte = jcd->
mem + Used;
1364 cinfo->dest->free_in_buffer = jcd->
size - Used;
1375 int Used = cinfo->dest->next_output_byte - jcd->
mem;
1376 if (Used < jcd->size) {
1379 jcd->
mem = NewBuffer;
1382 esyslog(
"ERROR: out of memory");
1391 else if (Quality > 100)
1394 jpeg_destination_mgr jdm;
1400 struct jpeg_compress_struct cinfo;
1401 struct jpeg_error_mgr jerr;
1402 cinfo.err = jpeg_std_error(&jerr);
1403 jpeg_create_compress(&cinfo);
1406 cinfo.client_data = &jcd;
1407 cinfo.image_width = Width;
1408 cinfo.image_height = Height;
1409 cinfo.input_components = 3;
1410 cinfo.in_color_space = JCS_RGB;
1412 jpeg_set_defaults(&cinfo);
1413 jpeg_set_quality(&cinfo, Quality, TRUE);
1414 jpeg_start_compress(&cinfo, TRUE);
1417 JSAMPROW rp[Height];
1418 for (
int k = 0; k < Height; k++)
1419 rp[k] = &Mem[rs * k];
1420 jpeg_write_scanlines(&cinfo, rp, Height);
1421 jpeg_finish_compress(&cinfo);
1422 jpeg_destroy_compress(&cinfo);
1432 static char buffer[HOST_NAME_MAX] =
"";
1434 if (gethostname(buffer,
sizeof(buffer)) < 0) {
1436 strcpy(buffer,
"vdr");
1444const char *
cBase64Encoder::b64 =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1467 c |= (
data[
i] >> 4) & 0x0F;
1470 c = (
data[
i] << 2) & 0x3F;
1472 c |= (
data[
i] >> 6) & 0x03;
1571 Add(FileHandle, Out);
1576 if (FileHandle >= 0) {
1578 if (
pfd[i].fd == FileHandle &&
pfd[i].events == (Out ? POLLOUT : POLLIN))
1588 esyslog(
"ERROR: too many file handles in cPoller");
1595 if (FileHandle >= 0) {
1597 if (
pfd[i].fd == FileHandle &&
pfd[i].events == (Out ? POLLOUT : POLLIN)) {
1634#if !__GLIBC_PREREQ(2, 24)
1639 if (strcmp(
result->d_name,
".") && strcmp(
result->d_name,
".."))
1655 for (
int i = 0; i <
Size(); i++) {
1656 if (!strcmp(s,
At(i)))
1664 for (
int i = 0; i <
Size(); i++)
1674 Load(Directory, DirsOnly);
1684 while ((e =
d.Next()) != NULL) {
1687 if (stat(
AddDirectory(Directory, e->d_name), &ds) == 0) {
1688 if (!S_ISDIR(ds.st_mode))
1692 Append(strdup(e->d_name));
1718 return Open(open(FileName, Flags, Mode));
1719 esyslog(
"ERROR: attempt to re-open %s", FileName);
1729 esyslog(
"ERROR: attempt to re-open file descriptor %d", FileDes);
1750 struct timeval timeout;
1752 FD_SET(FileDes, &set);
1753 if (TimeoutMs >= 0) {
1754 if (TimeoutMs < 100)
1756 timeout.tv_sec = TimeoutMs / 1000;
1757 timeout.tv_usec = (TimeoutMs % 1000) * 1000;
1759 return select(FD_SETSIZE, &set, NULL, NULL, (TimeoutMs >= 0) ? &timeout : NULL) > 0 && FD_ISSET(FileDes, &set);
1796 if (ferror(
f) != 0) {
1802 if (fclose(
f) < 0) {
1819#ifndef USE_FADVISE_READ
1820#define USE_FADVISE_READ 0
1822#ifndef USE_FADVISE_WRITE
1823#define USE_FADVISE_WRITE 1
1826#define WRITE_BUFFER KILOBYTE(800)
1841 fd = open(FileName, Flags, Mode);
1843#if USE_FADVISE_READ || USE_FADVISE_WRITE
1851 posix_fadvise(
fd, 0, 0, POSIX_FADV_RANDOM);
1859#if USE_FADVISE_READ || USE_FADVISE_WRITE
1862 posix_fadvise(
fd, 0, 0, POSIX_FADV_DONTNEED);
1866 return close(OldFd);
1877#define FADVGRAN KILOBYTE(4)
1878#define READCHUNK MEGABYTE(8)
1888 return posix_fadvise(
fd, Offset - (
FADVGRAN - 1), Len + (
FADVGRAN - 1) * 2, POSIX_FADV_DONTNEED);
1893 if (Whence == SEEK_SET && Offset ==
curpos)
1895 curpos = lseek(
fd, Offset, Whence);
1913 if (bytesRead > 0) {
1920 if (jumped >= 0 && jumped <= (off_t)
readahead) {
1961#if USE_FADVISE_WRITE
1962 if (bytesWritten > 0) {
2003 return bytesWritten;
2011 if (File->
Open(FileName, Flags, Mode) < 0) {
2020#define LOCKFILENAME ".lock-vdr"
2021#define LOCKFILESTALETIME 600
2040 time_t Timeout = time(NULL) + WaitSeconds;
2042 f = open(
fileName, O_WRONLY | O_CREAT | O_EXCL, DEFFILEMODE);
2044 if (errno == EEXIST) {
2056 else if (errno != ENOENT) {
2063 if (errno == ENOSPC) {
2064 esyslog(
"ERROR: can't create lock file '%s' - assuming lock anyway!",
fileName);
2072 }
while (
f < 0 && time(NULL) < Timeout);
2100 Object->
prev =
this;
2106 Object->
next =
this;
2132#define LIST_GARBAGE_COLLECTOR_TIMEOUT 5
2145 esyslog(
"ERROR: ListGarbageCollector destroyed without prior Purge()!");
2192 return stateLock.Lock(StateKey, Write, TimeoutMs);
2194 esyslog(
"ERROR: cListBase::Lock() called for a list that doesn't require locking");
2216 if (Before && Before !=
objects) {
2253 if (From && To && From != To) {
2310 while (
object && Index-- > 0)
2311 object =
object->Next();
2330 while (
object && i < n) {
2332 object =
object->
Next();
2336 for (i = 0; i < n; i++) {
2360 if (
size < NewSize) {
2367 esyslog(
"ERROR: out of memory");
2399 unsigned int hash =
hashfn(Id);
2410 if (hob->object == Object) {
2420 for (
int i = 0; i <
size; i++) {
cBase64Encoder(const uchar *Data, int Length, int MaxResult=64)
Sets up a new base 64 encoder for the given Data, with the given Length.
const char * NextLine(void)
Returns the next line of encoded data (terminated by '\0'), or NULL if there is no more encoded data.
bool SetLength(int Length)
cCharSetConv(const char *FromCode=NULL, const char *ToCode=NULL)
Sets up a character set converter to convert from FromCode to ToCode.
static const char * SystemCharacterTable(void)
static void SetSystemCharacterTable(const char *CharacterTable)
static char * systemCharacterTable
const char * Convert(const char *From, char *To=NULL, size_t ToLength=0)
Converts the given Text from FromCode to ToCode (as set in the constructor).
static void SleepMs(int TimeoutMs)
Creates a cCondWait object and uses it to sleep for TimeoutMs milliseconds, immediately giving up the...
cDynamicBuffer(int InitialSize=1024)
bool Realloc(int NewSize)
void Append(const uchar *Data, int Length)
bool Load(const char *Directory, bool DirsOnly=false)
cFileNameList(const char *Directory=NULL, bool DirsOnly=false)
static bool FileReady(int FileDes, int TimeoutMs=1000)
bool Ready(bool Wait=true)
bool Open(const char *FileName, int Flags, mode_t Mode=DEFFILEMODE)
void Del(cListObject *Object, unsigned int Id)
cListObject * Get(unsigned int Id) const
cList< cHashObject > ** hashTable
cList< cHashObject > * GetList(unsigned int Id) const
cHashBase(int Size, bool OwnObjects)
Creates a new hash of the given Size.
void Add(cListObject *Object, unsigned int Id)
unsigned int hashfn(unsigned int Id) const
void Ins(cListObject *Object, cListObject *Before=NULL)
bool Contains(const cListObject *Object) const
If a pointer to an object contained in this list has been obtained while holding a lock,...
void Del(cListObject *Object, bool DeleteObject=true)
virtual void Move(int From, int To)
void SetExplicitModify(void)
If you have obtained a write lock on this list, and you don't want it to be automatically marked as m...
void SetModified(void)
Unconditionally marks this list as modified.
bool Lock(cStateKey &StateKey, bool Write=false, int TimeoutMs=0) const
Tries to get a lock on this list and returns true if successful.
const char * needsLocking
cListBase(const char *NeedsLocking=NULL)
const cListObject * Get(int Index) const
void Add(cListObject *Object, cListObject *After=NULL)
void Purge(bool Force=false)
cListGarbageCollector(void)
void Put(cListObject *Object)
cListObject(const cListObject &ListObject)
cListObject * Prev(void) const
virtual int Compare(const cListObject &ListObject) const
Must return 0 if this object is equal to ListObject, a positive value if it is "greater",...
void Insert(cListObject *Object)
cListObject * Next(void) const
void Append(cListObject *Object)
const T * First(void) const
Returns the first element in this list, or NULL if the list is empty.
const T * Next(const T *Object) const
< Returns the element immediately before Object in this list, or NULL if Object is the first element ...
bool Lock(int WaitSeconds=0)
cLockFile(const char *Directory)
cPoller(int FileHandle=-1, bool Out=false)
bool Add(int FileHandle, bool Out)
bool Poll(int TimeoutMs=0)
void Del(int FileHandle, bool Out)
cReadDir(const char *Directory)
struct dirent * Next(void)
union cReadDir::@177011034140060070152007220245225125302245142357 u
cSafeFile(const char *FileName)
void Sort(bool IgnoreCase=false)
virtual void Clear(void) override
int Find(const char *s) const
virtual ~cStringList() override
cString & CompactChars(char c)
Compact any sequence of characters 'c' to a single character, and strip all of them from the beginnin...
static cString static cString vsprintf(const char *fmt, va_list &ap)
cString(const char *S=NULL, bool TakePointer=false)
static cString sprintf(const char *fmt,...) __attribute__((format(printf
cString & operator=(const cString &String)
cString & Append(const char *String)
cString & Truncate(int Index)
Truncate the string at the given Index (if Index is < 0 it is counted from the end of the string).
static tThreadId ThreadId(void)
uint64_t Elapsed(void) const
Returns the number of milliseconds that have elapsed since the last call to Set().
void Set(int Ms=0)
Sets the timer.
bool TimedOut(void) const
Returns true if the number of milliseconds given in the last call to Set() have passed.
cTimeMs(int Ms=0)
Creates a timer with ms resolution and an initial timeout of Ms.
void Reset(void)
Resets the timer to the same timeout as given in the last call to Set().
static uint64_t Now(void)
uint64_t Remaining(void) const
Returns the number of milliseconds remaining until the timer times out.
static cUnbufferedFile * Create(const char *FileName, int Flags, mode_t Mode=DEFFILEMODE)
void SetReadAhead(size_t ra)
ssize_t Write(const void *Data, size_t Size)
int Open(const char *FileName, int Flags, mode_t Mode=DEFFILEMODE)
ssize_t Read(void *Data, size_t Size)
int FadviseDrop(off_t Offset, off_t Len)
off_t Seek(off_t Offset, int Whence)
virtual void Append(char *Data)
char *& At(int Index) const
static boolean JpegCompressEmptyOutputBuffer(j_compress_ptr cinfo)
static void JpegCompressInitDestination(j_compress_ptr cinfo)
static void JpegCompressTermDestination(j_compress_ptr cinfo)