use CFileHelpers::copyFile instead of own function; cleanup helpers

Origin commit data
------------------
Commit: 6d01d59b53
Author: vanhofen <vanhofen@gmx.de>
Date: 2016-08-11 (Thu, 11 Aug 2016)

Origin message was:
------------------
- use CFileHelpers::copyFile instead of own function; cleanup helpers
This commit is contained in:
vanhofen
2016-08-11 13:52:49 +02:00
parent c5ec2be239
commit 31a80d2f93
6 changed files with 15 additions and 50 deletions

View File

@@ -59,9 +59,6 @@
#include <eitd/sectionsd.h> #include <eitd/sectionsd.h>
#include <timerdclient/timerdclient.h> #include <timerdclient/timerdclient.h>
//NI
#include <system/helpers.h>
extern CPictureViewer * g_PicViewer; extern CPictureViewer * g_PicViewer;
#define ICON_LARGE_WIDTH 26 #define ICON_LARGE_WIDTH 26
@@ -1272,7 +1269,8 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start
else else
picname = imdb->getFilename(channel, epgData.eventID); picname = imdb->getFilename(channel, epgData.eventID);
if (!File_copy(imdb->posterfile.c_str(), picname.c_str())) CFileHelpers fh;
if (!fh.copyFile(imdb->posterfile.c_str(), picname.c_str()))
perror( "IMDb: error copy file" ); perror( "IMDb: error copy file" );
sleep(2); sleep(2);

View File

@@ -1083,7 +1083,8 @@ void CInfoViewerBB::paint_cam_icons()
int CInfoViewerBB::check_ecmInfo() int CInfoViewerBB::check_ecmInfo()
{ {
int caid = 0; int caid = 0;
if (File_copy("/tmp/ecm.info", "/tmp/ecm.info.tmp")) { CFileHelpers fh;
if (fh.copyFile("/tmp/ecm.info", "/tmp/ecm.info.tmp")) {
g_InfoViewer->md5_ecmInfo = filehash((char *)"/tmp/ecm.info.tmp"); g_InfoViewer->md5_ecmInfo = filehash((char *)"/tmp/ecm.info.tmp");
caid = parse_ecmInfo("/tmp/ecm.info.tmp"); caid = parse_ecmInfo("/tmp/ecm.info.tmp");
} }

View File

@@ -911,8 +911,11 @@ int CMovieBrowser::exec(CMenuTarget* parent, const std::string & actionKey)
printf("Poster\n"); printf("Poster\n");
poster = m_movieSelectionHandler->file.Name.substr(0, pos); poster = m_movieSelectionHandler->file.Name.substr(0, pos);
poster += ".jpg"; poster += ".jpg";
File_copy(imdb->posterfile.c_str(), poster.c_str()); CFileHelpers fh;
printf("* poster: %s\n", poster.c_str()); if (fh.copyFile(imdb->posterfile.c_str(), poster.c_str()))
printf("* poster: %s\n", poster.c_str());
else
printf("* poster: copy error\n");
} }
//m_movieInfo.saveMovieInfo(*m_movieSelectionHandler); //m_movieInfo.saveMovieInfo(*m_movieSelectionHandler);

View File

@@ -156,7 +156,8 @@ int CNIMenu::exec(CMenuTarget* parent, const std::string &actionkey)
else if(actionkey == "ecmInfo") { else if(actionkey == "ecmInfo") {
buffer=NULL; buffer=NULL;
if (File_copy("/tmp/ecm.info", "/tmp/ecm.info.tmp")) CFileHelpers fhlp;
if (fhlp.copyFile("/tmp/ecm.info", "/tmp/ecm.info.tmp"))
{ {
if ((fh = fopen("/tmp/ecm.info.tmp", "r"))) if ((fh = fopen("/tmp/ecm.info.tmp", "r")))
{ {

View File

@@ -1110,44 +1110,7 @@ std::string Lang2ISO639_1(std::string& lang)
} }
//NI //NI
bool File_copy(std::string rstr, std::string wstr) // returns the pid of the first process found in /proc
{
char * buffer;
long size;
std::ifstream infile(rstr.c_str(), std::ifstream::binary);
if (infile)
{
std::ofstream outfile(wstr.c_str(), std::ofstream::binary);
if (outfile)
{
// get size of file
infile.seekg(0,std::ifstream::end);
size=infile.tellg();
infile.seekg(0);
buffer = new char [size];
infile.read (buffer,size);
outfile.write (buffer,size);
delete[] buffer;
outfile.close();
}
else
{
return false;
}
infile.close();
return true;
}
else
{
return false;
}
}
// rreturns the pid of the first process found in /proc
int getpidof(const char *process) int getpidof(const char *process)
{ {
DIR *dp; DIR *dp;

View File

@@ -122,10 +122,9 @@ std::string getJFFS2MountPoint(int mtdPos);
std::string Lang2ISO639_1(std::string& lang); std::string Lang2ISO639_1(std::string& lang);
//NI //NI
bool File_copy(std::string rstr, std::string wstr); int getpidof(const char *process);
int getpidof(const char *process); std::string filehash(const char * file);
std::string filehash(const char * file); std::string get_path(const char * path);
std::string get_path(const char * path);
inline bool file_exists(const std::string file) { return file_exists(file.c_str()); } inline bool file_exists(const std::string file) { return file_exists(file.c_str()); }
#endif #endif