-add replace_char to ZapitTools

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@943 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
satbaby
2010-12-14 18:46:30 +00:00
parent edea6e83f6
commit 6c250d1d5b
3 changed files with 20 additions and 35 deletions

View File

@@ -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`'<27>!,:;");
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`'~<>!,:;?^<5E>$\\=*#@<40>|");
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`'~<>!,:;?^<5E>$\\=*#@<40>|");
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`'<27>!,:;");
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`'~<>!,:;?^<5E>$\\=*#@<40>|");
if (*p_act) {
*p_act++ = '_';
}
} while (*p_act);
ZapitTools::replace_char(&filename[pos]);
}
}
}

View File

@@ -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

View File

@@ -22,6 +22,7 @@
*/
#include <zapit/client/zapittools.h>
#include <string.h>
namespace ZapitTools {
@@ -120,4 +121,16 @@ namespace ZapitTools {
}
return r;
}
void replace_char(char * p_act)
{
const char repchars[]="/ \"%&-\t`'~<>!,:;?^<5E>$\\=*#@<40>|";
do {
p_act += strcspn(p_act, repchars );
if (*p_act) {
*p_act++ = '_';
}
} while (*p_act);
}
}