void MultipleFilePrinter::changeOstream(const std::string &path) {
  working_dir_ = extractDir(extractCorename(path));
  if (change_ostream_) {
    auto new_path = root_dir_ + extractCorename(path);
    filesystem::create_directories(extractDir(new_path));
    os_ = std::make_shared<std::ofstream>(new_path);
  }
}
bool MROMInstaller::runScripts(const std::string& dir, const std::string& base, const std::string& root)
{
	system("rm -r /tmp/script; mkdir /tmp/script");

	if(!hasEntry(dir))
	{
		LOGI("Skippping scripts in %s, not in the ZIP\n", dir.c_str());
		return true;
	}

	if(!extractDir(dir, "/tmp/script/"))
		return false;

	if(system("ls /tmp/script/*.sh") == 0)
	{
		system("chmod -R 777 /tmp/script/*");

		gui_print("Running %s scripts...\n", dir.c_str());

		char cmd[512];
		sprintf(cmd, "sh -c 'for x in $(ls /tmp/script/*.sh); do echo Running script $x; sh $x %s %s || exit 1; done'", base.c_str(), root.c_str());
		if(system(cmd) != 0)
		{
			system("rm -r /tmp/script/");
			gui_print("One of the ROM scripts returned error status!");
			return false;
		}
	}
	else
		LOGI("Skipping folder %s, no bash scripts\n", dir.c_str());

	system("rm -r /tmp/script");
	return true;
}
Esempio n. 3
0
bool CglWnd::selectImageFile()
{
	CMzString strFilePath(MAX_PATH);
	TCHAR defDir[MAX_PATH] = {0};
	bool bSelect = false;   
	bool ret = false;
	g_config->GetValue(L"Last", L"Path", L"\\Disk\\Photo", defDir, MAX_PATH);
	bSelect = selectFile(m_hWnd, strFilePath, CMzString(L"*.jpg;*.png;"), defDir);

	if (bSelect)
	{
		showWaiting(m_hWnd);
		ImagingHelper img;
		MemoryDC memDc;
		if (img.LoadImage(strFilePath.C_Str(), true, true))
		{
			HDC dc;
			if (img.GetImageWidth() == 480 && img.GetImageHeight() == 720)
			{
				dc = img.GetDC();
			}
			else
			{
				memDc.Create(480, 720);
				RECT r;
				HBRUSH hBrush = CreateSolidBrush(RGB(0,0,0));
				SetRect(&r, 0, 0, 480, 720);
				FillRect(memDc.GetDC(), &r, hBrush);
				DeleteObject(hBrush);
				int w,h;
				if (img.GetImageWidth()*3 > img.GetImageHeight()*2)
				{
					w = 480;
					h = w*img.GetImageHeight()/img.GetImageWidth();
				}
				else
				{
					h = 720;
					w = h*img.GetImageWidth()/img.GetImageHeight();
				}
				SetRect(&r, 240 - w/2, 360 - h/2, 240 + w/2, 360 + h/2);
				img.Draw(memDc.GetDC(), &r, true, true);
				dc = memDc.GetDC();
			}

			if (setImageFromDC(dc))
			{
				ret = true;
				removeAllBubbles();
				if (extractDir(strFilePath.C_Str(), defDir))
					g_config->SetValue(L"Last", L"Path", defDir);
				
			}
		}
		hideWaiting();
	}
	return ret;
}
Esempio n. 4
0
StorageObject *
PosixStorageManager::makeStorageObject(const StringC &spec,
				       const StringC &base,
				       Boolean search,
				       Boolean mayRewind,
				       Messenger &mgr,
				       StringC &found)
{
  if (spec.size() == 0) {
    mgr.message(PosixStorageMessages::invalidFilename,
		StringMessageArg(spec));
    return 0;
  }
  descriptorManager_.acquireD();
  Boolean absolute = isAbsolute(spec);
  SearchResultMessageArg sr;
  for (size_t i = 0; i < searchDirs_.size() + 1; i++) {
    StringC filename;
    if (absolute)
      filename = spec;
    else if (i == 0)
    	filename = combineDir(extractDir(base), spec);
    else
      filename = combineDir(searchDirs_[i - 1], spec);
#ifdef SP_WIDE_SYSTEM
    String<FChar> cfilename(filename);
    cfilename += FChar(0);
#else
    String<FChar> cfilename = filenameCodingSystem_->convertOut(filename);
#endif
    int fd;
    do {
      fd = openFile(cfilename.data());
    } while (fd < 0 && errno == EINTR);
    if (fd >= 0) {
      found = filename;
      return new PosixStorageObject(fd,
				    filename,
				    cfilename,
				    mayRewind,
				    &descriptorManager_);
    }
    int savedErrno = errno;
    if (absolute || !search || searchDirs_.size() == 0) {
      ParentLocationMessenger(mgr).message(PosixStorageMessages::openSystemCall,
					   StringMessageArg(filename),
					   ErrnoMessageArg(savedErrno));
      descriptorManager_.releaseD();
      return 0;
    }
    sr.add(filename, savedErrno);
  }
  descriptorManager_.releaseD();
  ParentLocationMessenger(mgr).message(PosixStorageMessages::cannotFind,
				       StringMessageArg(spec), sr);
  return 0;
}
Esempio n. 5
0
Boolean PosixStorageManager::resolveRelative(const StringC &baseId,
					     StringC &specId,
					     Boolean search) const
{
  if (isAbsolute(specId))
    return 1;
  if (!search || searchDirs_.size() == 0) {
    specId = combineDir(extractDir(baseId), specId);
    return 1;
  }
  return 0;
}