コード例 #1
0
ファイル: ItemHandle_nix.cpp プロジェクト: aszlig/Desurium
inline gcString createDesktopFile(ItemInfoI* i)
{
	// KDE menu doesn't accept files like "Publisher Name-GameName.desktop" so we replace all " " with "_"
	gcString publisher = boost::algorithm::replace_all_copy(std::string(i->getPublisher()), " ", "_");

	gcString tmpPath("{0}/{1}-{2}.desktop",
	                 UTIL::OS::getCachePath(),
	                 publisher,
	                 i->getShortName());

	std::ofstream desktopFile(tmpPath);
	desktopFile << "[Desktop Entry]"
	            << "\nType=Application"
	            << "\nName=" << i->getName()
	            << "\nComment=" << i->getDesc()
	            << "\nIcon=" << i->getIcon()
	            << "\nTryExec=" << i->getActiveExe()->getExe()
	            << "\nExec=" << i->getActiveExe()->getExe() << ' '
	                         << i->getActiveExe()->getExeArgs()
	            << "\nCategories=Game;" << i->getGenre() << ';'
	            << std::endl;
	desktopFile.close();

	return tmpPath;
}
コード例 #2
0
void CMPlayerUtility::OpenUrl(CMString sUrl, const UINT32 nMode/* = EMode_3mv*/, const char* coursewareID )
{
    
    string path = CMCourseDownload::GetInstance()->GetLocalFilePath(coursewareID);
    
    //先检查本地文件在不在
    if(path.size() !=0 && CMFile::FileExist(CMString(path.c_str())))
    {
    	OpenFile(CMString(path.c_str()), nMode);
    	return;
    }
    
	CMPath tmpPath(CMPath::DOWNLOAD_PATH);
    CMString sOrgUrl;

    INT32 pos = sUrl.ReverseFind(L"?sid=");
    if(pos < 0)
    	pos = sUrl.ReverseFind(L"&sid=");
    if(pos > 0)
    	sOrgUrl = sUrl.Left(pos);
    else
    	sOrgUrl = sUrl;
    
    
    CMString filename = tmpPath.String()+CMFile::GetTempFileName(sOrgUrl, "");
	if(CMFile::FileExist(filename))
    {
    	OpenFile(filename, nMode);
    	return;
    }
    //本地无此文件,去数据库读取
    if(m_nState == EReady)
    {
        m_bDataCompleted = FALSE;
        SAFEDELETE(m_pMediaData);
        m_bOnlyAudio = nMode != EMode_3mv;
        if(nMode == EMode_3mv || nMode == EMode_3ma)
            m_pMediaData = new CMNetDataSource;
		else if(nMode == EMode_aac)
			 m_pMediaData = new CMAACDataSource;
		else
			return;
        BOOL ret = FALSE;
        
//        sUrl = CMString("http://42.96.138.63/Upload/Files/root/CourseWareFile/201401/201401101233202695248e5b93f75f4685af/201401161429192546803cd48b08aa3daf7f_(960x640).3mv");
        printf("surl:%s \n",(const CHAR*)sUrl);
        
        if(m_pMediaData && m_pMediaData->Init(this, m_pStreamBuffer))
            ret = m_pMediaData->Open(sUrl, NET_VOD);
        if(ret)
        {
            m_pMediaData->Start();
            m_PlayerObserver.StateChange(m_UserData, EOpening, m_nState);
            m_nState = EOpening;
        }
        else
            SAFEDELETE(m_pMediaData);
    }
}
コード例 #3
0
coResult coCppTypesGeneratorPlugin::GenerateType(coDynamicString& _relativePath, const coParsedType& _parsedType)
{
	const coType* type = _parsedType.type;
	coASSERT(type);
	coTRY(type->name != "", "Empty type name");

	coLocalAllocator localAllocator(4048);
	coDynamicString absolutePath(localAllocator);

	// Paths
	{
		const coConstString& projectPath = projectGenerator->GetProjectRelativePath();
		coDynamicString tmpPath(localAllocator);
		coJoinPaths(tmpPath, projectPath, co_typesPath);
		coJoinPaths(_relativePath, tmpPath, type->name);
		_relativePath << ".cxx";

		const coConstString& outPath = projectGenerator->GetOutReferenceDir();
		coJoinPaths(absolutePath, outPath, _relativePath);
		coASSERT(coIsPathNormalized(_relativePath));
	}

	coStringOutputStream stream;
	coWriteHeader(stream);
	coWriteInclude(stream, _parsedType.sourcePath);
	coWriteInclude(stream, "lang/reflect/coType.h");
	coWriteInclude(stream, "lang/reflect/coType_f.h");
	coWriteInclude(stream, "lang/result/coResult_f.h");
	coWriteInclude(stream, "lang/reflect/coTypeBuilder.h");
	coWriteInclude(stream, "lang/reflect/coTypeAutoRegistrator.h");
	if (_parsedType.parsedFields.count)
	{
		coWriteInclude(stream, "lang/reflect/coField.h");
		coWriteInclude(stream, "lang/reflect/coField_f.h");
	}
	coWriteInclude(stream, "lang/result/coResult.h");
	coWriteInclude(stream, "container/string/coDynamicString_f.h");
	stream << "\n";
	coTRY(WriteTypeBuilderDeclaration(stream, _parsedType), nullptr);
	coTRY(WriteInitTypeFunc(stream, _parsedType), nullptr);
	coTRY(WriteLinkTypeFunc(stream, _parsedType), nullptr);
	coTRY(WriteGetStaticTypeFunc(stream, _parsedType), nullptr);
	coTRY(stream.GetResult(), "Failed to write to stream: "<<stream << ".");

	{
		coDynamicArray<coByte> output;
		stream.GetOutput(output);
		coFileAccess file;
		coFileAccess::InitConfig c;
		c.mode = coFileAccess::write;
		c.path = absolutePath;
		coTRY(file.Init(c), "Failed to open for writing: " << file << ".");
		coTRY(file.Write(output), "Failed to write in: " << file << ".");
	}

	return true;
}
コード例 #4
0
CSequentialFormatter::CSequentialFormatter(CGenericFrameProvider* _frameProv,
                                           std::string _baseFolder,
                                           std::string _outputFileFormat)
    : CGenericFormatter(_frameProv)
    , mBaseFolder(_baseFolder)
    , mOutputFileFormat(_outputFileFormat)
{
    LOG(INFO) << "CSequentialFormatter created:";
    LOG(INFO) << "\tBase folder: " << mBaseFolder;
    LOG(INFO) << "\tOutput file format: " << mOutputFileFormat;

    boost::filesystem::path tmpPath(mBaseFolder);
    tmpPath /= mOutputFileFormat;
    mWholeTemplate = tmpPath.native();
}
コード例 #5
0
ファイル: griditem.cpp プロジェクト: FlorinLozneanu/lines
/*!
*/
void GridItem::moveBall(BallItem *ball, const QVector<GridPos> &path)
{
    if (!ball) {
        qDebug() << "GridItem::moveBall(...): pointer to the ball item is NULL";
        return;
    }

    QVector<GridPos> tmpPath(path);

    // skip the first square
    GridPos firstPos = tmpPath.front();
    freePos(firstPos);
    //

    // the source square becomes available
    BallItemsProvider::instance()->fromUsedToAvailable(firstPos);
    //

    QGraphicsScene *theScene = scene();
    Q_ASSERT(theScene);
    Q_ASSERT(theScene->views().isEmpty() == false);

    theScene->views()[0]->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
    foreach(GridPos pos, tmpPath) {
        if (pos != tmpPath.back()) {
            // do not store the ball item on the positions of the intermediate squares (the 3rd argument
            // is set to false).
            showBall(ball, pos, false);
            pause(100);
        } else {
            // is there any hint ball onto the target square ?
            BallItem *hintBall = ballAt(pos);
            if (hintBall) {
                hideBall(hintBall);
                delete hintBall;

                BallItemsProvider::instance()->removeHint(hintBall);
            }

            // stores the ball item on the position of the target square.
            showBall(ball, pos, true);
        }
        // also wipes the path tracks square by square
        m_pathTracker.removeFrontLine();
        update();
    }
}
コード例 #6
0
VError XLinuxFile::Copy(const VFilePath& inDestination, VFile** outFile, FileCopyOptions inOptions ) const
{
	VFilePath tmpPath(inDestination);
	
	if(tmpPath.IsFolder())
	{
		VStr255 name;					//jmo - todo : NAME_MAX ?
		fOwner->GetName(name);
		tmpPath.SetFileName(name);
	}

 	PathBuffer dstPath;
 	dstPath.Init(tmpPath);

	CopyHelper cpHlp;
	return cpHlp.Copy(fPath, dstPath);
}
コード例 #7
0
HANDLE CreateTempFile(WCHAR *filePathBufOut, size_t bufSize)
{
    ScopedMem<WCHAR> tmpPath(path::GetTempPath(L"nPV"));
    if (!tmpPath)
    {
        plogf("sp: CreateTempFile(): GetTempPath() failed");
        return NULL;
    }
    str::BufSet(filePathBufOut, bufSize, tmpPath);

    HANDLE hFile = CreateFile(filePathBufOut, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
                              FILE_ATTRIBUTE_NORMAL, NULL);
    if (INVALID_HANDLE_VALUE == hFile)
    {
        plogf("sp: CreateTempFile(): CreateFile() failed");
        return NULL;
    }
    return hFile;
}
コード例 #8
0
ファイル: CDRTypes.cpp プロジェクト: LibreOffice/libcdr
void libcdr::CDRPolygon::create(libcdr::CDRPath &path) const
{
  if (m_numAngles == 0)
    return;

  libcdr::CDRPath tmpPath(path);
  double step = 2*M_PI / (double)m_numAngles;
  if (m_nextPoint && m_numAngles % m_nextPoint)
  {
    libcdr::CDRTransform tmpTrafo(cos(m_nextPoint*step), sin(m_nextPoint*step), 0.0, -sin(m_nextPoint*step), cos(m_nextPoint*step), 0.0);
    for (unsigned i = 1; i < m_numAngles; ++i)
    {
      tmpPath.transform(tmpTrafo);
      path.appendPath(tmpPath);
    }
  }
  else
  {
    libcdr::CDRTransform tmpTrafo(cos(m_nextPoint*step), sin(m_nextPoint*step), 0.0, -sin(m_nextPoint*step), cos(m_nextPoint*step), 0.0);
    libcdr::CDRTransform tmpShift(cos(step), sin(step), 0.0, -sin(step), cos(step), 0.0);
    for (unsigned i = 0; i < m_nextPoint; ++i)
    {
      if (i)
      {
        tmpPath.transform(tmpShift);
        path.appendPath(tmpPath);
      }
      for (unsigned j=1; j < m_numAngles / m_nextPoint; ++j)
      {
        tmpPath.transform(tmpTrafo);
        path.appendPath(tmpPath);
      }
      path.appendClosePath();
    }
  }
  path.appendClosePath();
  libcdr::CDRTransform trafo(m_rx, 0.0, m_cx, 0.0, m_ry, m_cy);
  path.transform(trafo);
}
コード例 #9
0
int b3ResourcePath::findResourcePath(const char* resourceName, char* resourcePathOut, int resourcePathMaxNumBytes, PFN_FIND_FILE findFile, void* userPointer)
{
	if (findFile==0)
	{
		findFile=b3MyFindFile;
	}
	//first find in a resource/<exeName> location, then in various folders within 'data' using b3FileUtils
	char exePath[B3_MAX_EXE_PATH_LEN];

	bool res = findFile(userPointer, resourceName, resourcePathOut, resourcePathMaxNumBytes);
	if (res)
	{
		return strlen(resourcePathOut);
	}

	if (sAdditionalSearchPath[0])
	{
		TempResourcePath tmpPath(resourcePathMaxNumBytes + 1024);
		char* resourcePathIn = tmpPath.m_path;
		sprintf(resourcePathIn, "%s/%s", sAdditionalSearchPath, resourceName);
		//printf("try resource at %s\n", resourcePath);
		if (findFile(userPointer, resourcePathIn, resourcePathOut, resourcePathMaxNumBytes))
		{
			return strlen(resourcePathOut);
		}
	}

	int l = b3ResourcePath::getExePath(exePath, B3_MAX_EXE_PATH_LEN);
	if (l)
	{
		char pathToExe[B3_MAX_EXE_PATH_LEN];

		int exeNamePos = b3FileUtils::extractPath(exePath, pathToExe, B3_MAX_EXE_PATH_LEN);
		if (exeNamePos)
		{
			TempResourcePath tmpPath(resourcePathMaxNumBytes + 1024);
			char* resourcePathIn = tmpPath.m_path;
			sprintf(resourcePathIn, "%s../data/%s", pathToExe, resourceName);
			//printf("try resource at %s\n", resourcePath);
			if (findFile(userPointer, resourcePathIn, resourcePathOut, resourcePathMaxNumBytes))
			{
				return strlen(resourcePathOut);
			}

			sprintf(resourcePathIn, "%s../resources/%s/%s", pathToExe, &exePath[exeNamePos], resourceName);
			//printf("try resource at %s\n", resourcePath);
			if (findFile(userPointer, resourcePathIn, resourcePathOut, resourcePathMaxNumBytes))
			{
				return strlen(resourcePathOut);
			}
			sprintf(resourcePathIn, "%s.runfiles/google3/third_party/bullet/data/%s", exePath, resourceName);
			//printf("try resource at %s\n", resourcePath);
			if (findFile(userPointer, resourcePathIn, resourcePathOut, resourcePathMaxNumBytes))
			{
				return strlen(resourcePathOut);
			}
		}
	}

	return 0;
}
コード例 #10
0
ファイル: HeaderHeader.cpp プロジェクト: HaikuArchives/Pe
status_t
RunPopUpMenu(BPoint where, BString &header, BString &fileName, 
	CLanguageInterface *languageInterface)
{
	status_t err;
	BPath path;
	BDirectory dir;
	err = GetSettingsDir(dir, path);
	err = B_ERROR;
	BPopUpMenu *menu = BuildPopUp(dir);
	if (menu == NULL)
		return B_ERROR;
	
	BMenuItem *item = menu->Go(where, false, true);
	//if (item && item->Message())
	//	item->Message()->PrintToStream();

	switch ((item && item->Message()) ? item->Message()->what : 0)
	{
		case 'head':
		{
			if (item->Message()->FindString("template", &header) < B_OK)
				break;
			BString tmp;
			time_t now = time(NULL);
			struct tm *tim = localtime(&now);
			// date
			char *p;
			p = tmp.LockBuffer(100);
			memset(p, 0, 100);
			strftime(p, 100, "%Y-%m-%d", tim);
			tmp.UnlockBuffer();
			header.ReplaceAll("%DATE%", tmp.String());
			tmp.Truncate(0);
			
			p = tmp.LockBuffer(100);
			memset(p, 0, 100);
			strftime(p, 100, "%T", tim);
			tmp.UnlockBuffer();
			header.ReplaceAll("%TIME%", tmp.String());
			tmp.Truncate(0);

			// year
			p = tmp.LockBuffer(10);
			memset(p, 0, 10);
			strftime(p, 10, "%Y", tim);
			tmp.UnlockBuffer();
			header.ReplaceAll("%YEAR%", tmp.String());
			tmp.Truncate(0);

			// fetch from query on META:email==** ?
			p = tmp.LockBuffer(B_PATH_NAME_LENGTH);
			memset(p, 0, B_PATH_NAME_LENGTH);
			err = dir.ReadAttr("pe:author_people", B_STRING_TYPE, 0LL, p, 
				B_PATH_NAME_LENGTH);
			tmp.UnlockBuffer();
			//printf("ppl:%s\n", tmp.String());
			BNode people;
			if (err > 0)
				people.SetTo(tmp.String());
			tmp.Truncate(0);
			
			BString attr;

			static struct {
				const char *tmplName;
				const char *attrName;
			} attrMap[] = {
				{ "%AUTHOR%", "META:name" },
				{ "%AUTHORMAIL%", "META:email" },
				{ "%COMPANY%", "META:company" },
				{ "%AUTHORURL%", "META:url" },
				{ NULL, NULL }
			};
			int i;

			for (i = 0; attrMap[i].tmplName; i++)
			{
				p = attr.LockBuffer(256);
				memset(p, 0, 256);
				err = people.ReadAttr(attrMap[i].attrName, B_ANY_TYPE, 
					0LL, p, 256);
				//printf("ReadAttr: %d, %s\n", err, attr.String());
				attr.UnlockBuffer();

				tmp << attr;
				header.ReplaceAll(attrMap[i].tmplName, tmp.String());
				tmp.Truncate(0);
				attr.Truncate(0);
			}

			BString fileNameNoExt(fileName);
			if (fileNameNoExt.FindLast('.') > -1)
				fileNameNoExt.Truncate(fileNameNoExt.FindLast('.'));
			header.ReplaceAll("%FILENAMENOEXT%", fileNameNoExt.String());
			header.ReplaceAll("%FILENAME%", fileName.String());
			/*
			tmp << "Haiku";
			header.ReplaceAll("%PROJECT%", tmp.String());
			tmp.Truncate(0);
			*/

			// better values for C++
			BString language("C/C++");
			BString commentLineStart("/*");
			BString commentLineEnd("");
			BString commentBlockStart("/*");
			BString commentBlockCont(" *");
			BString commentBlockLazy("");
			BString commentBlockLineEnd("");
			BString commentBlockEnd(" */");
			if (languageInterface)
			{
				// if not C++
				if (language != languageInterface->Name())
				{
					language = languageInterface->Name();
					commentLineStart = languageInterface->LineCommentStart();
					commentLineEnd = languageInterface->LineCommentEnd();
					// I'd miss a CommentCanSpanLines()
					// let's assume line end means can span
					if (commentLineEnd.Length())
					{
						commentBlockStart = commentLineStart;
						commentBlockCont = "";
						commentBlockLazy = "";
						commentBlockLineEnd = "";
						commentBlockEnd = commentLineEnd;
					}
					else
					{
						commentBlockStart = commentLineStart;
						commentBlockCont = commentLineStart;
						commentBlockLazy = commentLineStart;
						commentBlockLineEnd = commentLineEnd;
						commentBlockEnd = commentLineStart;
					}
					/*
					printf("LANG:'%s' CS:'%s' CE:'%s'\n", 
						language.String(), 
						commentLineStart.String(), 
						commentLineEnd.String());
					*/
				}
			}
			// comment start
			header.ReplaceAll("%COMMS%", commentBlockStart.String());
			// comment cont'd
			header.ReplaceAll("%COMMC%", commentBlockCont.String());
			// comment cont'd lazy (blank if possible)
			header.ReplaceAll("%COMML%", commentBlockLazy.String());
			// comment end
			header.ReplaceAll("%COMME%", commentBlockEnd.String());
			// comment line end
			commentBlockLineEnd << "\n";
			header.ReplaceAll("\n", commentBlockLineEnd.String());


			err = B_OK;
			break;
		}
		case 'optf':
		{
			const char *args[] = {path.Path(), NULL};
			err = be_roster->Launch(sTrackerSig, 1, (char **)args);
			//printf("err %s\n", strerror(err));
			err = B_CANCELED;
			break;
		}
		case 'seta':
		{
			MimeRefFilter filter("application/x-person");
			BPath path;
			entry_ref people;

			if (find_directory(B_USER_DIRECTORY, &path) == B_OK)
			{
				path.Append("people");
				get_ref_for_path(path.Path(), &people);
			}

			BFilePanel *panel;
			panel = new BFilePanel(B_OPEN_PANEL, NULL, &people,
				B_FILE_NODE, false, NULL, &filter);
			// trick to synchronously use BFilePanel
			PanelHandler *handler = new PanelHandler;
			if (panel->Window()->Lock())
			{
				panel->Window()->AddHandler(handler);
				panel->Window()->Unlock();
			}
			panel->SetTarget(BMessenger(handler));
			panel->Show();
			if (handler->Wait() < B_OK)
				break;
			if (!handler->Message())
				break;
			if (handler->Message()->what == B_CANCEL)
				break;
			entry_ref ref;
			//panel->Message()->PrintToStream();
			if (panel->GetNextSelectedRef(&ref) == B_OK)
			{
				//printf("ref:%s\n", ref.name);
				path.SetTo(&ref);
				dir.WriteAttr("pe:author_people", B_STRING_TYPE, 0LL, 
					path.Path(), strlen(path.Path()));
			}
			delete panel;
			delete handler;
			err = B_CANCELED;
			break;
		}
		case B_ABOUT_REQUESTED:
		{
			BString tmpPath("/tmp/Pe-HeaderHeader-About-");
			tmpPath << system_time() << "-" << getpid() << ".txt";
			entry_ref ref;
			get_ref_for_path(tmpPath.String(), &ref);
			{
				BFile f(&ref, B_CREATE_FILE | B_WRITE_ONLY);
				err = f.InitCheck();
				if (err < 0)
					break;
				f.Write(sAboutText, strlen(sAboutText));
				f.SetPermissions(0444);
			}
			BMessage msg(B_REFS_RECEIVED);
			msg.AddRef("refs", &ref);
			err = be_app_messenger.SendMessage(&msg);
			err = B_CANCELED;
			break;
		}
		case 0:
			err = B_CANCELED;
			break;
		default:
			break;
	}
	delete menu;
	return err;
}
コード例 #11
0
vector<string> MusicVideoService::downloadAudio(const string& url) {
  LOG(INFO) << "downloadYouTubeAudio with url " << url;
  vector<string> filepaths;

  boost::filesystem::path tmpPath(SoulSifterSettings::getInstance().get<string>("dir.tmp"));  // todo: use os.tmpdir()
  if (!boost::filesystem::exists(tmpPath)) {
    if (!boost::filesystem::create_directories(tmpPath)) {
      LOG(WARNING) << "Unable to create temporary directory " << tmpPath;
      return filepaths;
    }
  } else if (!boost::filesystem::is_directory(tmpPath)) {
    LOG(WARNING) << "Temporary directory is not a directory " << tmpPath;
    return filepaths;
  }

  FILE *fpipe;
  stringstream command;
  command << "cd " << tmpPath << "; youtube-dl --print-json --write-all-thumbnails --restrict-filenames --extract-audio --audio-format mp3 --audio-quality 0 --quiet " << url;
  if (!(fpipe = (FILE*)popen(command.str().c_str(), "r"))) {
    LOG(WARNING) << "Problem with youtube-dl pipe.";
    return filepaths;
  }

  char buffer[1024];
  stringstream ss;
  LOG(INFO) << "Running command '" << command.str() << "'";
  while (fgets(buffer, sizeof buffer, fpipe)) {
    ss << buffer;
  }

  pclose(fpipe);

  // read output
  string json;
  while (std::getline(ss, json, '\n')) {
    if (json.at(0) == '{') {
      boost::property_tree::ptree ptree;
      std::stringstream tmp(json);
      read_json(tmp, ptree);

      Song* song = new Song();
      Album* album = new Album();
      song->setAlbum(album);

      string baseFileName = ptree.get<string>("_filename").substr(0, ptree.get<string>("_filename").size() - ptree.get<string>("ext").size());
      song->setFilepath(SoulSifterSettings::getInstance().get<string>("dir.tmp") + '/' + baseFileName + "mp3");
      album->setCoverFilepath(SoulSifterSettings::getInstance().get<string>("dir.tmp") + '/' + baseFileName + "jpg");
      string title = ptree.get<string>("title");
      if (!MusicManager::getInstance().splitArtistAndTitle(title, song)) {
        song->setArtist(ptree.get<string>("uploader"));
        song->setTitle(title);
      }
      MusicManager::getInstance().moveFeaturing(song);
      MusicManager::getInstance().copyRemixer(song);
      song->setLowQuality(true);
      song->setCurator(ptree.get<string>("uploader"));
      string date = ptree.get<string>("upload_date", "00000000");
      if (!date.empty() && !!date.compare("null")) {
        album->setReleaseDateYear(std::stoi(date.substr(0, 4)));
        album->setReleaseDateMonth(std::stoi(date.substr(4, 2)));
        album->setReleaseDateDay(std::stoi(date.substr(6, 4)));
      }
      album->setArtist(song->getArtist());
      album->setName(song->getTitle());

      TagService::writeId3v2Tag(song);
      filepaths.push_back(song->getFilepath());
      filepaths.push_back(album->getCoverFilepath());
      delete song;
      return filepaths;
    }
  }
  return filepaths;
}
コード例 #12
0
ファイル: swipl-ld.c プロジェクト: ddgold/design_patterns
static void
fillDefaultOptions()
{ char tmp[1024];
  char *defcxx = PROG_CXX;

  defaultProgram(&cc,  PROG_CC);
  if ( streq(cc, "gcc") )			/* TBD: MINGW */
    defcxx = "g++";
  defaultProgram(&cxx, defcxx);

  if ( !ld )				/* not specified */
  { ld = (shared ? SO_LD : PROG_LD);

    if ( cppfiles.size > 0 && streq(ld, cc) )
      ld = cxx;
  }

#if defined(HOST_TOOLCHAIN_MSC)
  if ( strcmp(LIB_PL_DEBUG,pllib) == 0 )
    ensureOption(&coptions, "/MDd");
  else ensureOption(&coptions, "/MD");
  ensureOption(&coptions, "/D__WINDOWS__");
  ensureOption(&coptions, "/nologo");
  ensureOption(&ldoptions, "/nologo");
#endif

  tmpPath(&ctmp,   "ctmp-");
  tmpPath(&pltmp,  "pltmp-");
#if defined(__CYGWIN__)
/* Compile generates .exe files on Cygwin */
  replaceExtension(ctmp, "exe", tmp);
  free(ctmp);
  ctmp = strdup(tmp);
#endif
#if defined(HOST_OS_WINDOWS)
/* Saved states have the .exe extension under Windows */
  replaceExtension(pltmp, "exe", tmp);
  free(pltmp);
  pltmp = strdup(tmp);
#endif
  if ( shared && !out && !nolink )
  { fprintf(stderr, "%s: \"-o out\" required for linking shared object\n", plld);
    exit(1);
  }
#if defined(HOST_OS_WINDOWS)
  if ( out && !nolink )
  { replaceExtension(out, shared || embed_shared ? "dll" : "exe", tmp);
    out = strdup(tmp);
  }
#endif
  defaultPath(&out, PROG_OUT);

  defaultProgram(&plgoal,     "version");
  defaultProgram(&pltoplevel, "prolog");
  defaultProgram(&plinitfile, "none");
  defaultProgram(&plsysinit,  "none");

#ifdef __WINDOWS__
  sprintf(tmp, "%s/lib", plbase);
#else
  sprintf(tmp, "%s/lib/%s", plbase, plarch);
#endif
  prependArgList(&libdirs, tmp);
  sprintf(tmp, "%s/include", plbase);
  prependArgList(&includedirs, tmp);
}
コード例 #13
0
ファイル: Archiver7ZIP.cpp プロジェクト: Claybird/lhaforge
//指定されたディレクトリ内部を展開する;高速実装
bool CArchiver7ZIP::ExtractDirectoryEntry(LPCTSTR lpszArcFile,CConfigManager &ConfMan,const ARCHIVE_ENTRY_INFO_TREE* lpBase,const ARCHIVE_ENTRY_INFO_TREE* lpDir,LPCTSTR lpszOutputBaseDir,bool bCollapseDir,CString &strLog)
{
	//---一時フォルダ中にまとめて展開し、後からフォルダ構造を切り出す
	std::list<CString> files;

	CString strPath;

	bool bRestoreDir=false;
	if(lpDir->strFullPath.IsEmpty()){
		//ディレクトリが登録されていないのでパス名を算出する
		ArcEntryInfoTree_GetNodePathRelative(lpDir,lpBase,strPath);
		strPath.Replace(_T('/'),_T('\\'));

		CPath tmpPath(strPath);
		tmpPath.RemoveBackslash();	//ディレクトリだったら裸にする
		tmpPath.RemoveFileSpec();	//親ディレクトリまで切りつめる
		tmpPath.Append(_T("*"));	//特定ディレクトリ以下の全てのファイルを展開
		files.push_back(tmpPath);

		bRestoreDir=true;
	}else{
		//ディレクトリもアーカイブ中にエントリとして登録されているなら出力する
		CString tmpPath(lpDir->strFullPath);
		if(tmpPath[tmpPath.GetLength()-1]==_T('\\')||tmpPath[tmpPath.GetLength()-1]==_T('/')){
			//末尾の\もしくは/を削除
			tmpPath.Delete(tmpPath.GetLength()-1);
		}
		files.push_back(tmpPath);

		strPath=lpDir->strFullPath;
		strPath.Replace(_T('/'),_T('\\'));
	}

	//--------------------------------------
	// 修正された出力ディレクトリパスを算出
	//--------------------------------------
	//---本来の出力先
	CString strOutputDir=lpszOutputBaseDir+strPath;
	if(strOutputDir.GetLength()>_MAX_PATH){
		//フォルダ名が長くなりすぎた
		strLog=CString(MAKEINTRESOURCE(IDS_ERROR_MAX_PATH));
		return false;
	}

	//FileListには1件しか入っていないはず
	ASSERT(files.size()==1);

	//一時フォルダ
	CTemporaryDirectoryManager tdm(_T("lhaf"));
	CPath strTempOutput(tdm.GetDirPath());
	if(bRestoreDir){	//ディレクトリを手作業で復元
		strTempOutput+=strPath;
		strTempOutput.AddBackslash();
		TRACE(_T("手作業でのディレクトリ復元:%s\n"),(LPCTSTR)strTempOutput);
		if(!UtilMakeSureDirectoryPathExists(strTempOutput)){
			strLog.Format(IDS_ERROR_CANNOT_MAKE_DIR,strTempOutput);
			return false;
		}
	}
	//---一時フォルダ中にまとめて展開し、後からフォルダ構造を切り出す
	// ファイルを展開
	if(!ExtractSpecifiedOnly(lpszArcFile,ConfMan,strTempOutput,files,strLog,true)){
		return false;
	}

	//送り側ファイル名指定
	CPath tmp(strTempOutput);
	tmp+=(LPCTSTR)strPath;	//PathAppend相当
	tmp.RemoveBackslash();
	CString strSrcFiles(tmp);
	strSrcFiles+=_T("||");
	//受け側ファイル名指定
	tmp=lpszOutputBaseDir;
	{
		CString strTmp;
		ArcEntryInfoTree_GetNodePathRelative(lpDir,lpBase,strTmp);
		strTmp.Replace(_T('/'),_T('\\'));
		tmp+=(LPCTSTR)strTmp;
	}
	tmp.AddBackslash();
	CString strDestFiles(tmp);
	strDestFiles+=_T("||");

	//'|'を'\0'に変換する
	std::vector<TCHAR> srcBuf(strSrcFiles.GetLength()+1);
	UtilMakeFilterString(strSrcFiles,&srcBuf[0],srcBuf.size());
	std::vector<TCHAR> destBuf(strDestFiles.GetLength()+1);
	UtilMakeFilterString(strDestFiles,&destBuf[0],destBuf.size());

	//ファイル操作内容
	SHFILEOPSTRUCT fileOp={0};
	fileOp.wFunc=FO_MOVE;
	fileOp.fFlags=FOF_MULTIDESTFILES|/*FOF_NOCONFIRMATION|*/FOF_NOCONFIRMMKDIR|FOF_NOCOPYSECURITYATTRIBS|FOF_NO_CONNECTED_ELEMENTS;
	fileOp.pFrom=&srcBuf[0];
	fileOp.pTo=&destBuf[0];

	//移動実行
	if(::SHFileOperation(&fileOp)){
		//エラー
		strLog=CString(MAKEINTRESOURCE(IDS_ERROR_FILE_MOVE));
		return false;
	}else if(fileOp.fAnyOperationsAborted){
		//キャンセル
		strLog=CString(MAKEINTRESOURCE(IDS_ERROR_USERCANCEL));
		return false;
	}

	return true;

}
コード例 #14
0
// Returns true if this method handled the glyph, false if needs to be passed to fallback
//
bool GrDistanceFieldTextContext::appendGlyph(GrGlyph::PackedID packed,
                                             SkScalar sx, SkScalar sy,
                                             GrFontScaler* scaler) {
    if (NULL == fDrawTarget) {
        return true;
    }

    if (NULL == fStrike) {
        fStrike = fContext->getFontCache()->getStrike(scaler, true);
    }

    GrGlyph* glyph = fStrike->getGlyph(packed, scaler);
    if (NULL == glyph || glyph->fBounds.isEmpty()) {
        return true;
    }

    // fallback to color glyph support
    if (kA8_GrMaskFormat != glyph->fMaskFormat) {
        return false;
    }

    SkScalar dx = SkIntToScalar(glyph->fBounds.fLeft + SK_DistanceFieldInset);
    SkScalar dy = SkIntToScalar(glyph->fBounds.fTop + SK_DistanceFieldInset);
    SkScalar width = SkIntToScalar(glyph->fBounds.width() - 2*SK_DistanceFieldInset);
    SkScalar height = SkIntToScalar(glyph->fBounds.height() - 2*SK_DistanceFieldInset);

    SkScalar scale = fTextRatio;
    dx *= scale;
    dy *= scale;
    sx += dx;
    sy += dy;
    width *= scale;
    height *= scale;
    SkRect glyphRect = SkRect::MakeXYWH(sx, sy, width, height);

    // check if we clipped out
    SkRect dstRect;
    const SkMatrix& ctm = fViewMatrix;
    (void) ctm.mapRect(&dstRect, glyphRect);
    if (fClipRect.quickReject(SkScalarTruncToInt(dstRect.left()),
                              SkScalarTruncToInt(dstRect.top()),
                              SkScalarTruncToInt(dstRect.right()),
                              SkScalarTruncToInt(dstRect.bottom()))) {
        return true;
    }

    if (NULL == glyph->fPlot) {
        // needs to be a separate conditional to avoid over-optimization
        // on Nexus 7 and Nexus 10

        // If the glyph is too large we fall back to paths
        if (!uploadGlyph(glyph, scaler)) {
            if (NULL == glyph->fPath) {
                SkPath* path = SkNEW(SkPath);
                if (!scaler->getGlyphPath(glyph->glyphID(), path)) {
                    // flag the glyph as being dead?
                    delete path;
                    return true;
                }
                glyph->fPath = path;
            }

            // flush any accumulated draws before drawing this glyph as a path.
            this->flush();

            SkMatrix ctm;
            ctm.setScale(fTextRatio, fTextRatio);
            ctm.postTranslate(sx - dx, sy - dy);

            SkPath tmpPath(*glyph->fPath);
            tmpPath.transform(ctm);

            GrStrokeInfo strokeInfo(SkStrokeRec::kFill_InitStyle);
            fContext->drawPath(fRenderTarget, fClip, fPaint, fViewMatrix, tmpPath, strokeInfo);

            // remove this glyph from the vertices we need to allocate
            fTotalVertexCount -= kVerticesPerGlyph;
            return true;
        }
    }

    SkASSERT(glyph->fPlot);
    GrDrawTarget::DrawToken drawToken = fDrawTarget->getCurrentDrawToken();
    glyph->fPlot->setDrawToken(drawToken);

    GrTexture* texture = glyph->fPlot->texture();
    SkASSERT(texture);

    if (fCurrTexture != texture || fCurrVertex + kVerticesPerGlyph > fTotalVertexCount) {
        this->flush();
        fCurrTexture = texture;
        fCurrTexture->ref();
    }

    bool useColorVerts = !fUseLCDText;

    if (NULL == fVertices) {
        int maxQuadVertices = kVerticesPerGlyph * fContext->getQuadIndexBuffer()->maxQuads();
        fAllocVertexCount = SkMin32(fTotalVertexCount, maxQuadVertices);
        fVertices = alloc_vertices(fDrawTarget,
                                   fAllocVertexCount,
                                   useColorVerts);
    }

    fVertexBounds.joinNonEmptyArg(glyphRect);

    int u0 = glyph->fAtlasLocation.fX + SK_DistanceFieldInset;
    int v0 = glyph->fAtlasLocation.fY + SK_DistanceFieldInset;
    int u1 = u0 + glyph->fBounds.width() - 2*SK_DistanceFieldInset;
    int v1 = v0 + glyph->fBounds.height() - 2*SK_DistanceFieldInset;

    size_t vertSize = get_vertex_stride(useColorVerts);
    intptr_t vertex = reinterpret_cast<intptr_t>(fVertices) + vertSize * fCurrVertex;

    // V0
    SkPoint* position = reinterpret_cast<SkPoint*>(vertex);
    position->set(glyphRect.fLeft, glyphRect.fTop);
    if (useColorVerts) {
        SkColor* color = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint));
        *color = fPaint.getColor();
    }
    SkIPoint16* textureCoords = reinterpret_cast<SkIPoint16*>(vertex + vertSize -
                                                              sizeof(SkIPoint16));
    textureCoords->set(u0, v0);
    vertex += vertSize;

    // V1
    position = reinterpret_cast<SkPoint*>(vertex);
    position->set(glyphRect.fLeft, glyphRect.fBottom);
    if (useColorVerts) {
        SkColor* color = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint));
        *color = fPaint.getColor();
    }
    textureCoords = reinterpret_cast<SkIPoint16*>(vertex + vertSize  - sizeof(SkIPoint16));
    textureCoords->set(u0, v1);
    vertex += vertSize;

    // V2
    position = reinterpret_cast<SkPoint*>(vertex);
    position->set(glyphRect.fRight, glyphRect.fBottom);
    if (useColorVerts) {
        SkColor* color = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint));
        *color = fPaint.getColor();
    }
    textureCoords = reinterpret_cast<SkIPoint16*>(vertex + vertSize  - sizeof(SkIPoint16));
    textureCoords->set(u1, v1);
    vertex += vertSize;

    // V3
    position = reinterpret_cast<SkPoint*>(vertex);
    position->set(glyphRect.fRight, glyphRect.fTop);
    if (useColorVerts) {
        SkColor* color = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint));
        *color = fPaint.getColor();
    }
    textureCoords = reinterpret_cast<SkIPoint16*>(vertex + vertSize  - sizeof(SkIPoint16));
    textureCoords->set(u1, v0);

    fCurrVertex += 4;
    
    return true;
}
コード例 #15
0
ファイル: server.cpp プロジェクト: rupinder/GNU-MyServer
/*!
  Here is loaded the configuration of the server.
  The configuration file is a XML file.
  Return nonzero on errors.
 */
int Server::initialize ()
{
  const char *data;
#ifdef WIN32
  envString = GetEnvironmentStrings ();
#endif
  connectionsMutex = new Mutex ();
  threadsMutex = new Mutex ();

  /* Store the default values.  */
  nStaticThreads = 20;
  nMaxThreads = 50;
  currentThreadID = 0;
  freeThreads = 0;
  connectionTimeout = MYSERVER_SEC (180);
  endServer = false;
  purgeThreadsThreshold = 1;
  throttlingRate = 0;
  maxConnections = 0;
  maxConnectionsToAccept = 0;

  if (genMainConf)
    {
      configurationFileManager = genMainConf (this,
                                              mainConfigurationFile.c_str ());
      if (!configurationFileManager)
        {
          log (MYSERVER_LOG_MSG_ERROR,
               _("Error while loading the %s configuration file"),
               mainConfigurationFile.c_str ());
          return -1;
        }

    }
  else
    {
      XmlMainConfiguration *xmlMainConf = new XmlMainConfiguration ();
      if (xmlMainConf->open (mainConfigurationFile.c_str ()))
        {
          log (MYSERVER_LOG_MSG_ERROR,
               _("Error while loading the %s configuration file"),
               mainConfigurationFile.c_str ());
          delete xmlMainConf;
          return -1;
        }
      configurationFileManager = xmlMainConf;
    }

  configurationFileManager->readData (&hashedDataTrees, &hashedData);

  /* Process console colors information.  */
  list<string> levels = logManager->getLoggingLevelsByNames ();
  for (list<string>::iterator it = levels.begin (); it != levels.end (); it++)
    {
      string fg (*it + "_fg");
      string bg (*it + "_bg");

      string fullFg ("log_color." + *it + "_fg");
      string fullBg ("log_color." + *it + "_bg");
      data = getData (fullFg.c_str ());
      if (data)
        consoleColors[fg] = string (data);

      data = getData (fullBg.c_str ());
      if (data)
        consoleColors[bg] = string (data);
    }

  initLogManager ();

  data = getData ("server.buffer_size", "102400");
  if (data)
    buffersize = (atol (data) > 81920) ?  atol (data) :  81920 ;

  data = getData ("connection.timeout");
  if (data)
    connectionTimeout = MYSERVER_SEC ((u_long) atol (data));

  data = getData ("server.static_threads");
  if (data)
    nStaticThreads = atoi (data);

  data = getData ("server.max_threads");
  if (data)
    nMaxThreads = atoi (data);

  /* Get the max connections number to allow.  */
  data = getData ("server.max_connections");
  if (data)
    maxConnections = atoi (data);

  /* Get the max connections number to accept.  */
  data = getData ("server.max_accepted_connections");
  if (data)
    maxConnectionsToAccept = atoi (data);

  data = getData ("server.connections_pool.size");
  if (data)
    connectionsPool.init (atoi (data));

  /* Get the default throttling rate to use on connections.  */
  data = getData ("connection.throttling");
  if (data)
    throttlingRate = (u_long) atoi (data);

  data = getData ("server.max_log_size");
  if (data)
    maxLogFileSize=(u_long) atol (data);

  data = getData ("server.max_files_cache");
  if (data)
    {
      u_long maxSize = (u_long) atol (data);
      cachedFiles.initialize (maxSize);
    }
  else
    cachedFiles.initialize (1 << 23);

  data = getData ("server.temp_directory");
  if (data)
    {
      string tmpPath (data);
      FilesUtility::completePath (tmpPath);
      FilesUtility::setTmpPath (tmpPath);
    }
  else
    FilesUtility::resetTmpPath ();

  data = getData ("server.max_file_cache");
  if (data)
    {
      u_long maxSize = (u_long) atol (data);
      cachedFiles.setMaxSize (maxSize);
    }

  data = getData ("server.min_file_cache");
  if (data)
    {
      u_long minSize = (u_long) atol (data);
      cachedFiles.setMinSize (minSize);
    }

  data = getData ("server.uid");
  if (data)
    uid.assign (data);
  else
    uid.assign ("");

  data = getData ("server.gid");
  if (data)
    gid.assign (data);
  else
    gid.assign ("");

  data = getData ("server.max_servers");
  if (data)
    {
      int maxServersProcesses = atoi (data);
      getProcessServerManager ()->setMaxServers (maxServersProcesses);
    }

  return 0;
}
コード例 #16
0
ファイル: ScanDlg.cpp プロジェクト: jf4210/src2-test
void CScanDlg::OnBnClickedBtnScan()
{
#ifdef TEST_TIP_SHOW
	CScanMgrDlg* pTmpDlg = (CScanMgrDlg*)GetParent();
	pTmpDlg->ShowChildDlg(3);
	return;
#endif
	int           sel = m_comboScanner.GetCurSel();
	TW_INT16      index = (TW_INT16)m_comboScanner.GetItemData(sel);
	pTW_IDENTITY  pID = NULL;

	_nScanStatus_ = 0;
	if (!_bLogin_)
	{
		CNewMessageBox	dlg;
		dlg.setShowInfo(2, 1, "未登录, 无法扫描");
		dlg.DoModal();
		return;
	}
	if (_pCurrExam_->nModel == 0 && !_pModel_)
	{
		CNewMessageBox	dlg;
		dlg.setShowInfo(2, 1, "当前考试无模板信息");
		dlg.DoModal();
		return;
	}

	int nMustScanNum = 0;		//必须扫描的试卷数量,在高厉害模式时生效,保存试卷时,检查扫描的数量是否与此数量一致,不一致不能提交,只能重扫
	if (g_nHighSevereMode && _pCurrExam_->nModel == 0)	//手阅模式不显示扫描数量对话框
	{
		int nDefScanCounts = 0;
		char* ret;
		ret = new char[20];
		ret[0] = '\0';
		if (ReadRegKey(HKEY_CURRENT_USER, "Software\\EasyTNT\\AppKey", REG_SZ, "defScanCounts", ret) == 0)
		{
			nDefScanCounts = atoi(ret);
		}
		SAFE_RELEASE_ARRY(ret);
		g_nDefStudentsInKC = nDefScanCounts > 0 ? nDefScanCounts : 30;

		//高厉害考试模式
		CSetScanNumDlg dlg(g_nDefStudentsInKC);
		if (dlg.DoModal() != IDOK)
			return;
		nMustScanNum = dlg.m_nScanNum;

		char szRet[20] = { 0 };
		sprintf_s(szRet, "%d", nMustScanNum);
		WriteRegKey(HKEY_CURRENT_USER, "Software\\EasyTNT\\AppKey", REG_SZ, "defScanCounts", szRet);
	}

	if (_nScanAnswerModel_ == 1)
	{
		CNewMessageBox	dlg;
		dlg.setShowInfo(1, 1, "当前处于扫描 客观题(Omr) 答案模式!");
		dlg.DoModal();
	}
	else if (_nScanAnswerModel_ == 2)
	{
		CNewMessageBox	dlg;
		dlg.setShowInfo(1, 1, "当前处于扫描 主观题 答案模式!");
		dlg.DoModal();
	}
	
	USES_CONVERSION;
	char szPicTmpPath[MAX_PATH] = { 0 };
	sprintf_s(szPicTmpPath, "%sPaper\\Tmp", T2A(g_strCurrentPath));

	std::string strUtfPath = CMyCodeConvert::Gb2312ToUtf8(szPicTmpPath);
	try
	{
		Poco::File tmpPath(strUtfPath);
		if (tmpPath.exists())
			tmpPath.remove(true);

		Poco::File tmpPath1(strUtfPath);
		tmpPath1.createDirectories();
	}
	catch (Poco::Exception& exc)
	{
		std::string strLog = "删除临时文件夹失败(" + exc.message() + "): ";
		strLog.append(szPicTmpPath);
		g_pLogger->information(strLog);
	}

	m_strCurrPicSavePath = szPicTmpPath;

#ifdef Test_Data
	TestData();
	if (g_nHighSevereMode)	_pCurrPapersInfo_->nMustScanNum = nMustScanNum;
	return;
#endif

	//获取扫描参数
	int nScanSize = 1;				//1-A4		//TWSS_A4LETTER-a4, TWSS_A3-a3, TWSS_NONE-自定义
	int nScanType = 2;				//0-黑白,1-灰度,2-彩色
	int nScanDpi = 200;				//dpi: 72, 150, 200, 300
	int nAutoCut = 1;
	if (_pModel_)
	{
		nScanSize = _pModel_->nScanSize;
		nScanType = _pModel_->nScanType;
		nScanDpi = _pModel_->nScanDpi;
		nAutoCut = _pModel_->nAutoCut;

		m_nModelPicNums = _pModel_->nPicNum;

		//扫描主观题答案时,模板图像数值1
		if(_nScanAnswerModel_ == 2) m_nModelPicNums = 1;
	}
	else  //手阅
	{
		m_nModelPicNums = _nPicNum4Ty_;
	}

	bool bShowScanSrcUI = g_bShowScanSrcUI ? true : m_bAdvancedScan;			//显示高级扫描界面


	_nDoubleScan_ = m_comboDuplex.GetCurSel();
	int nDuplex = m_comboDuplex.GetCurSel();		//单双面,0-单面,1-双面
	int nSize = TWSS_NONE;							//1-A4		//TWSS_A4LETTER-a4, TWSS_A3-a3, TWSS_NONE-自定义
	if (nScanSize == 1)
		nSize = TWSS_A4LETTER;
	else if (nScanSize == 2)
		nSize = TWSS_A3;
	else
		nSize = TWSS_NONE;
	
	int nNum = 0;
	if (nDuplex == 0)
	{
		nNum = m_nCurrentScanCount * m_nModelPicNums;
	}
	else
	{
		int nModelPics = m_nModelPicNums;
		if (nModelPics % 2)
			nModelPics++;

		nNum = m_nCurrentScanCount * nModelPics;
	}
	if (nNum == 0)
		nNum = -1;
	
	CScanMgrDlg* pDlg = (CScanMgrDlg*)GetParent();
	if (NULL != (pID = pDlg->GetScanSrc(index)))
	{
		SAFE_RELEASE(_pCurrPapersInfo_);
		_pCurrPapersInfo_ = new PAPERSINFO();

		if (g_nHighSevereMode)	_pCurrPapersInfo_->nMustScanNum = nMustScanNum;
		
		_nScanStatus_ = 1;
		pST_SCANCTRL pScanCtrl = new ST_SCANCTRL();
		pScanCtrl->nScannerId = pID->Id;
		pScanCtrl->nScanCount = nNum;			//nNum
		pScanCtrl->nScanDuplexenable = nDuplex;
		pScanCtrl->nScanPixelType = nScanType;
		pScanCtrl->nScanResolution = nScanDpi;
		pScanCtrl->nScanSize = nSize;
		pScanCtrl->bShowUI = bShowScanSrcUI;	//bShowScanSrcUI;
		pScanCtrl->nAutoCut = nAutoCut;

		pDlg->m_scanThread.ResetGlobalVal();
		pDlg->m_scanThread.setNotifyDlg(pDlg);
		pDlg->m_scanThread.setModelInfo(m_nModelPicNums, m_strCurrPicSavePath);
		pDlg->m_scanThread.resetData();
		pDlg->ResetChildDlg();
		pDlg->m_scanThread.PostThreadMessage(MSG_START_SCAN, pID->Id, (LPARAM)pScanCtrl);

		pDlg->ShowChildDlg(3);
	}
	else
	{
		CNewMessageBox	dlg;
		dlg.setShowInfo(2, 1, "获取扫描源失败");
		dlg.DoModal();
	}

	char szRet[20] = { 0 };
	sprintf_s(szRet, "%d", sel);
	WriteRegKey(HKEY_CURRENT_USER, "Software\\EasyTNT\\AppKey", REG_SZ, "scanSrc", szRet);
	memset(szRet, 0, 20);
	sprintf_s(szRet, "%d", nDuplex);
	WriteRegKey(HKEY_CURRENT_USER, "Software\\EasyTNT\\AppKey", REG_SZ, "scanDuplex", szRet);
}
コード例 #17
0
ファイル: Omega.cpp プロジェクト: yade/trunk
void Omega::cleanupTemps(){
	boost::filesystem::path tmpPath(tmpFileDir);
	boost::filesystem::remove_all(tmpPath);
}
コード例 #18
0
void CScanModelPaperDlg::OnBnClickedBtnMakemodelScan()
{
	UpdateData(TRUE);
	USES_CONVERSION;
	std::string strSavePath = T2A(m_strSavePath);
	if (m_strSavePath == _T(""))
	{
		CNewMessageBox dlg;
		dlg.setShowInfo(2, 1, "图像保存路径为空!");
		dlg.DoModal();
		return;
	}

	Poco::File fileSaveDir(CMyCodeConvert::Gb2312ToUtf8(strSavePath));
	if (!fileSaveDir.exists())
	{
		CNewMessageBox dlg;
		dlg.setShowInfo(2, 1, "图像保存路径不存在或非法!");
		dlg.DoModal();
		return;
	}

	int           sel = m_comboScanSrc.GetCurSel();
	TW_INT16      index = (TW_INT16)m_comboScanSrc.GetItemData(sel);
	pTW_IDENTITY  pID = NULL;

	_nScanStatus_ = 0;

	char szPicTmpPath[MAX_PATH] = { 0 };
	if (_pCurrSub_)
		sprintf_s(szPicTmpPath, "%s\\%s", T2A(m_strSavePath), _pCurrSub_->strSubjName.c_str());
	else
		sprintf_s(szPicTmpPath, "%s", T2A(m_strSavePath));

	std::string strUtfPath = CMyCodeConvert::Gb2312ToUtf8(szPicTmpPath);
	try
	{
		if (_pCurrSub_)
		{
			Poco::File tmpPath(strUtfPath);
			if (tmpPath.exists())
				tmpPath.remove(true);

			Poco::File tmpPath1(strUtfPath);
			tmpPath1.createDirectories();
		}		
	}
	catch (Poco::Exception& exc)
	{
		std::string strLog = "删除临时文件夹失败(" + exc.message() + "): ";
		strLog.append(szPicTmpPath);
		g_pLogger->information(strLog);
	}
	strSavePath = szPicTmpPath;
	
	//获取扫描参数
	int nScanSize = m_comboPaperSize.GetCurSel();				//1-A4		//TWSS_A4LETTER-a4, TWSS_A3-a3, TWSS_NONE-自定义
	int nScanType = 2;				//0-黑白,1-灰度,2-彩色
	int nScanDpi = 200;				//dpi: 72, 150, 200, 300
	int nAutoCut = 1;

	bool bShowScanSrcUI = g_bShowScanSrcUI ? true : m_bAdvancedScan;			//显示高级扫描界面

	int nDuplex = m_comboDuplex.GetCurSel();		//单双面,0-单面,1-双面

	int nSize = 0;							//1-A4		//TWSS_A4LETTER-a4, TWSS_A3-a3, TWSS_NONE-自定义
	if (nScanSize == 0)
		nSize = TWSS_A4LETTER;
	else if (nScanSize == 1)
		nSize = TWSS_A3;
	else
		nSize = TWSS_NONE;

	int nNum = 0;
	if (nNum == 0)
		nNum = -1;

	CNewMakeModelDlg* pDlg = (CNewMakeModelDlg*)m_pNotifyDlg;

	if (NULL != (pID = pDlg->GetScanSrc(index)))
	{
		SAFE_RELEASE(_pCurrPapersInfo_);
		_pCurrPapersInfo_ = new PAPERSINFO();

		_nScanStatus_ = 1;
		pST_SCANCTRL pScanCtrl = new ST_SCANCTRL();
		pScanCtrl->nScannerId = pID->Id;
		pScanCtrl->nScanCount = nNum;			//nNum
		pScanCtrl->nScanDuplexenable = nDuplex;
		pScanCtrl->nScanPixelType = nScanType;
		pScanCtrl->nScanResolution = nScanDpi;
		pScanCtrl->nScanSize = nSize;
		pScanCtrl->bShowUI = bShowScanSrcUI;	//bShowScanSrcUI;

		pDlg->m_scanThread.ResetGlobalVal();
		pDlg->m_scanThread.setNotifyDlg(pDlg);
		pDlg->m_scanThread.setNotifyDlgType(2);
		pDlg->m_scanThread.setModelInfo(1, strSavePath);
		pDlg->m_scanThread.resetData();
		pDlg->m_scanThread.PostThreadMessage(MSG_START_SCAN, pID->Id, (LPARAM)pScanCtrl);
	}
	else
	{
		CNewMessageBox	dlg;
		dlg.setShowInfo(2, 1, "获取扫描源失败");
		dlg.DoModal();
		return;
	}

	char szRet[20] = { 0 };
	sprintf_s(szRet, "%d", sel);
	WriteRegKey(HKEY_CURRENT_USER, "Software\\EasyTNT\\AppKey", REG_SZ, "scanSrc", szRet);
	memset(szRet, 0, 20);
	sprintf_s(szRet, "%d", nDuplex);
	WriteRegKey(HKEY_CURRENT_USER, "Software\\EasyTNT\\AppKey", REG_SZ, "scanDuplex", szRet);
	memset(szRet, 0, 20);
	sprintf_s(szRet, "%d", nScanSize);
	WriteRegKey(HKEY_CURRENT_USER, "Software\\EasyTNT\\AppKey", REG_SZ, "scanSize", szRet);
	OnOK();
}