Exemple #1
0
QString FileUtils::getFileInfo( const QString& fileName, const QString& whatInfo )
{
#ifdef Q_OS_WIN
	//在QT5中必须使用 std::wstring 做下临时保存 fileName.toStdWString().c_str();这样会直接失败
	std::wstring stdStr = getFullPath(fileName).toStdWString();
	LPCTSTR fName = stdStr.c_str();
	DWORD infoSize = ::GetFileVersionInfoSize(fName, NULL);

	if(infoSize <= 0)  return "";
	QScopedArrayPointer<TCHAR> pBuf(new TCHAR[infoSize]);  

	if(::GetFileVersionInfo(fName, NULL, infoSize, pBuf.data()))     
	{    
		LPCTSTR pInfo(NULL);
		UINT nSize = 0;
		//		QString translation, strTemp;
		//		不知道为什么,获取语言translation,老是不成功,所以直接写080404b0进行构造
		// 		if(!::VerQueryValue(pBuf.data(), LPCTSTR("\\VarFileInfo\\Translation"),
		// 			(LPVOID *)&lpTranslate , &nSize))  return "";
		//		QString subBlock = strTemp.sprintf("\\StringFileInfo\\%04x%04x", lpTranslate[0].wLanguage, lpTranslate[0].wCodePage);
		//080404b0为中文,040904E4为英文
		QString strTmp = "\\StringFileInfo\\080404b0\\" + whatInfo;
		stdStr = strTmp.toStdWString();
		LPCTSTR pBlock = stdStr.c_str();
		if(::VerQueryValue(pBuf.data(), pBlock, (LPVOID *)&pInfo, &nSize))     
		{    
			return QString::fromWCharArray(pInfo);
		}     
	}     
	return  "";

#endif
}
// This is also defined in WinIconProvider, remove from both locations if 64 bit build is produced
QString aliasTo64(QString path) 
{
	QProcessEnvironment env = QProcessEnvironment::systemEnvironment ();
	QString pf32 = env.value("PROGRAMFILES");
	QString pf64 = env.value("PROGRAMW6432");

	// On 64 bit windows, 64 bit shortcuts don't resolve correctly from 32 bit executables, fix it here
	QFileInfo pInfo(path);

	if (env.contains("PROGRAMW6432") && pInfo.isSymLink() && pf32 != pf64) {
		if (QDir::toNativeSeparators(pInfo.symLinkTarget()).contains(pf32)) {
			QString path64 = QDir::toNativeSeparators(pInfo.symLinkTarget());
			path64.replace(pf32, pf64);
			if (QFileInfo(path64).exists()) {
				path = path64;
			}
		}
		else if (pInfo.symLinkTarget().contains("system32")) {
			QString path32 = QDir::toNativeSeparators(pInfo.symLinkTarget());
			if (!QFileInfo(path32).exists()) {
				path = path32.replace("system32", "sysnative");
			}
		}
	}
	return path;
}
ChEXPORT WrdDocumentProperties* WrdDocumentProperties::clone() const
{
    ChAutoPtr<WrdDOPTypography> pTypography((WrdDOPTypography*)m_pTypography->clone());
    ChAutoPtr<WrdDrawingObjectGrid> pGrid((WrdDrawingObjectGrid*)m_pGrid->clone());
    ChAutoPtr<WrdAutoSummaryInfo> pInfo((WrdAutoSummaryInfo*)m_pAutoSummary->clone());
    ChAutoPtr<WrdDateTime> pDate1((WrdDateTime*)m_pDateCreated->clone());
    ChAutoPtr<WrdDateTime> pDate2((WrdDateTime*)m_pDateRevised->clone());
    ChAutoPtr<WrdDateTime> pDate3((WrdDateTime*)m_pDateLastPrinted->clone());
    
    WrdDocumentProperties* pProps = ChNEW WrdDocumentProperties
    	((WrdDOPTypography*)pTypography.get(), (WrdDrawingObjectGrid*)pGrid.get(), 
        (WrdAutoSummaryInfo*)pInfo.get(), (WrdDateTime*)pDate1.get(), (WrdDateTime*)pDate2.get(), 
        (WrdDateTime*)pDate3.get());
    
    pDate3.giveUpOwnership();
    pDate2.giveUpOwnership();
    pDate1.giveUpOwnership();
    pInfo.giveUpOwnership();
    pGrid.giveUpOwnership();
    pTypography.giveUpOwnership();
	
	// Need to place this in an auto-pointer in case operator()= throws an exception
	ChAutoPtr<WrdDocumentProperties> pClone(pProps);
	*pClone = *this;
	return pClone.giveUpOwnership();
}
Exemple #4
0
std::unique_ptr<IFX_SystemFontInfo> IFX_SystemFontInfo::CreateDefault(
    const char** pUnused) {
  CFX_MacFontInfo* pInfo(new CFX_MacFontInfo);
  pInfo->AddPath("~/Library/Fonts");
  pInfo->AddPath("/Library/Fonts");
  pInfo->AddPath("/System/Library/Fonts");
  return std::unique_ptr<CFX_MacFontInfo>(pInfo);
}
Exemple #5
0
DTC::ArtworkInfoList* Content::GetRecordingArtworkList(
    int chanid, const QDateTime &recstarttsRaw)
{
    if (chanid <= 0 || !recstarttsRaw.isValid())
        throw( QString("Channel ID or StartTime appears invalid."));

    ProgramInfo pInfo(chanid, recstarttsRaw.toUTC());

    return GetProgramArtworkList(pInfo.GetInetRef(), pInfo.GetSeason());
}
Exemple #6
0
void IosProbe::addDeveloperPath(const QString &path)
{
    if (path.isEmpty())
        return;
    QFileInfo pInfo(path);
    if (!pInfo.exists() || !pInfo.isDir())
        return;
    if (m_developerPaths.contains(path))
        return;
    m_developerPaths.append(path);
    qCDebug(probeLog) << QString::fromLatin1("Added developer path %1").arg(path);
}
Exemple #7
0
/*
void runProgram(QString path, QString args) {

	SHELLEXECUTEINFO ShExecInfo;
	bool elevated = (GetKeyState(VK_SHIFT) & 0x80000000) != 0 && (GetKeyState(VK_CONTROL) & 0x80000000) != 0;

	ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
	ShExecInfo.fMask = SEE_MASK_FLAG_NO_UI;
	ShExecInfo.hwnd = NULL;
	ShExecInfo.lpVerb = elevated ? L"runas" : NULL;
	ShExecInfo.lpFile = (LPCTSTR)path.utf16();
	if (args != "") {
		ShExecInfo.lpParameters = (LPCTSTR)args.utf16();
	} else {
		ShExecInfo.lpParameters = NULL;
	}
	QDir dir(path);
	QFileInfo info(path);
	if (!info.isDir() && info.isFile())
		dir.cdUp();	
	QString filePath = QDir::toNativeSeparators(dir.absolutePath());
	ShExecInfo.lpDirectory = (LPCTSTR)filePath.utf16();
	ShExecInfo.nShow = SW_NORMAL;
	ShExecInfo.hInstApp = NULL;

	ShellExecuteEx(&ShExecInfo);	
}
*/
void runProgram(QString path, QString args) {

	QProcessEnvironment env = QProcessEnvironment::systemEnvironment ();
	QString pf32 = env.value("PROGRAMFILES");
	QString pf64 = env.value("PROGRAMW6432");

	// On 64 bit windows, 64 bit shortcuts don't resolve correctly from 32 bit executables, fix it here
	QFileInfo pInfo(path);

	if (env.contains("PROGRAMW6432") && pInfo.isSymLink() &&
		pf32 != pf64 && QDir::toNativeSeparators(pInfo.symLinkTarget()).contains(pf32))
	{
		QString path64 = QDir::toNativeSeparators(pInfo.symLinkTarget());
		path64.replace(pf32, pf64);
		if (QFileInfo(path64).exists()) {
			path = path64;
		}
	}

	SHELLEXECUTEINFO ShExecInfo;
	bool elevated = (GetKeyState(VK_SHIFT) & 0x80000000) != 0 && (GetKeyState(VK_CONTROL) & 0x80000000) != 0;

	ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
	ShExecInfo.fMask = SEE_MASK_FLAG_NO_UI;
	ShExecInfo.hwnd = NULL;
	ShExecInfo.lpVerb = elevated ? L"runas" : NULL;
	ShExecInfo.lpFile = (LPCTSTR)path.utf16();
	if (args != "") {
		ShExecInfo.lpParameters = (LPCTSTR)args.utf16();
	} else {
		ShExecInfo.lpParameters = NULL;
	}


	QDir dir(path);
	QFileInfo info(path);
	if (!info.isDir() && info.isFile())
		dir.cdUp();
	QString filePath = QDir::toNativeSeparators(dir.absolutePath());
	ShExecInfo.lpDirectory = (LPCTSTR)filePath.utf16();
	ShExecInfo.nShow = SW_NORMAL;
	ShExecInfo.hInstApp = NULL;

	ShellExecuteEx(&ShExecInfo);	
}
void CMultiEditDispatcher::registerBeginEdit(const QString& objectUuid
		,const IOSender::Handle& userUuid, const PRL_UINT64& llObjectShotId)
{
	LOG_MESSAGE (DBG_DEBUG, "objectId=[%s], userId=[%s]", objectUuid.toUtf8().data(), userUuid.toUtf8().data());

	QMutexLocker lock( this );
	QHash<QString, EditCommitInfoPtr >::iterator
		itByObject=m_hashCommitsByObject.find(objectUuid);
	if (m_hashCommitsByObject.end()==itByObject)
	{
		SmartPtr<EditCommitInfo> pInfo( new EditCommitInfo() );
		itByObject=m_hashCommitsByObject.insert(objectUuid, pInfo);
	}

	QHash<IOSender::Handle, BeginEditInfo>::iterator
		itBeginEditByUser= itByObject.value()->m_hashBeginEditByUser.find(userUuid);
	if( itByObject.value()->m_hashBeginEditByUser.end() != itBeginEditByUser )
		removeObjectShot( itBeginEditByUser.value().llObjectShotId );
	itByObject.value()->m_hashBeginEditByUser[userUuid] = BeginEditInfo( PrlGetTickCount64(), llObjectShotId );
}
Exemple #9
0
void CSyncThread::slotProgress(Progress::Kind kind, const SyncFileItem& item, quint64 curr, quint64 total)
{
    if( Progress::isErrorKind(kind) ) {
        progressProblem(kind, item);
        return;
    }

    if( kind == Progress::StartSync ) {
        _currentFileNo = 0;
        _lastOverallBytes = 0;
    }
    if( kind == Progress::StartDelete ||
            kind == Progress::StartDownload ||
            kind == Progress::StartRename ||
            kind == Progress::StartUpload ) {
        int indx = _syncedItems.indexOf(item);
        if( _previousIndex != indx ) {
            _currentFileNo += 1;
            _previousIndex = indx;
        }
        curr = 0;
    }

    if( kind == Progress::EndUpload ||
            kind == Progress::EndDownload) {
        _lastOverallBytes += total;
    }

    Progress::Info pInfo(_progressInfo);
    pInfo.kind                  = kind;
    pInfo.current_file          = item._file;
    pInfo.rename_target         = item._renameTarget;
    pInfo.file_size             = total;
    pInfo.current_file_bytes    = curr;
    pInfo.current_file_no       = _currentFileNo;
    pInfo.timestamp             = QDateTime::currentDateTime();
    pInfo.overall_current_bytes = _lastOverallBytes + curr;
    // Connect to something in folder!
    emit transmissionProgress( pInfo );
}
Exemple #10
0
void
ScriptUpdater::updateScript()
{
    DEBUG_BLOCK

    // 1a. detect currently installed version
    QFileInfo info( m_scriptPath );
    const QString specPath = info.path() + '/' + "script.spec";
    if( !QFile::exists( specPath ) )
    {
        // no .spec file found, can't continue
        emit finished( m_scriptPath );
        return;
    }
    KPluginInfo pInfo( specPath );
    if ( !pInfo.isValid() || pInfo.name().isEmpty() || pInfo.version().isEmpty() )
    {
        // invalid or unusable .spec file, can't continue
        emit finished( m_scriptPath );
        return;
    }
    m_scriptversion = pInfo.version();

    // 1b. detect script name
    QFile file( m_scriptPath );
    m_fileName = file.fileName();
    QRegExp rxname( "amarok/scripts/(.+)/main.js" );
    rxname.indexIn( m_fileName );
    m_scriptname = rxname.cap( 1 );

    // 2. check if there are updates: get 'version' file from server
    KUrl versionUrl( updateBaseUrl );
    versionUrl.addPath( m_scriptname );
    versionUrl.addPath( '/' + versionFilename );
    m_versionFile.open();
    debug() << m_scriptname << ": Accessing " << versionUrl.prettyUrl() << " ...";
    KUrl versionDest( m_versionFile.fileName() );
    KIO::FileCopyJob *versionJob = KIO::file_copy( versionUrl, versionDest, -1, KIO::Overwrite | KIO::HideProgressInfo );
    connect ( versionJob, SIGNAL(result(KJob*)), this, SLOT(phase2(KJob*)) );
}
Exemple #11
0
bool StelFileMgr::fileFlagsCheck(const QFileInfo& thePath, const Flags& flags)
{
	const bool exists = thePath.exists();
	
	if (flags & New)
	{
		// if the file already exists, it is not a new file
		if (exists)
			return false;

		// To be able to create a new file, we need to have a
		// parent directory which is writable.
		QFileInfo pInfo(thePath.dir().absolutePath());
		if (!pInfo.exists() || !pInfo.isWritable())
		{
			return false;
		}
	}
	else if (exists)
	{
		if (flags==0)
			return true;
		
		if ((flags & Writable) && !thePath.isWritable())
			return false;

		if ((flags & Directory) && !thePath.isDir())
			return false;

		if ((flags & File) && !thePath.isFile())
			return false;
	}
	else
	{
		// doesn't exist and New flag wasn't requested
		return false ;
	}

	return true;
}
Exemple #12
0
int cellPamfReaderGetStreamInfo(mem_ptr_t<CellPamfReader> pSelf, u32 pInfo_addr, u32 size)
{
	cellPamf.Warning("cellPamfReaderGetStreamInfo(pSelf=0x%x (stream=%d), pInfo_addr=0x%x, size=%d)",
		pSelf.GetAddr(), pSelf->stream, pInfo_addr, size);

	if (!pSelf.IsGood() || !Memory.IsGoodAddr(pSelf->pAddr))
		return CELL_PAMF_ERROR_INVALID_ARG;

	const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr);

	memset(Memory + pInfo_addr, 0, size);

	switch (pamfGetStreamType(pSelf, pSelf->stream))
	{
	case CELL_PAMF_STREAM_TYPE_AVC:
		{
			mem_ptr_t<CellPamfAvcInfo> pInfo(pInfo_addr);
			mem_ptr_t<PamfStreamHeader_AVC> pAVC(pSelf->pAddr + 0x98 + pSelf->stream * 0x30);

			if (size != sizeof(CellPamfAvcInfo))
			{
				cellPamf.Error("cellPamfReaderGetStreamInfo: wrong AVC data size(%d)", size);
				return CELL_PAMF_ERROR_INVALID_ARG;
			}

			pInfo->profileIdc = pAVC->profileIdc;
			pInfo->levelIdc = pAVC->levelIdc;

			pInfo->frameMbsOnlyFlag = 1; //fake
			pInfo->frameRateInfo = (pAVC->unk0 & 0x7) - 1;
			pInfo->aspectRatioIdc = 1; //fake

			pInfo->horizontalSize = 16 * (u16)pAVC->horizontalSize;
			pInfo->verticalSize = 16 * (u16)pAVC->verticalSize;

			pInfo->videoSignalInfoFlag = 1; //fake
			pInfo->colourPrimaries = 1; //fake
			pInfo->transferCharacteristics = 1; //fake
			pInfo->matrixCoefficients = 1; //fake
			//pInfo->deblockingFilterFlag = 1; //???

			cellPamf.Warning("cellPamfReaderGetStreamInfo: CELL_PAMF_STREAM_TYPE_AVC");
		}
		break;
	case CELL_PAMF_STREAM_TYPE_M2V:
		{
			//TODO
			cellPamf.Error("TODO: cellPamfReaderGetStreamInfo: CELL_PAMF_STREAM_TYPE_M2V");
		}
		break;
	case CELL_PAMF_STREAM_TYPE_ATRAC3PLUS: 
		{
			mem_ptr_t<CellPamfAtrac3plusInfo> pInfo(pInfo_addr);
			mem_ptr_t<PamfStreamHeader_Audio> pAudio(pSelf->pAddr + 0x98 + pSelf->stream * 0x30);

			if (size != sizeof(CellPamfAtrac3plusInfo))
			{
				cellPamf.Error("cellPamfReaderGetStreamInfo: wrong ATRAC3+ data size(%d)", size);
				return CELL_PAMF_ERROR_INVALID_ARG;
			}

			pInfo->numberOfChannels = pAudio->channels;
			pInfo->samplingFrequency = CELL_PAMF_FS_48kHz;
		}
		break;
	case CELL_PAMF_STREAM_TYPE_AC3:
		{
			mem_ptr_t<CellPamfAc3Info> pInfo(pInfo_addr);
			mem_ptr_t<PamfStreamHeader_Audio> pAudio(pSelf->pAddr + 0x98 + pSelf->stream * 0x30);

			if (size != sizeof(CellPamfAc3Info))
			{
				cellPamf.Error("cellPamfReaderGetStreamInfo: wrong AC3 data size(%d)", size);
				return CELL_PAMF_ERROR_INVALID_ARG;
			}

			pInfo->numberOfChannels = pAudio->channels;
			pInfo->samplingFrequency = CELL_PAMF_FS_48kHz;
		}
		break;
	case CELL_PAMF_STREAM_TYPE_PAMF_LPCM:
		{
			mem_ptr_t<CellPamfLpcmInfo> pInfo(pInfo_addr);
			mem_ptr_t<PamfStreamHeader_Audio> pAudio(pSelf->pAddr + 0x98 + pSelf->stream * 0x30);

			if (size != sizeof(CellPamfLpcmInfo))
			{
				cellPamf.Error("cellPamfReaderGetStreamInfo: wrong LPCM data size(%d)", size);
				return CELL_PAMF_ERROR_INVALID_ARG;
			}

			pInfo->numberOfChannels = pAudio->channels;
			pInfo->samplingFrequency = CELL_PAMF_FS_48kHz;

			if (pAudio->bps == 0x40)
				pInfo->bitsPerSample = CELL_PAMF_BIT_LENGTH_16;
			else
				//TODO: CELL_PAMF_BIT_LENGTH_24
				cellPamf.Error("cellPamfReaderGetStreamInfo: unknown bps(0x%x)", (u8)pAudio->bps);
		}
		break;
	case CELL_PAMF_STREAM_TYPE_USER_DATA: 
		{
			cellPamf.Error("cellPamfReaderGetStreamInfo: CELL_PAMF_STREAM_TYPE_USER_DATA");
			return CELL_PAMF_ERROR_INVALID_ARG;
		}
	}
	
	return CELL_OK;
}
int		Panel::ProcessKey(int Key, unsigned int ControlState) {
	switch (Key) {
		case VK_F3:
			if (ControlState == PKF_SHIFT) {
				return	true;
			}
			break;
		case VK_F4:
			switch (ControlState) {
				case 0:
					DlgShutdown();
					return true;
				case PKF_SHIFT:
					return	true;
			}
			break;
		case VK_F6:
			switch (ControlState) {
				case 0:
					if (DlgConnection()) {
						psi.Control(this, FCTL_UPDATEPANEL, 0, nullptr);
						psi.Control(this, FCTL_REDRAWPANEL, 0, nullptr);
					}
					return	true;
				case PKF_SHIFT:
					try {
						m_conn->Open(nullptr);
					} catch (WinError &e) {
						farebox_code(e.code(), e.where().c_str());
					}
					psi.Control(this, FCTL_UPDATEPANEL, 0, nullptr);
					psi.Control(this, FCTL_REDRAWPANEL, 0, nullptr);
					return	true;
			}
			break;
		case VK_F7:
			switch (ControlState) {
				case 0:
					AutoUTF cmd = L"mstsc.exe";
					if (!Empty(m_conn->host())) {
						cmd += L" /v:";
						cmd += m_conn->host();
					}
					ExecCMD(cmd);
					return true;
			}
			break;
	}
	if ((ControlState == 0 && (Key == VK_F3 || Key == VK_F5 || Key == VK_F8)) ||
		(ControlState == PKF_SHIFT && (Key == VK_F7 || Key == VK_F8))) {
		FarPnl pInfo(this, FCTL_GETPANELINFO);
		WinTS::iterator m_cur;
		if (pInfo.ItemsNumber() && pInfo.CurrentItem() &&
			(m_cur = std::find(m_ts.begin(), m_ts.end(), pInfo[pInfo.CurrentItem()].FindData.nFileSize)) != m_ts.end()) {
			if (ControlState == 0 && Key == VK_F3) {
				AutoUTF	tmp(TempFile(TempDir()));
				HANDLE	hfile = ::CreateFileW(tmp.c_str(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
				if (hfile != INVALID_HANDLE_VALUE) {
					FileWrite(hfile, Info(m_cur));
					::CloseHandle(hfile);
					psi.Viewer(tmp.c_str(), nullptr, 0, 0, -1, -1,
							   VF_DELETEONLYFILEONCLOSE | VF_ENABLE_F6 | VF_DISABLEHISTORY |
							   VF_NONMODAL | VF_IMMEDIATERETURN, CP_AUTODETECT);
				}
				return	true;
			} else if (ControlState == 0 && Key == VK_F5) {
				DlgMessage(m_cur->id());
			} else 	if (ControlState == PKF_SHIFT && Key == VK_F7) {
				WinTSession::ConnectLocal(m_cur->id());
			} else 	if (ControlState == 0 && Key == VK_F8) {
				if (farquestion(GetMsg(txtAreYouSure), GetMsg(txtDisconnectSession)))
					WinTSession::Disconnect(m_cur->id(), m_conn->host());
			} else if (ControlState == PKF_SHIFT && Key == VK_F8) {
				if (farquestion(GetMsg(txtAreYouSure), GetMsg(txtLogoffSession)))
					WinTSession::LogOff(m_cur->id(), m_conn->host());
			}
			psi.Control(this, FCTL_UPDATEPANEL, 0, nullptr);
			psi.Control(this, FCTL_REDRAWPANEL, 0, nullptr);
			return	true;
		}
	}
	return	false;
}