diff options
author | thlo <smarttv640@gmail.com> | 2013-02-02 13:36:07 +0100 |
---|---|---|
committer | thlo <t.lohmar@gmx.de> | 2013-02-02 13:36:07 +0100 |
commit | 0b2c6753dbe0f6963eae8713b0b9eb3dcace4896 (patch) | |
tree | b28e0eca6efbaec401267a15976f82d153920562 /vdr-smarttvweb | |
parent | ddc72f21013a7385bf2eb8ac07d641542d386406 (diff) | |
download | vdr-plugin-smarttvweb-0b2c6753dbe0f6963eae8713b0b9eb3dcace4896.tar.gz vdr-plugin-smarttvweb-0b2c6753dbe0f6963eae8713b0b9eb3dcace4896.tar.bz2 |
use stat64 instead of stat. Don't show hideen files.
Diffstat (limited to 'vdr-smarttvweb')
-rwxr-xr-x | vdr-smarttvweb/httpresource.c | 53 | ||||
-rwxr-xr-x | vdr-smarttvweb/httpresource.h | 26 |
2 files changed, 40 insertions, 39 deletions
diff --git a/vdr-smarttvweb/httpresource.c b/vdr-smarttvweb/httpresource.c index adffffc..3e1e21c 100755 --- a/vdr-smarttvweb/httpresource.c +++ b/vdr-smarttvweb/httpresource.c @@ -326,7 +326,7 @@ int cHttpResource::processRequest() { #ifndef DEBUG *(mLog->log())<< DEBUGPREFIX << " processRequest for mPath= " << mPath << DEBUGHDR << endl; #endif - struct stat statbuf; + struct stat64 statbuf; bool ok_to_serve = false; if (mMethod.compare("POST")==0) { @@ -400,7 +400,7 @@ int cHttpResource::processRequest() { if (mPath.compare("/widget.conf") == 0) { mPath = mFactory->getConfigDir() + "/widget.conf"; - if (stat(mPath.c_str(), &statbuf) < 0) { + if (stat64(mPath.c_str(), &statbuf) < 0) { sendError(404, "Not Found", NULL, "File not found."); return OKAY; } @@ -415,7 +415,7 @@ int cHttpResource::processRequest() { if (mPath.compare("/favicon.ico") == 0) { mPath = mFactory->getConfigDir() + "/web/favicon.ico"; - if (stat(mPath.c_str(), &statbuf) < 0) { + if (stat64(mPath.c_str(), &statbuf) < 0) { sendError(404, "Not Found", NULL, "File not found."); return OKAY; } @@ -464,7 +464,7 @@ int cHttpResource::processRequest() { } - if (stat(mPath.c_str(), &statbuf) < 0) { + if (stat64(mPath.c_str(), &statbuf) < 0) { // checking, whether the file or directory exists *(mLog->log())<< DEBUGPREFIX << " File Not found " << mPath << endl; @@ -831,7 +831,7 @@ void cHttpResource::sendError(int status, const char *title, const char *extra, } -int cHttpResource::sendDir(struct stat *statbuf) { +int cHttpResource::sendDir(struct stat64 *statbuf) { char pathbuf[4096]; char f[400]; int len; @@ -851,7 +851,7 @@ int cHttpResource::sendDir(struct stat *statbuf) { } snprintf(pathbuf, sizeof(pathbuf), "%sindex.html", mPath.c_str()); - if (stat(pathbuf, statbuf) >= 0) { + if (stat64(pathbuf, statbuf) >= 0) { mPath = pathbuf; mFileSize = statbuf->st_size; mContentType = SINGLEFILE; @@ -895,7 +895,7 @@ int cHttpResource::sendDir(struct stat *statbuf) { // printf (" -Entry: %s\n", de->d_name); strcat(pathbuf, de->d_name); - stat(pathbuf, statbuf); + stat64(pathbuf, statbuf); tm = gmtime(&(statbuf->st_mtime)); strftime(timebuf, sizeof(timebuf), "%d-%b-%Y %H:%M:%S", tm); @@ -1045,7 +1045,7 @@ int cHttpResource::getQueryAttributeValue(vector<sQueryAVP> *avps, string attr, return found; } -int cHttpResource::parseFiles(vector<sFileEntry> *entries, string prefix, string dir_base, string dir_name, struct stat *statbuf) { +int cHttpResource::parseFiles(vector<sFileEntry> *entries, string prefix, string dir_base, string dir_name, struct stat64 *statbuf) { char pathbuf[4096]; string link; DIR *dir; @@ -1063,7 +1063,7 @@ int cHttpResource::parseFiles(vector<sFileEntry> *entries, string prefix, string #endif dir = opendir(dir_comp.c_str()); - if (stat(dir_comp.c_str(), statbuf) < 0) + if (stat64(dir_comp.c_str(), statbuf) < 0) return ERROR; while ((de = readdir(dir)) != NULL) { @@ -1074,7 +1074,7 @@ int cHttpResource::parseFiles(vector<sFileEntry> *entries, string prefix, string strcpy(pathbuf, dir_comp.c_str()); strcat(pathbuf, de->d_name); - stat(pathbuf, statbuf); + stat64(pathbuf, statbuf); if (S_ISDIR(statbuf->st_mode)) { if (strcmp(&(pathbuf[strlen(pathbuf)-4]), ".rec") == 0) { @@ -1105,14 +1105,15 @@ int cHttpResource::parseFiles(vector<sFileEntry> *entries, string prefix, string } } else { - entries->push_back(sFileEntry(prefix+de->d_name, pathbuf, 1)); + if ((de->d_name)[0] != '.' ) + entries->push_back(sFileEntry(prefix+de->d_name, pathbuf, 1)); } } closedir(dir); return OKAY; } -int cHttpResource::sendManifest (struct stat *statbuf, bool is_hls) { +int cHttpResource::sendManifest (struct stat64 *statbuf, bool is_hls) { #ifndef STANDALONE size_t pos = mPath.find_last_of ("/"); @@ -1255,7 +1256,7 @@ void cHttpResource::writeMPD(double duration, float seg_dur, int end_seg) { sendHeaders(200, "OK", NULL, "application/x-mpegURL", mResponseMessage->size(), -1); } -int cHttpResource::sendMediaSegment (struct stat *statbuf) { +int cHttpResource::sendMediaSegment (struct stat64 *statbuf) { #ifndef STANDALONE *(mLog->log()) << DEBUGPREFIX << " sendMediaSegment " << mPath << endl; @@ -1374,7 +1375,7 @@ int cHttpResource::sendMediaSegment (struct stat *statbuf) { << endl; #endif snprintf(seg_fn, sizeof(seg_fn), mFileStructure.c_str(), mDir.c_str(), mVdrIdx); - if (stat(seg_fn, statbuf) < 0) { + if (stat64(seg_fn, statbuf) < 0) { *(mLog->log()) << DEBUGPREFIX << " file= " <<seg_fn << " does not exist" << endl; @@ -1386,7 +1387,7 @@ int cHttpResource::sendMediaSegment (struct stat *statbuf) { // loop over all idx files between start_idx and end_idx for (int idx = (start_idx+1); idx < end_idx; idx ++) { snprintf(seg_fn, sizeof(seg_fn), mFileStructure.c_str(), mDir.c_str(), idx); - if (stat(seg_fn, statbuf) < 0) { + if (stat64(seg_fn, statbuf) < 0) { *(mLog->log()) << DEBUGPREFIX << " for loop file= " <<seg_fn << " does not exist" << endl; @@ -1428,7 +1429,7 @@ int cHttpResource::sendMediaSegment (struct stat *statbuf) { return OKAY; } -int cHttpResource::sendMediaXml (struct stat *statbuf) { +int cHttpResource::sendMediaXml (struct stat64 *statbuf) { char pathbuf[4096]; string link; string media_folder = mFactory->getConfig()->getMediaFolder(); @@ -1478,7 +1479,7 @@ int cHttpResource::sendMediaXml (struct stat *statbuf) { return OKAY; } -int cHttpResource::sendVdrStatusXml (struct stat *statbuf) { +int cHttpResource::sendVdrStatusXml (struct stat64 *statbuf) { #ifndef STANDALONE @@ -1517,7 +1518,7 @@ int cHttpResource::sendVdrStatusXml (struct stat *statbuf) { return OKAY; } -int cHttpResource::sendEpgXml (struct stat *statbuf) { +int cHttpResource::sendEpgXml (struct stat64 *statbuf) { #ifndef STANDALONE char f[400]; @@ -1684,7 +1685,7 @@ int cHttpResource::sendEpgXml (struct stat *statbuf) { return OKAY; } -int cHttpResource::sendChannelsXml (struct stat *statbuf) { +int cHttpResource::sendChannelsXml (struct stat64 *statbuf) { #ifndef STANDALONE char f[400]; @@ -1876,7 +1877,7 @@ int cHttpResource::receiveResume() { return OKAY; } -//int cHttpResource::sendResumeXml (struct stat *statbuf) { +//int cHttpResource::sendResumeXml (struct stat64 *statbuf) { int cHttpResource::sendResumeXml () { #ifndef STANDALONE @@ -1969,7 +1970,7 @@ int cHttpResource::deleteRecording() { } -int cHttpResource::sendRecordingsXml(struct stat *statbuf) { +int cHttpResource::sendRecordingsXml(struct stat64 *statbuf) { #ifndef STANDALONE mResponseMessage = new string(); @@ -2175,7 +2176,7 @@ int cHttpResource::sendRecordingsXml(struct stat *statbuf) { return OKAY; } -bool cHttpResource::isTimeRequest(struct stat *statbuf) { +bool cHttpResource::isTimeRequest(struct stat64 *statbuf) { vector<sQueryAVP> avps; parseQueryLine(&avps); @@ -2334,7 +2335,7 @@ bool cHttpResource::isTimeRequest(struct stat *statbuf) { int vdr_idx = mVdrIdx; while (more_to_go) { snprintf(pathbuf, sizeof(pathbuf), mFileStructure.c_str(), mPath.c_str(), vdr_idx); - if (stat(pathbuf, statbuf) >= 0) { + if (stat64(pathbuf, statbuf) >= 0) { *(mLog->log())<< " found for " << pathbuf << endl; file_size += statbuf->st_size; } @@ -2359,7 +2360,7 @@ bool cHttpResource::isTimeRequest(struct stat *statbuf) { return true; } -int cHttpResource::sendVdrDir(struct stat *statbuf) { +int cHttpResource::sendVdrDir(struct stat64 *statbuf) { #ifndef DEBUG *(mLog->log())<< DEBUGPREFIX << " *** sendVdrDir mPath= " << mPath << endl; @@ -2397,7 +2398,7 @@ int cHttpResource::sendVdrDir(struct stat *statbuf) { while (more_to_go) { vdr_idx ++; snprintf(pathbuf, sizeof(pathbuf), mFileStructure.c_str(), mPath.c_str(), vdr_idx); - if (stat(pathbuf, statbuf) >= 0) { + if (stat64(pathbuf, statbuf) >= 0) { #ifndef DEBUG *(mLog->log())<< " found for " << pathbuf << endl; #endif @@ -2583,7 +2584,7 @@ void cHttpResource::sendHeaders(int status, const char *title, const char *extra } -int cHttpResource::sendFile(struct stat *statbuf) { +int cHttpResource::sendFile(struct stat64 *statbuf) { // Send the First Datachunk, incl all headers *(mLog->log())<< DEBUGPREFIX diff --git a/vdr-smarttvweb/httpresource.h b/vdr-smarttvweb/httpresource.h index 81ecb34..35b3367 100755 --- a/vdr-smarttvweb/httpresource.h +++ b/vdr-smarttvweb/httpresource.h @@ -141,17 +141,17 @@ class cHttpResource { int readRequestPayload(); void sendError(int status, const char *title, const char *extra, const char *text); - int sendDir(struct stat *statbuf); - int sendVdrDir(struct stat *statbuf); - int sendRecordingsXml (struct stat *statbuf); - int sendChannelsXml (struct stat *statbuf); + int sendDir(struct stat64 *statbuf); + int sendVdrDir(struct stat64 *statbuf); + int sendRecordingsXml (struct stat64 *statbuf); + int sendChannelsXml (struct stat64 *statbuf); int sendResumeXml (); - int sendVdrStatusXml (struct stat *statbuf); - // int sendResumeXml (struct stat *statbuf); - int sendEpgXml (struct stat *statbuf); - int sendMediaXml (struct stat *statbuf); + int sendVdrStatusXml (struct stat64 *statbuf); + // int sendResumeXml (struct stat64 *statbuf); + int sendEpgXml (struct stat64 *statbuf); + int sendMediaXml (struct stat64 *statbuf); - int sendManifest (struct stat *statbuf, bool is_hls = true); + int sendManifest (struct stat64 *statbuf, bool is_hls = true); int receiveResume(); int deleteRecording(); @@ -160,25 +160,25 @@ class cHttpResource { void writeMPD(double duration, float seg_dur, int end_seg); - int sendMediaSegment (struct stat *statbuf); + int sendMediaSegment (struct stat64 *statbuf); void sendHeaders(int status, const char *title, const char *extra, const char *mime, long long int length, time_t date); - int sendFile(struct stat *statbuf); + int sendFile(struct stat64 *statbuf); // Helper Functions const char *getMimeType(const char *name); string getConnStateName(); void checkRecording(); - bool isTimeRequest(struct stat *statbuf); + bool isTimeRequest(struct stat64 *statbuf); int parseRangeHeaderValue(string); int parseHttpRequestLine(string); int parseHttpHeaderLine (string); int parseQueryLine (vector<sQueryAVP> *avps); int parseResume(cResumeEntry &entry, string &id); - int parseFiles(vector<sFileEntry> *entries, string prefix, string dir_base, string dir_name, struct stat *statbuf); + int parseFiles(vector<sFileEntry> *entries, string prefix, string dir_base, string dir_name, struct stat64 *statbuf); int getQueryAttributeValue(vector<sQueryAVP> *avps, string id, string &val); int openFile(const char *name); |