From 6c250d1d5b7d7bf3adbc84f1104e52b8243aa1de Mon Sep 17 00:00:00 2001 From: satbaby Date: Tue, 14 Dec 2010 18:46:30 +0000 Subject: [PATCH] -add replace_char to ZapitTools git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@943 e54a6e83-5905-42d5-8d5c-058d10e6a962 --- src/driver/vcrcontrol.cpp | 41 +++------------------ src/zapit/include/zapit/client/zapittools.h | 1 + src/zapit/lib/zapittools.cpp | 13 +++++++ 3 files changed, 20 insertions(+), 35 deletions(-) diff --git a/src/driver/vcrcontrol.cpp b/src/driver/vcrcontrol.cpp index 1315ae48f..f7621fc78 100644 --- a/src/driver/vcrcontrol.cpp +++ b/src/driver/vcrcontrol.cpp @@ -586,13 +586,8 @@ printf("Record channel_id: " PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS " epg: %llx if (!(ext_channel_name.empty())) { strcpy(&(filename[pos]), UTF8_TO_FILESYSTEM_ENCODING(ext_channel_name.c_str())); - char * p_act = &(filename[pos]); - do { - p_act += strcspn(p_act, "/ \"%&-\t`'´!,:;"); - if (*p_act) { - *p_act++ = '_'; - } - } while (*p_act); + ZapitTools::replace_char(&filename[pos]); + if (!autoshift && g_settings.recording_save_in_channeldir) { struct stat statInfo; int res = stat(filename,&statInfo); @@ -628,24 +623,12 @@ printf("Record channel_id: " PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS " epg: %llx if (!(epgdata.title.empty())) { strcpy(&(filename[pos]), epgdata.title.c_str()); - char * p_act = &(filename[pos]); - do { - p_act += strcspn(p_act, "/ \"%&-\t`'~<>!,:;?^°$\\=*#@¤|"); - if (*p_act) { - *p_act++ = '_'; - } - } while (*p_act); + ZapitTools::replace_char(&filename[pos]); } } } else if (!epgTitle.empty()) { strcpy(&(filename[pos]), epgTitle.c_str()); - char * p_act = &(filename[pos]); - do { - p_act += strcspn(p_act, "/ \"%&-\t`'~<>!,:;?^°$\\=*#@¤|"); - if (*p_act) { - *p_act++ = '_'; - } - } while (*p_act); + ZapitTools::replace_char(&filename[pos]); } } #if 1 @@ -700,13 +683,7 @@ void CVCRControl::Screenshot(const t_channel_id channel_id, char * fname) channel_name = g_Zapit->getChannelName(channel_id); if (!(channel_name.empty())) { strcpy(&(filename[pos]), UTF8_TO_FILESYSTEM_ENCODING(channel_name.c_str())); - char * p_act = &(filename[pos]); - do { - p_act += strcspn(p_act, "/ \"%&-\t`'´!,:;"); - if (*p_act) { - *p_act++ = '_'; - } - } while (*p_act); + ZapitTools::replace_char(&filename[pos]); strcat(filename, "_"); } pos = strlen(filename); @@ -721,13 +698,7 @@ void CVCRControl::Screenshot(const t_channel_id channel_id, char * fname) if(sectionsd_getEPGidShort(epgid, &epgdata)) { if (!(epgdata.title.empty())) { strcpy(&(filename[pos]), epgdata.title.c_str()); - char * p_act = &(filename[pos]); - do { - p_act += strcspn(p_act, "/ \"%&-\t`'~<>!,:;?^°$\\=*#@¤|"); - if (*p_act) { - *p_act++ = '_'; - } - } while (*p_act); + ZapitTools::replace_char(&filename[pos]); } } } diff --git a/src/zapit/include/zapit/client/zapittools.h b/src/zapit/include/zapit/client/zapittools.h index 487d2a488..5af91e8ee 100644 --- a/src/zapit/include/zapit/client/zapittools.h +++ b/src/zapit/include/zapit/client/zapittools.h @@ -31,6 +31,7 @@ namespace ZapitTools std::string UTF8_to_Latin1 (const char *); std::string UTF8_to_UTF8XML(const char *); std::string Latin1_to_UTF8 (const char *); + void replace_char(char * p_act); } #endif diff --git a/src/zapit/lib/zapittools.cpp b/src/zapit/lib/zapittools.cpp index a81c2bcef..efca4ef4b 100644 --- a/src/zapit/lib/zapittools.cpp +++ b/src/zapit/lib/zapittools.cpp @@ -22,6 +22,7 @@ */ #include +#include namespace ZapitTools { @@ -120,4 +121,16 @@ namespace ZapitTools { } return r; } + + void replace_char(char * p_act) + { + const char repchars[]="/ \"%&-\t`'~<>!,:;?^°$\\=*#@¤|"; + do { + p_act += strcspn(p_act, repchars ); + if (*p_act) { + *p_act++ = '_'; + } + } while (*p_act); + } + }