示例#1
0
文件: pin.c 项目: suborb/reelvdr
bool cPinPlugin::Initialize(void)
{
   char* path;

   asprintf(&path, "%s/%s", cPlugin::ConfigDirectory(), "pin");

   if (!DirectoryOk(path, no))
   {
      if (mkdir(path, 0770))
      {
         // cannot create the directory

         esyslog("Creating of directory '%s' failed, errno was (%d) - '%s'", 
                 path, errno, strerror(errno)); 
         free(path);

         return true; // anyhow let vdr start
      }
   }

   free(path);

   lockedChannels.Load(AddDirectory(cPlugin::ConfigDirectory(), 
                                    "pin/channellocks.conf"), true, false);
   lockedBroadcasts.Load(AddDirectory(cPlugin::ConfigDirectory(),
                                      "pin/broadcastlocks.conf"), true, false);
   lockedPlugins.Load(AddDirectory(cPlugin::ConfigDirectory(),
                                   "pin/pluginlocks.conf"), true, false);

   return true;
}
bool NzPluginManager::Initialize()
{
	if (s_initialized)
		return true;

	s_initialized = true;

	AddDirectory(".");
	AddDirectory("plugins");

	return true;
}
示例#3
0
文件: reelblog.c 项目: suborb/reelvdr
bool cPluginReelblogReader::Start(void)
{
  // Start any background activities the plugin shall perform.
  if (!ReelblogItems.Load(AddDirectory(ConfigDirectory(), "reelblog.conf")))
    Skins.Message(mtInfo, tr("ConfigFile reelblog.conf not found!"));
  return true;
}
void cRecordingsCache::LoadResumeData()
{
  cMutexLock lock(&m_mutex);

  cString filename = AddDirectory(XVDRServerConfig.ConfigDirectory, RESUME_DATA_FILE);
  FILE* f = fopen((const char*)filename, "r");

  if(f == NULL)
  {
    ERRORLOG("unable to open resume data: %s", (const char*)filename);
    return;
  }

  uint32_t uid = 0;
  uint64_t pos = 0;
  int count = 0;

  while(fscanf(f, "%08x = %"PRIu64", %i", &uid, &pos, &count) != EOF)
  {
    m_recordings[uid].lastplayedposition = pos;
    m_recordings[uid].playcount = count;

    uid = 0;
    pos = 0;
    count = 0;
  }

  fclose(f);
  return;
}
示例#5
0
void FileList::AddDirectory(const QString &directory, bool recursive)
{
    QDir dir(directory);
    dir.setSorting(QDir::Name);
    const QStringList filters = FileList::GetDefaultFilters();
    const QStringList origNameFilters = dir.nameFilters();
    dir.setNameFilters(filters);
    if (!recursive) {
        dir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
        QFileInfoList items = dir.entryInfoList();
        mFileList += items;
    } else {
        dir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
        QFileInfoList items = dir.entryInfoList();
        mFileList += items;

        dir.setNameFilters(origNameFilters);
        dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
        QFileInfoList list = dir.entryInfoList();
        QFileInfo item;
        foreach(item, list) {
            const QString path = item.canonicalFilePath();
            AddDirectory(path, recursive);
        }
    }
}
示例#6
0
cOsdObject *cPluginEpgsearch::MainMenuAction(void)
{
   if (reloadMenuConf)
      LoadMenuTemplates();

   if (showConflicts)
   {
      showConflicts = false;
      return new cMenuConflictCheck();
   }

   if (showAnnounces)
   {
      showAnnounces = false;
      return new cMenuAnnounceList(cSearchTimerThread::announceList);
   }

   // Perform the action when selected from the main VDR menu.
   cOsdObject* pMenu = NULL;
   char* rcFilename = strdup(AddDirectory(CONFIGDIR, ".epgsearchrc"));
   if (access(rcFilename, F_OK) == 0)
      pMenu = DoInitialSearch(rcFilename);
   else
      pMenu = new cMenuSearchMain();

   free(rcFilename);
   return pMenu;
}
示例#7
0
bool cThemes::Load(const char *SkinName)
{
  Clear();
  if (themesDirectory) {
     cReadDir d(themesDirectory);
     struct dirent *e;
     while ((e = d.Next()) != NULL) {
           if (strcmp(e->d_name, ".") && strcmp(e->d_name, "..")) {
              if (strstr(e->d_name, SkinName) == e->d_name && e->d_name[strlen(SkinName)] == '-') {
                 cString FileName = AddDirectory(themesDirectory, e->d_name);
                 cTheme Theme;
                 if (Theme.Load(*FileName, true)) {
                    names = (char **)realloc(names, (numThemes + 1) * sizeof(char *));
                    names[numThemes] = strdup(Theme.Name());
                    fileNames = (char **)realloc(fileNames, (numThemes + 1) * sizeof(char *));
                    fileNames[numThemes] = strdup(*FileName);
                    descriptions = (char **)realloc(descriptions, (numThemes + 1) * sizeof(char *));
                    descriptions[numThemes] = strdup(Theme.Description());
                    numThemes++;
                    }
                 }
              }
           }
     return numThemes > 0;
     }
  return false;
}
示例#8
0
status_t ArpMultiDir::AddDirectory(directory_which which, const char* leaf)
{
	BPath path;
	status_t ret = find_directory(which,&path);
	if( ret != B_OK ) return ret;
	return AddDirectory(path.Path(),leaf);
}
示例#9
0
bool FDirectory::Open(bool quiet)
{
	NumLumps = AddDirectory(Filename);
	if (!quiet) Printf(", %d lumps\n", NumLumps);
	PostProcessArchive(&Lumps[0], sizeof(FDirectoryLump));
	return true;
}
示例#10
0
bool FDirectory::Open(bool quiet)
{
	NumLumps = AddDirectory(Filename);
	if (!quiet) Printf(", %d lumps\n", NumLumps);
	// Entries in Zips are sorted alphabetically.
	qsort(&Lumps[0], NumLumps, sizeof(FDirectoryLump), lumpcmp);
	return true;
}
//--------------------------------------------------------------------------------
bool CFileIndexSubSystem::AddDirectory(LPCTSTR pDir, CFileIndexDirObject*& pObj)
	{
	pObj = NULL;
	CWriteLock lock(&m_tree, false);
	if(! lock.Lock(1000))
		return false;

	return AddDirectory(pDir, pObj, lock);
	}
示例#12
0
文件: crawler.c 项目: suborb/reelvdr
void cDirCrawler::Action()
{
    cThreadLock threadLock(this);
    const char* DirName = pwd.path.c_str();
    int LinkLevel = pwd.linkLevel;
    isyslog("thread %d, Dir '%s'", ThreadId(), DirName);
    cReadDir d(DirName);
    struct dirent *e;
    
    while (Running() && (e = d.Next()) != NULL) 
    {
        // Ignore NULL or empty names and all hidden directories and files
        if (!e->d_name || !strlen(e->d_name) || e->d_name[0] == '.')
            continue;

        // construct full path
        cString buffer(AddDirectory(DirName, e->d_name));
        struct stat st;

        // check if path is a link
        if (lstat(buffer, &st) != 0)
            continue; // error

        if (S_ISLNK(st.st_mode))
        {
            ++LinkLevel;

            // too many symlink in this path, maybe cyclic
            if (LinkLevel > MAX_LINK_LEVEL)
            {
                isyslog("max link level exceeded - not scanning %s", *buffer);
                continue;
            }

            if (stat(buffer, &st) != 0)
                continue; // error
        }

        cPath nextPath;
        nextPath.path = *buffer;
        nextPath.linkLevel = LinkLevel;

        // if subdirectory, put it in the directory Queue for other threads
        if (S_ISDIR(st.st_mode))
        {
            isyslog("pwd: %s got '%s' , push '%s'", DirName, e->d_name, *buffer);
            dirQ->AddPath(nextPath);
        }
        else if (S_ISREG(st.st_mode))
        {
            nextPath.filename = e->d_name;
            // a file
            AddPathToDatabase(nextPath);
        }
    } // while
} // Action()
NS_IMETHODIMP nsAbMDBDirectory::AddMailList(nsIAbDirectory *list, nsIAbDirectory **addedList)
{
  NS_ENSURE_ARG_POINTER(addedList);

  if (mIsQueryURI)
    return NS_ERROR_NOT_IMPLEMENTED;

  nsresult rv = NS_OK;
  if (!mDatabase)
    rv = GetAbDatabase();

  if (NS_FAILED(rv) || !mDatabase)
    return NS_ERROR_FAILURE;

  nsCOMPtr<nsIAbMDBDirectory> dblist(do_QueryInterface(list, &rv));
  if (NS_FAILED(rv))
  {
    nsCOMPtr<nsIAbDirectory> newlist(new nsAbMDBDirProperty);
    if (!newlist)
      return NS_ERROR_OUT_OF_MEMORY;

    rv = newlist->CopyMailList(list);
    NS_ENSURE_SUCCESS(rv, rv);

    dblist = do_QueryInterface(newlist, &rv);
    NS_ENSURE_SUCCESS(rv, rv);
    
    mDatabase->CreateMailListAndAddToDB(newlist, true, this);
  }
  else
    mDatabase->CreateMailListAndAddToDB(list, true, this);

  mDatabase->Commit(nsAddrDBCommitType::kLargeCommit);

  uint32_t dbRowID;
  dblist->GetDbRowID(&dbRowID);

  nsAutoCString listUri(mURI);
  listUri.AppendLiteral("/MailList");
  listUri.AppendInt(dbRowID);

  nsCOMPtr<nsIAbDirectory> newList;
  rv = AddDirectory(listUri.get(), getter_AddRefs(newList));
  if (NS_SUCCEEDED(rv) && newList)
  {
    nsCOMPtr<nsIAbMDBDirectory> dbnewList(do_QueryInterface(newList, &rv));
    NS_ENSURE_SUCCESS(rv, rv);

    dbnewList->CopyDBMailList(dblist);
    AddMailListToDirectory(newList);
    NotifyItemAdded(newList);
  }

  NS_IF_ADDREF(*addedList = newList);
  return rv;
}
示例#14
0
void FileList::AddPathList(const QStringList &paths)
{
    QString path;
    foreach(path, paths) {
        QFileInfo inf(path);
        if (inf.isFile())
            AddFile(path);
        else
            AddDirectory(path, true);
    }
示例#15
0
int FDirectory::AddDirectory(const char *dirpath)
{
	struct _finddata_t fileinfo;
	intptr_t handle;
	FString dirmatch;
	int count = 0;

	dirmatch = dirpath;
	dirmatch += '*';
	
	if ((handle = _findfirst(dirmatch, &fileinfo)) == -1)
	{
		Printf("Could not scan '%s': %s\n", dirpath, strerror(errno));
	}
	else
	{
		do
		{
			if (fileinfo.attrib & _A_HIDDEN)
			{
				// Skip hidden files and directories. (Prevents SVN bookkeeping
				// info from being included.)
				continue;
			}
			if (fileinfo.attrib & _A_SUBDIR)
			{

				if (fileinfo.name[0] == '.' &&
					(fileinfo.name[1] == '\0' ||
					 (fileinfo.name[1] == '.' && fileinfo.name[2] == '\0')))
				{
					// Do not record . and .. directories.
					continue;
				}
				FString newdir = dirpath;
				newdir << fileinfo.name << '/';
				count += AddDirectory(newdir);
			}
			else
			{
				if (strstr(fileinfo.name, ".orig") || strstr(fileinfo.name, ".bak"))
				{
					// We shouldn't add backup files to the lump directory
					continue;
				}

				AddEntry(FString(dirpath) + fileinfo.name, fileinfo.size);
				count++;
			}
		} while (_findnext(handle, &fileinfo) == 0);
		_findclose(handle);
	}
	return count;
}
示例#16
0
status_t ArpMultiDir::AddSearchPath(const char* path, const char* leaf)
{
	if( !path ) return B_OK;
	
	char* mypath = strdup(path);
	if( !mypath ) return B_NO_MEMORY;
	
	char* base = mypath;
	status_t ret = B_OK;
	while( *base ) {
		bool need_repl = false;
		char* buffer;
		while( *mypath != ':' && *mypath != 0 ) {
			if( *mypath == '%' ) need_repl = true;
			mypath++;
		}
		char endc = *mypath;
		*mypath = 0;
		
		if( need_repl ) {
			int32 size = expand_dir(NULL,base);
			buffer = (char*)malloc(size);
			if( buffer ) {
				expand_dir(buffer,base);
				base = buffer;
			} else ret = B_NO_MEMORY;
		} else buffer = NULL;
		
		if( ret == B_OK ) ret = AddDirectory(base, leaf);
		else AddDirectory(base, leaf);
		
		*mypath = endc;
		if( *mypath != 0 ) mypath++;
		base = mypath;
		
		if( buffer ) free(buffer);
	}
	return ret;
}
std::string ChannelController::createLogoUrl(const cChannel* channel, const std::string& baseUrl) {
    if(baseUrl.empty()) {
        return "";
    }

    std::string filename = createServiceReference(channel);

    if(baseUrl.size() > 4 && baseUrl.substr(0, 4) == "http") {
        filename = urlEncode(filename);
    }

    cString piconurl = AddDirectory(baseUrl.c_str(), filename.c_str());
    return (const char*)cString::sprintf("%s.png", (const char*)piconurl);
}
示例#18
0
文件: compat.c 项目: aiolos/sasc
bool DllsLoad(const char *libdir)
{
  char pat[32];
  snprintf(pat,sizeof(pat),"%s*-%d%s%s",LIBSC_PREFIX,SCAPIVERS,SO_INDICATOR,APIVERSION);
  bool res=true;
  cReadDir dir(libdir);
  struct dirent *e;
  while((e=dir.Next())) {
    if(!fnmatch(pat,e->d_name,FNM_PATHNAME|FNM_NOESCAPE)) {
      if(!DllLoad(AddDirectory(libdir,e->d_name))) res=false;
      }
    }
  return res;
}
示例#19
0
cGraphLCDLogoList::cGraphLCDLogoList(const std::string & logodir, const std::string & cfgdir)
{
	std::fstream file;
	char readLine[1000];
	std::string line;
	std::string aliasFileName;
	std::string::size_type pos;
	tAliasListElement * newAlias;

	logoDir = logodir;
	aliasFileName = AddDirectory(cfgdir.c_str(), kAliasFileName);

#if (__GNUC__ < 3)
	file.open(aliasFileName.c_str(), std::ios::in);
#else
	file.open(aliasFileName.c_str(), std::ios_base::in);
#endif
	if (!file.is_open())
		return;

	while (!file.eof())
	{
		file.getline(readLine, 1000);
		line = trim(readLine);
		if (line.length() == 0)
			continue;
		if (line[0] == '#')
			continue;
		pos = line.find(":");
		if (pos == std::string::npos)
			continue;
		newAlias = new tAliasListElement;
		if (newAlias)
		{
			newAlias->channelID = trim(line.substr(0, pos));
			newAlias->fileName = trim(line.substr(pos + 1));
			aliasList.push_back(newAlias);
		}
	}
	file.close();
/*
	std::list <tAliasListElement *>::iterator it;
	for (it = aliasList.begin(); it != aliasList.end(); it++)
	{
		newAlias = *it;
		printf(">>>>>> AliasList:  >%s< : >%s<\n", newAlias->channelID.c_str(), newAlias->fileName.c_str());
	}
*/
}
示例#20
0
void RoboTVServerConfig::Load() {
    LiveQueue::setTimeShiftDir(cVideoDirectory::Name());

    if(!cConfig<cSetupLine>::Load(AddDirectory(configDirectory.c_str(), GENERAL_CONFIG_FILE), true, false)) {
        return;
    }

    for(cSetupLine* l = First(); l; l = Next(l)) {
        if(!Parse(l->Name(), l->Value())) {
            ERRORLOG("Unknown config parameter %s = %s in %s", l->Name(), l->Value(), GENERAL_CONFIG_FILE);
        }
    }

    LiveQueue::removeTimeShiftFiles();
}
示例#21
0
void cPluginEpgsearch::LoadMenuTemplates()
{
   char* templateFilename = strdup(AddDirectory(CONFIGDIR, "epgsearchmenu.conf"));
   if (access(templateFilename, F_OK) == 0)
   {
      cTemplFile templFile;
      if (!templFile.Load(templateFilename))
      {
         templFile.Reset();
         LogFile.eSysLog("could not load '%s'", templateFilename);
      }
   }
   cTemplFile::PrepareDefaultTemplates();
   free(templateFilename);
}
示例#22
0
void cXVDRServerConfig::Load() {
  cLiveQueue::SetTimeShiftDir(VideoDirectory);
  cRecordingsCache::GetInstance().LoadResumeData();

  if(!cConfig<cSetupLine>::Load(AddDirectory(ConfigDirectory, GENERAL_CONFIG_FILE), true, false))
    return;

  for (cSetupLine* l = First(); l; l = Next(l))
  {
    if(!Parse(l->Name(), l->Value()))
      ERRORLOG("Unknown config parameter %s = %s in %s", l->Name(), l->Value(), GENERAL_CONFIG_FILE);
  }

  cLiveQueue::RemoveTimeShiftFiles();
  cChannelCache::LoadChannelCacheData();
}
示例#23
0
void cPluginEpgsearch::LoadUserVars()
{
   char* userVarFilename = strdup(AddDirectory(CONFIGDIR, "epgsearchuservars.conf"));
   if (access(userVarFilename, F_OK) == 0)
   {
      LogFile.Log(1, "loading %s", userVarFilename);
      cUserVarFile userVarFile;
      if (!userVarFile.Load(userVarFilename))
         LogFile.eSysLog("could not load '%s'", userVarFilename);
      else
         LogFile.Log(2,"loaded uservars from %s", userVarFilename);
   }
   free(userVarFilename);
   UserVars.InitInternalVars();
   UserVars.InitExtEPGVars();
}
示例#24
0
GameTracker::GameTracker(QObject* parent) : QFileSystemWatcher(parent)
{
  m_loader = new GameLoader;
  m_loader->moveToThread(&m_loader_thread);

  qRegisterMetaType<QSharedPointer<GameFile>>();
  connect(&m_loader_thread, &QThread::finished, m_loader, &QObject::deleteLater);
  connect(this, &QFileSystemWatcher::directoryChanged, this, &GameTracker::UpdateDirectory);
  connect(this, &QFileSystemWatcher::fileChanged, this, &GameTracker::UpdateFile);
  connect(this, &GameTracker::PathChanged, m_loader, &GameLoader::LoadGame);
  connect(m_loader, &GameLoader::GameLoaded, this, &GameTracker::GameLoaded);

  m_loader_thread.start();

  for (QString dir : Settings().GetPaths())
    AddDirectory(dir);
}
示例#25
0
void cRecsDone::RemoveSearchID(int ID)
{
    if (ID == -1)
	return;
    cMutexLock RecsDoneLock(this);
    if (Count() == 0)
	Load(AddDirectory(CONFIGDIR, "epgsearchdone.data"));
    cRecDone* recDone = First();
    while (recDone)
    {
	if (recDone->searchID == ID)
	{
	    recDone->searchID = -1;
	    LogFile.Log(2,"search timer %d removed in recording %s~%s", ID, recDone->title?recDone->title:"unknown title", recDone->shortText?recDone->shortText:"unknown subtitle");
	}
	recDone = Next(recDone);
    }
    Save();
}
示例#26
0
文件: themes.c 项目: suborb/reelvdr
bool cThemes::Load(const char *SkinName)
{
  Clear();
  if (themesDirectory) {
     cReadDir d(themesDirectory);
     struct dirent *e;
     while ((e = d.Next()) != NULL) {
           if (strstr(e->d_name, SkinName) == e->d_name && e->d_name[strlen(SkinName)] == '-') {
              cString FileName = AddDirectory(themesDirectory, e->d_name);
              cTheme Theme;
              if (Theme.Load(*FileName, true)) {
                 if (char **NewBuffer = (char **)realloc(names, (numThemes + 1) * sizeof(char *))) {
                    names = NewBuffer;
                    names[numThemes] = strdup(Theme.Name());
                    }
                 else {
                    esyslog("ERROR: out of memory");
                    break;
                    }
                 if (char **NewBuffer = (char **)realloc(fileNames, (numThemes + 1) * sizeof(char *))) {
                    fileNames = NewBuffer;
                    fileNames[numThemes] = strdup(*FileName);
                    }
                 else {
                    esyslog("ERROR: out of memory");
                    break;
                    }
                 if (char **NewBuffer = (char **)realloc(descriptions, (numThemes + 1) * sizeof(char *))) {
                    descriptions = NewBuffer;
                    descriptions[numThemes] = strdup(Theme.Description());
                    }
                 else {
                    esyslog("ERROR: out of memory");
                    break;
                    }
                 numThemes++;
                 }
              }
           }
     return numThemes > 0;
     }
  return false;
}
示例#27
0
void cLiveQueue::RemoveTimeShiftFiles()
{
  DIR* dir = opendir((const char*)TimeShiftDir);

  if(dir == NULL)
    return;

  struct dirent* entry = NULL;

  while((entry = readdir(dir)) != NULL)
  {
    if(strncmp(entry->d_name, "xvdr-ringbuffer-", 16) == 0)
    {
      INFOLOG("Removing old time-shift storage: %s", entry->d_name);
      unlink(AddDirectory(TimeShiftDir, entry->d_name));
    }
  }

  closedir(dir);
}
示例#28
0
文件: Favorite.cpp 项目: Fale/sqlyog
// Function to add  files & folders to  Favorite menu
wyBool 
FavoriteBase::AddMenu(HMENU hmenu, wyString &parentpath)
{
	wyInt32				res;
	wyWChar				filename[MAX_PATH + 1] = {0};
	HANDLE				hfile;
	wyString			parent;
	WIN32_FIND_DATA		wfd={0};

    parent.SetAs(parentpath);
	parent.Add("*");
    hfile = ::FindFirstFile(parent.GetAsWideChar(), &wfd); 		

	if(hfile == INVALID_HANDLE_VALUE) 
		return wyFalse;
	
	do
	{	
		if ( wcscmp(L".", wfd.cFileName) == 0 || wcscmp(L"..", wfd.cFileName) == 0)
            res = ::FindNextFile(hfile, &wfd);
		else
		{	
			//wcscpy(filename, wfd.cFileName);
			wcsncpy(filename, wfd.cFileName, MAX_PATH);
			filename[MAX_PATH] = '\0';
			
			// check for favorite folder 
			if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) 
				AddDirectory(hmenu, parentpath, filename);
			else
				AddFile(hmenu, parentpath, filename);
						
            res = ::FindNextFile(hfile, &wfd);
		}
	
	}while(res);
	
    ::FindClose( hfile );			
	return wyTrue;
}
示例#29
0
文件: entry.c 项目: flensrocker/vdr
void cPictureEntry::Load(void) const
{
  if (isDirectory && !entries) {
     cString Directory = Path();
     cReadDir d(Directory);
     if (d.Ok()) {
        struct dirent *e;
        while ((e = d.Next()) != NULL) {
              struct stat ds;
              if (stat(AddDirectory(Directory, e->d_name), &ds) == 0) {
                 if (!entries)
                    entries = new cList<cPictureEntry>;
                 entries->Add(new cPictureEntry(e->d_name, this, S_ISDIR(ds.st_mode)));
                 }
              }
        if (entries)
           entries->Sort();
        }
     else
        LOG_ERROR_STR(*Directory);
     }
}
void cRecordingsCache::SaveResumeData()
{
  cMutexLock lock(&m_mutex);

  cString filename = AddDirectory(XVDRServerConfig.ConfigDirectory, RESUME_DATA_FILE);
  FILE* f = fopen((const char*)filename, "w");

  if(f == NULL)
  {
    ERRORLOG("unable to create resume data: %s", (const char*)filename);
    return;
  }

  std::map<uint32_t, struct RecEntry>::iterator i;
  for(i = m_recordings.begin(); i != m_recordings.end(); i++)
  {
    if(i->second.lastplayedposition != 0 || i->second.playcount != 0)
      fprintf(f, "%08x = %"PRIu64", %i\n", i->first, i->second.lastplayedposition, i->second.playcount);
  }

  fclose(f);
  return;
}