Exemplo n.º 1
0
void
pcl::ImageGrabberBase::ImageGrabberImpl::loadDepthAndRGBFiles (const std::string &depth_dir, const std::string &rgb_dir)
{
  if (!boost::filesystem::exists (depth_dir) || !boost::filesystem::is_directory (depth_dir))
  {
    PCL_ERROR ("[pcl::ImageGrabber::loadDepthAndRGBFiles] Error: attempted to instantiate a pcl::ImageGrabber from a path which"
               " is not a directory: %s", depth_dir.c_str ());
    return;
  }
  if (!boost::filesystem::exists (rgb_dir) || !boost::filesystem::is_directory (rgb_dir))
  {
    PCL_ERROR ("[pcl::ImageGrabber::loadDepthAndRGBFiles] Error: attempted to instantiate a pcl::ImageGrabber from a path which"
               " is not a directory: %s", rgb_dir.c_str ());
    return;
  }
  std::string pathname;
  std::string extension;
  std::string basename;
  boost::filesystem::directory_iterator end_itr;
  // First iterate over depth images
  for (boost::filesystem::directory_iterator itr (depth_dir); itr != end_itr; ++itr)
  {
    extension = boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ()));
    pathname = itr->path ().string ();
    basename = boost::filesystem::basename (itr->path ());
    if (!boost::filesystem::is_directory (itr->status ())
        && isValidExtension (extension))
    {
      if (basename.find ("depth") < std::string::npos)
      {
        depth_image_files_.push_back (pathname);
      }
    }
  }
  // Then iterate over RGB images
  for (boost::filesystem::directory_iterator itr (rgb_dir); itr != end_itr; ++itr)
  {
    extension = boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ()));
    pathname = itr->path ().string ();
    basename = boost::filesystem::basename (itr->path ());
    if (!boost::filesystem::is_directory (itr->status ())
        && isValidExtension (extension))
    {
      if (basename.find ("rgb") < std::string::npos)
      {
        rgb_image_files_.push_back (pathname);
      }
    }
  }
  if (depth_image_files_.size () != rgb_image_files_.size () )
    PCL_WARN ("[pcl::ImageGrabberBase::ImageGrabberImpl::loadDepthAndRGBFiles] : Watch out not same amount of depth and rgb images");
  if (!depth_image_files_.empty ())
    sort (depth_image_files_.begin (), depth_image_files_.end ());
  else
    PCL_ERROR ("[pcl::ImageGrabberBase::ImageGrabberImpl::loadDepthAndRGBFiles] : no depth images added");
  if (!rgb_image_files_.empty ())
    sort (rgb_image_files_.begin (), rgb_image_files_.end ());
  else
    PCL_ERROR ("[pcl::ImageGrabberBase::ImageGrabberImpl::loadDepthAndRGBFiles] : no rgb images added");
}
Exemplo n.º 2
0
void
pcl::ImageGrabberBase::ImageGrabberImpl::loadDepthAndRGBFiles (const std::string &dir)
{
  if (!boost::filesystem::exists (dir) || !boost::filesystem::is_directory (dir))
  {
    PCL_ERROR ("[pcl::ImageGrabber::loadDepthAndRGBFiles] Error: attempted to instantiate a pcl::ImageGrabber from a path which"
               " is not a directory: %s", dir.c_str ());
    return;
  }
  std::string pathname;
  std::string extension;
  std::string basename;
  boost::filesystem::directory_iterator end_itr;
  for (boost::filesystem::directory_iterator itr (dir); itr != end_itr; ++itr)
  {
    extension = boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ()));
    pathname = itr->path ().string ();
    basename = boost::filesystem::basename (itr->path ());
    if (!boost::filesystem::is_directory (itr->status ()) 
        && isValidExtension (extension))
    {
      if (basename.find ("rgb") < std::string::npos)
      {
        rgb_image_files_.push_back (pathname);
      }
      else if (basename.find ("depth") < std::string::npos)
      {
        depth_image_files_.push_back (pathname);
      }
    }
  }
  sort (depth_image_files_.begin (), depth_image_files_.end ());
  if (!rgb_image_files_.empty ())
    sort (rgb_image_files_.begin (), rgb_image_files_.end ());
}
Exemplo n.º 3
0
void CUrlBufferModule::CheckLineForLink(const CString& sMessage, const CString& sOrigin)
{
	if(sOrigin != m_pUser->GetUserName() && GetNV("enable").ToBool() )
	{	
		VCString words;
		CString output;
		sMessage.Split(" ", words, false, "", "", true, true);
		for (size_t a = 0; a < words.size(); a++) 
		{
			CString& word = words[a];
			if(word.Left(4) == "http" || word.Left(4) == "www.")
			{            
				//if you find an image download it, save it in the www directory and keep the new link in buffer
				VCString tokens;
				word.Split("/", tokens, false, "", "", true, true);
				CString name = tokens[tokens.size()-1];
				word.Split(".", tokens, false, "", "", true, true);

				//if it's an image link download/upload it else just keep the link
                time_t curtime;
                time(&curtime);
                CString dir = GetNV("directory") + CUtils::FormatTime(curtime,"%Y-%m-%d", m_pUser->GetTimezone()) + "/";
                CString nickname = (sOrigin.empty())? m_pUser->GetUserName() : sOrigin;
                if(!CFile::Exists(dir) && !CFile::IsDir(dir, false))
                {
                        CDir::MakeDir(dir, 0775);
                }

				if(isValidExtension( tokens[tokens.size()-1] ))
				{

                    std::stringstream ss;
					if( GetNV("enablelocal").ToBool())
					{
						ss << "wget -b -O " << dir.c_str() << name <<" -q " << word.c_str() << " 2>&1";
                        getStdoutFromCommand(ss.str());
					}
					ss.str("");
					if (!word.WildCmp("*imgur*") && GetNV("reupload").ToBool()) {
						ss << "curl -d \"image=" << word.c_str() << "\" -d \"key=5ce86e7f95d8e58b18931bf290f387be\" http://api.imgur.com/2/upload.xml | sed -n 's/.*<original>\\(.*\\)<\\/original>.*/\\1/p' 2>&1";
						output = getStdoutFromCommand(ss.str());
						lastUrls.push_back(output);
					} else {
						lastUrls.push_back(word);
					}
				} else if(GetNV("bufferalllinks").ToBool()){
					lastUrls.push_back(word);
                    //append nick:link to file
                    CString filename = dir + "links.txt";
                    std::ofstream log(filename.c_str() , std::ios_base::app | std::ios_base::out);
                    log << nickname << ": " << word << "\n"; 
				}
                                nicks.push_back( nickname );
			}
		}
	}
}
Exemplo n.º 4
0
void
pcl::ImageGrabberBase::ImageGrabberImpl::loadPCLZFFiles (const std::string &dir)
{
  if (!boost::filesystem::exists (dir) || !boost::filesystem::is_directory (dir))
  {
    PCL_ERROR ("[pcl::ImageGrabber::loadPCLZFFiles] Error: attempted to instantiate a pcl::ImageGrabber from a path which"
               " is not a directory: %s", dir.c_str ());
    return;
  }
  std::string pathname;
  std::string extension;
  std::string basename;
  boost::filesystem::directory_iterator end_itr;
  for (boost::filesystem::directory_iterator itr (dir); itr != end_itr; ++itr)
  {
#if BOOST_FILESYSTEM_VERSION == 3
    extension = boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->path ()));
    pathname = itr->path ().string ();
    basename = boost::filesystem::basename (itr->path ());
#else
    extension = boost::algorithm::to_upper_copy (boost::filesystem::extension (itr->leaf ()));
    pathname = itr->path ().filename ();
    basename = boost::filesystem::basename (itr->leaf ());
#endif
    if (!boost::filesystem::is_directory (itr->status ()) 
        && isValidExtension (extension))
    {
      if (basename.find ("rgb") < std::string::npos)
        rgb_pclzf_files_.push_back (pathname);
      else if (basename.find ("depth") < std::string::npos)
        depth_pclzf_files_.push_back (pathname);
      else
        xml_files_.push_back (pathname);

    }
  }
  sort (depth_pclzf_files_.begin (), depth_pclzf_files_.end ());
  if (rgb_pclzf_files_.size () > 0)
    sort (rgb_pclzf_files_.begin (), rgb_pclzf_files_.end ());
  sort (xml_files_.begin(), xml_files_.end());
  if (depth_pclzf_files_.size() != xml_files_.size())
  {
    PCL_ERROR("[pcl::ImageGrabber::loadPCLZFFiles] # depth clouds != # xml files\n");
    return;
  }
  if (depth_pclzf_files_.size() != rgb_pclzf_files_.size() && rgb_pclzf_files_.size() > 0)
  {
    PCL_ERROR("[pcl::ImageGrabber::loadPCLZFFiles] # depth clouds != # rgb clouds\n");
    return;
  }
}
Exemplo n.º 5
0
bool PresetInfoEnumerator::hasPresetInfo(const QString extension, const QString name) {
    // Check if preset info matching extension and preset name can be found
    if (!isValidExtension(extension))
        return false;

    for (QMap<QString, QMap<QString, PresetInfo> >::const_iterator it =
                 presetsByExtension.begin();
         it != presetsByExtension.end(); ++it) {
        for (QMap<QString, PresetInfo>::const_iterator it2 = it.value().begin();
             it2 != it.value().end(); ++it2) {
            if (name == it2.value().getName()) {
                return true;
            }
        }
    }
    return false;
}
Exemplo n.º 6
0
GrepResults DirectoryWorker::doWork()
{
    //Iterate over the current directory given - generate new "workers" as we go!
    //Blank directory iterator = "end" iterator
    directory_iterator end;
    for (directory_iterator bdi(currentDirectory); bdi != end; ++bdi) {
        path searchedFile = bdi->path();
        if (is_directory(searchedFile)) {
            //Generate new "directory worker" - add it to the queue
            workerFactory.GenerateWorker(WorkerType::DIRECTORY, searchedFile);
        }
        else if (is_regular_file(searchedFile)) {
            //Need to confirm that the "extension" of the file we are searching matches on in our list
            if (isValidExtension(searchedFile.extension().generic_string())) {
                //Generate new "FileWorker" - add it to the queue
                //Only want to track files we're actually scanning
                workerFactory.GenerateWorker(WorkerType::REGULARFILE, searchedFile);
            }
        }
    }

    //Currently - Return empty object as we don't care what this returns
    return GrepResults("");
}
Exemplo n.º 7
0
static int ScanFolder(const TCHAR *tszFolder, size_t cbBaseLen, int level, const TCHAR *tszBaseUrl, SERVLIST& hashes, OBJLIST<FILEINFO> *UpdateFiles)
{
	// skip updater's own folder
	if (!_tcsicmp(tszFolder, tszRoot))
		return 0;

	// skip profile folder
	TCHAR tszProfilePath[MAX_PATH];
	CallService(MS_DB_GETPROFILEPATHT, SIZEOF(tszProfilePath), (LPARAM)tszProfilePath);
	if (!_tcsicmp(tszFolder, tszProfilePath))
		return 0;

	TCHAR tszBuf[MAX_PATH];
	mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s\\*"), tszFolder);

	WIN32_FIND_DATA ffd;
	HANDLE hFind = FindFirstFile(tszBuf, &ffd);
	if (hFind == INVALID_HANDLE_VALUE)
		return 0;

	Netlib_LogfT(hNetlibUser,_T("Scanning folder %s"), tszFolder);

	int count = 0;
	do {
		if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
			// Scan recursively all subfolders
			if (_tcscmp(ffd.cFileName, _T(".")) && _tcscmp(ffd.cFileName, _T(".."))) {
				mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s\\%s"), tszFolder, ffd.cFileName);
				count += ScanFolder(tszBuf, cbBaseLen, level + 1, tszBaseUrl, hashes, UpdateFiles);
			}
		}
		else if (isValidExtension(ffd.cFileName)) {
			// calculate the current file's relative name and store it into tszNewName
			TCHAR tszNewName[MAX_PATH];
			if (!CheckFileRename(ffd.cFileName, tszNewName)) {
				if (level == 0)
					_tcsncpy(tszNewName, ffd.cFileName, MAX_PATH);
				else
					mir_sntprintf(tszNewName, SIZEOF(tszNewName), _T("%s\\%s"), tszFolder + cbBaseLen, ffd.cFileName);
			}

			TCHAR *ptszUrl;
			int MyCRC = 0;
			mir_sntprintf(tszBuf, SIZEOF(tszBuf), _T("%s\\%s"), tszFolder, ffd.cFileName);

			bool bDeleteOnly = (tszNewName[0] == 0);
			// this file is not marked for deletion
			if (!bDeleteOnly) {
				TCHAR *pName = tszNewName;
				ServListEntry *item = hashes.find((ServListEntry*)&pName);
				// Not in list? Check for trailing 'W' or 'w'
				if (item == NULL) {
					TCHAR *p = _tcsrchr(tszNewName, '.');
					if (p[-1] != 'w' && p[-1] != 'W')
						continue;

					// remove trailing w or W and try again
					int iPos = int(p - tszNewName) - 1;
					strdel(p - 1, 1);
					if ((item = hashes.find((ServListEntry*)&pName)) == NULL)
						continue;

					strdel(tszNewName + iPos, 1);
				}

				ptszUrl = item->m_name;
				// No need to hash a file if we are forcing a redownload anyway
				if (!opts.bForceRedownload) {
					// try to hash the file
					char szMyHash[33];
					__try {
						CalculateModuleHash(tszBuf, szMyHash);
						// hashes are the same, skipping
						if (strcmp(szMyHash, item->m_szHash) == 0)
							continue;
					}
					__except (EXCEPTION_EXECUTE_HANDLER)
					{
						// smth went wrong, reload a file from scratch
					}
				}

				MyCRC = item->m_crc;
			}