Пример #1
0
/**
 * Program entry point.
 */
int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  
  // Flash wizard is our main widget that goes through the whole
  // firmware flashing process.
  FlashWizard w;

  QStringList options;
  options.append("Fonera");
  options.append("Linksys");

  FilesList files;
  files.addFile("First file", true);
  files.addFile("Second file", true);

  // Initialize steps
  w.addPage(new WelcomeStep);
  w.addPage(new InstructionsStep("sample-1", "Sample Instructions", "This is a sample instruction page with a nice big image below. Niiice.", "state_power.png"));
  w.addPage(new SelectionStep("sample-2", "Sample selection", "Select option", "state_select.png", options));
  w.addPage(new FilesStep("sample-3", "Sample file form", "Fill the form", "state_select.png", files));

  ProgressStep *progress = new ProgressStep("sample-4", "Sample progress", "Progress", "state_install.png");
  progress->appendTerminalOutput("bash$ rm -rf /\nRemoving all files ... \nBye :D");
  w.addPage(progress);


  w.show();
  return a.exec();
}
Пример #2
0
void wxCrafterTab::BuildTree()
{
    m_treeCtrl->Freeze();
    m_treeCtrl->DeleteAllItems();
    
    m_treeCtrl->AddRoot(_("Hidden Root"));
    
    // Load all wxcp files
    FilesList allWxcpFiles;
    wxcHelper::GetAllFiles( allWxcpFiles, wxT("wxcp") );
    
    // Now add the file to the tab view
    FilesList::iterator iter = allWxcpFiles.begin();
    for(; iter != allWxcpFiles.end(); ++iter ) {
        wxFileName fnProjectFile( (*iter)->GetParentProject()->GetFilename() );
        wxFileName fnResrouceFile( (*iter)->file );
        wxTreeItemId projectItem = GetProjectNode( (*iter)->GetParentProject()->GetTitle() );
        if ( !projectItem.IsOk() ) {
            // First time, add a project node
            projectItem = m_treeCtrl->AppendItem(m_treeCtrl->GetRootItem(), (*iter)->GetParentProject()->GetTitle(), 1, 1, new wxCrafterTabItemData(wxCrafterTabItemData::kKindProject));
        }
        wxCrafterTabItemData* itemData = new wxCrafterTabItemData(fnResrouceFile.GetFullPath());
        
        fnResrouceFile.MakeRelativeTo( fnProjectFile.GetPath() );
        m_treeCtrl->AppendItem(projectItem, fnResrouceFile.GetFullPath(), 0, 0, itemData);
    }
    m_treeCtrl->ExpandAll();
    m_treeCtrl->Thaw();
}
Пример #3
0
void Platform::GetFilesByRegExp(string const & directory, string const & regexp, FilesList & res)
{
  if (ZipFileReader::IsZip(directory))
  {
    // Get files list inside zip file
    typedef ZipFileReader::FileListT FilesT;
    FilesT fList;
    ZipFileReader::FilesList(directory, fList);

    regexp::RegExpT exp;
    regexp::Create(regexp, exp);

    for (FilesT::iterator it = fList.begin(); it != fList.end(); ++it)
    {
      string & name = it->first;
      if (regexp::IsExist(name, exp))
      {
        // Remove assets/ prefix - clean files are needed for fonts white/blacklisting logic
        size_t const ASSETS_LENGTH = 7;
        if (name.find("assets/") == 0)
          name.erase(0, ASSETS_LENGTH);

        res.push_back(name);
      }
    }
  }
  else
    pl::EnumerateFilesByRegExp(directory, regexp, res);
}
Пример #4
0
void Platform::GetFilesByRegExp(string const & directory, string const & regexp, FilesList & outFiles)
{
  regex exp(regexp);

  QDir dir(QString::fromUtf8(directory.c_str()));
  int const count = dir.count();

  for (int i = 0; i < count; ++i)
  {
    string const name = dir[i].toUtf8().data();
    if (regex_search(name.begin(), name.end(), exp))
      outFiles.push_back(name);
  }
}
Пример #5
0
void Platform::GetFilesByRegExp(string const & directory, string const & regexp, FilesList & outFiles)
{
  regexp::RegExpT exp;
  regexp::Create(regexp, exp);

  QDir dir(QString::fromUtf8(directory.c_str()));
  int const count = dir.count();

  for (int i = 0; i < count; ++i)
  {
    string const name = dir[i].toUtf8().data();
    if (regexp::IsExist(name, exp))
      outFiles.push_back(name);
  }
}
Пример #6
0
void wxcHelper::GetAllFiles(FilesList& files, const wxString& filterExt)
{
    wxString filterExtLowerCase = filterExt;
    filterExtLowerCase.MakeLower();

    ProjectsArray* projects = Manager::Get()->GetProjectManager()->GetProjects();
    for ( size_t i=0; i<projects->GetCount(); ++i ) {
        cbProject* pProj = projects->Item(i);
        const FilesList& fileList = pProj->GetFilesList();
        FilesList::const_iterator iter = fileList.begin();
        for( ; iter != fileList.end(); ++iter ) {
            if( filterExtLowerCase.IsEmpty() || filterExtLowerCase == (*iter)->file.GetExt().MakeLower() ) {
                files.insert( (*iter) );
            }
        }
    }
}
Пример #7
0
void OpenWithAction::process(const IFileContainer *container, const FilesList &files) const
{
	Application::open(m_application, container, files.at(0).second);
}
Пример #8
0
	bool getFolderContent(shared_ptr<Path> folder)
	{
		WinDir dir(folder->path(), L"*");
		for (WinDir::iterator it = dir.begin(); it != dir.end(); ++it) {
			if (it.is_file()) {
				++Statistics::getInstance()->FoundFiles;
				Statistics::getInstance()->FoundFilesSize += it.size();
				if (SkipHidden && (it.attr() & FILE_ATTRIBUTE_HIDDEN)) {
					++Statistics::getInstance()->IgnoredHidden;
					{
						ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
						logDebug(L"File ignored [hidden]: ");
					}
					logDebug(L"\"%s\"\n", it.name());
				} else if (SkipSystem && (it.attr() & FILE_ATTRIBUTE_SYSTEM)) {
					++Statistics::getInstance()->IgnoredSystem;
					{
						ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
						logDebug(L"File ignored [system]: ");
					}
					logDebug(L"\"%s\"\n", it.name());
				} else if (it.size() == 0LL) {
					++Statistics::getInstance()->IgnoredZero;
					{
						ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
						logDebug(L"File ignored [zero]: ");
					}
					logDebug(L"\"%s\"\n", it.name());
				} else if (!LinkSmall && (it.size() < MIN_FILE_SIZE)) {
					++Statistics::getInstance()->IgnoredSmall;
					{
						ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
						logDebug(L"File ignored [small]: ");
					}
					logDebug(L"\"%s\"\n", it.name());
				} else {
					//logFile(info);
					data.push_back(shared_ptr < File > (new File(folder, it.name())));
				}
			} else {
				if (SkipJunct && it.is_link()) {
					++Statistics::getInstance()->IgnoredJunc;
					{
						ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
						logDebug(L"Dir  ignored [junction]: ");
					}
					logDebug(L"\"%s\"\n", it.name());
				} else {
					if (it.is_link())
						++Statistics::getInstance()->FoundJuncs;
					else
						++Statistics::getInstance()->FoundDirs;
//					logFile(info);
					if (recursive) {
						bool Result = getFolderContent(shared_ptr < Path > (new Path(folder, it.name())));
						if (!Result)
							return false;
					}
				}
			}
		}

//		WIN32_FIND_DATAW	info;
//		HANDLE	hFind = ::FindFirstFileW(mask.c_str(), &info);
//		if (hFind == INVALID_HANDLE_VALUE) {
//			logError(::GetLastError(), L"Unable to read folder \"%s\" content.\n", path.c_str());
//		} else {
//			do {
//				if (is_valid_filename(info.cFileName)) {
//					if (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
//						uintmax_t	filesize = MyUI64(info.nFileSizeLow, info.nFileSizeHigh);
//						++Statistics::getInstance()->FoundFiles;
//						Statistics::getInstance()->FoundFilesSize += filesize;
//						if (SkipHidden && (info.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)) {
//							++Statistics::getInstance()->IgnoredHidden;
//							{
//								ConsoleColor	col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
//								logDebug(L"File ignored [hidden]: ");
//							}
//							logDebug(L"\"%s\"\n", info.cFileName);
//						} else if (SkipSystem && (info.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)) {
//							++Statistics::getInstance()->IgnoredSystem;
//							{
//								ConsoleColor	col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
//								logDebug(L"File ignored [system]: ");
//							}
//							logDebug(L"\"%s\"\n", info.cFileName);
//						} else if (filesize == 0LL) {
//							++Statistics::getInstance()->IgnoredZero;
//							{
//								ConsoleColor	col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
//								logDebug(L"File ignored [zero]: ");
//							}
//							logDebug(L"\"%s\"\n", info.cFileName);
//						} else if (!LinkSmall && (filesize < MIN_FILE_SIZE)) {
//							++Statistics::getInstance()->IgnoredSmall;
//							{
//								ConsoleColor	col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
//								logDebug(L"File ignored [small]: ");
//							}
//							logDebug(L"\"%s\"\n", info.cFileName);
//						} else {
//							logFile(info);
//							data.push_back(shared_ptr<File>(new File(folder, info.cFileName)));
//						}
//					} else {
//						if (SkipJunct && info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
//							++Statistics::getInstance()->IgnoredJunc;
//							{
//								ConsoleColor	col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
//								logDebug(L"Dir  ignored [junction]: ");
//							}
//							logDebug(L"\"%s\"\n", info.cFileName);
//						} else {
//							if (info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
//								++Statistics::getInstance()->FoundJuncs;
//							else
//								++Statistics::getInstance()->FoundDirs;
//							logFile(info);
//							if (recursive) {
//								bool	Result = getFolderContent(shared_ptr<Path>(new Path(folder, info.cFileName)));
//								if (!Result)
//									return	false;
//							}
//						}
//					}
//				}
//			} while (::FindNextFile(hFind, &info) != 0);
//			dwError = ::GetLastError();
//			::FindClose(hFind);
//			if (dwError != ERROR_NO_MORE_FILES) {
//				logError(dwError, L"FindNextFile error\n");
//				return	false;
//			}
//		}
		return true;
	}
Пример #9
0
	void Process()
	{
		PathListIt it = paths.begin();
		while (it != paths.end()) {
			getFolderContent(*it);
			++it;
		}
		logInfo(L"Files to process:\t%8llu\n", data.size());

		logDebug(L"");
		std::sort(data.begin(), data.end(), CompareBySizeAndTime);
		std::pair<FilesListIt, FilesListIt> bounds;
		FilesListIt srch = data.begin();
		while (srch != data.end()) {
			logCounter(L"Files left:\t%8llu", std::distance(srch, data.end()));
			bounds = std::equal_range(srch, data.end(), *srch, CompareBySize);
			if (std::distance(bounds.first, bounds.second) == 1) {
				++Statistics::getInstance()->filesFoundUnique;
				data.erase(bounds.first);
			} else {
				while (srch != bounds.second) {
					FilesListIt it = srch;
					++it;
					shared_ptr<File>& f1 = *srch;
					while (it != bounds.second) {
						shared_ptr<File>& f2 = *it;
						AutoUTF buf1(f1->path());
						AutoUTF buf2(f2->path());
						{
							ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN);
							logDebug(L"Comparing files [size = %I64u]:\n", f1->size());
						}
						logDebug(L"  %s\n", buf1.c_str());
						logDebug(L"  %s\n", buf2.c_str());
						++Statistics::getInstance()->fileCompares;
						f1->refresh();
						f2->refresh();
						if (AttrMustMatch && f1->attr() != f2->attr()) {
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
								logDebug(L"  Attributes of files do not match, skipping\n");
							}
							Statistics::getInstance()->fileMetaDataMismatch++;
							++it;
							break;
						}
						if (TimeMustMatch && f1->mtime() != f2->mtime()) {
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
								logDebug(L"  Modification timestamps of files do not match, skipping\n");
							}
							Statistics::getInstance()->fileMetaDataMismatch++;
							++it;
							break;
						}
						if (!isSameVolume(*f1, *f2)) {
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
								logDebug(L"  Files ignored - on different volumes\n");
							}
							++Statistics::getInstance()->filesOnDifferentVolumes;
							++it;
							break;
						}
						if (f1 == f2) {
							++Statistics::getInstance()->fileAlreadyLinked;
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_GREEN);
								logDebug(L"  Files ignored - already linked\n");
							}
							++it;
							break;
						}
						if (f1->size() > FirstBlock) {
							if (!f1->LoadHashMini()) {
								break;
							}
							if (!f2->LoadHashMini()) {
								it = data.erase(it);
								continue;
							}
						} else {
							if (!f1->LoadHashFull()) {
								break;
							}
							if (!f2->LoadHashFull()) {
								it = data.erase(it);
								continue;
							}
						}
						if (isIdentical(*f1, *f2)) {
							++Statistics::getInstance()->fileContentSame;
							if (logLevel == LOG_VERBOSE) {
								{
									ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN);
									logVerbose(L"Comparing files [size = %I64u]:\n", f1->size());
								}
								logVerbose(L"  %s\n", buf1.c_str());
								logVerbose(L"  %s\n", buf2.c_str());
							}
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
								logVerbose(L"  Files are equal, hard link possible\n");
							}
							if (hardlink) {
								f1->hardlink(*f2);
							}
							Statistics::getInstance()->FreeSpaceIncrease += f1->size();
							it = data.erase(it);
						} else {
							{
								ConsoleColor col(FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
								logDebug(L"  Files differ in content (hash)\n");
							}
							Statistics::getInstance()->hashComparesHit1++;
							++it;
						}
					}
					srch = data.erase(srch);
				}
			}
			srch = bounds.second;
		}
		logCounter(L"                              ");
	}
Пример #10
0
void Platform::GetSystemFontNames(FilesList & res) const
{
#if defined(OMIM_OS_MAC) || defined(OMIM_OS_IPHONE)
#else
  char const * fontsWhitelist[] = {
    "Roboto-Medium.ttf",
    "DroidSansFallback.ttf",
    "DroidSansFallbackFull.ttf",
    "DroidSans.ttf",
    "DroidSansArabic.ttf",
    "DroidSansSemc.ttf",
    "DroidSansSemcCJK.ttf",
    "DroidNaskh-Regular.ttf",
    "Lohit-Bengali.ttf",
    "Lohit-Devanagari.ttf",
    "Lohit-Tamil.ttf",
    "PakType Naqsh.ttf",
    "wqy-microhei.ttc",
    "Jomolhari.ttf",
    "Jomolhari-alpha3c-0605331.ttf",
    "Padauk.ttf",
    "KhmerOS.ttf",
    "Umpush.ttf",
    "DroidSansThai.ttf",
    "DroidSansArmenian.ttf",
    "DroidSansEthiopic-Regular.ttf",
    "DroidSansGeorgian.ttf",
    "DroidSansHebrew-Regular.ttf",
    "DroidSansHebrew.ttf",
    "DroidSansJapanese.ttf",
    "LTe50872.ttf",
    "LTe50259.ttf",
    "DevanagariOTS.ttf",
    "FreeSans.ttf",
    "DejaVuSans.ttf",
    "arial.ttf",
    "AbyssinicaSIL-R.ttf",
  };

  char const * systemFontsPath[] = {
    "/system/fonts/",
#ifdef OMIM_OS_LINUX
    "/usr/share/fonts/truetype/roboto/",
    "/usr/share/fonts/truetype/droid/",
    "/usr/share/fonts/truetype/ttf-dejavu/",
    "/usr/share/fonts/truetype/wqy/",
    "/usr/share/fonts/truetype/freefont/",
    "/usr/share/fonts/truetype/padauk/",
    "/usr/share/fonts/truetype/dzongkha/",
    "/usr/share/fonts/truetype/ttf-khmeros-core/",
    "/usr/share/fonts/truetype/tlwg/",
    "/usr/share/fonts/truetype/abyssinica/",
    "/usr/share/fonts/truetype/paktype/",
    "/usr/share/fonts/truetype/mapsme/",
#endif
  };

  const uint64_t fontSizeBlacklist[] = {
    183560,   // Samsung Duos DroidSans
    7140172,  // Serif font without Emoji
    14416824  // Serif font with Emoji
  };

  uint64_t fileSize = 0;

  for (size_t i = 0; i < ARRAY_SIZE(fontsWhitelist); ++i)
  {
    for (size_t j = 0; j < ARRAY_SIZE(systemFontsPath); ++j)
    {
      string const path = string(systemFontsPath[j]) + fontsWhitelist[i];
      if (IsFileExistsByFullPath(path))
      {
        if (GetFileSizeByName(path, fileSize))
        {
          uint64_t const * end = fontSizeBlacklist + ARRAY_SIZE(fontSizeBlacklist);
          if (find(fontSizeBlacklist, end, fileSize) == end)
          {
            res.push_back(path);
            LOG(LINFO, ("Found usable system font", path, "with file size", fileSize));
          }
        }
      }
    }
  }
#endif
}