Пример #1
0
size_t AXmlElement::find(const AString& path, AXmlElement::CONST_CONTAINER& result) const
{
  AString strAttribute;
  AString strPath(path);
  bool leadingSlash = false;

  if ('/' == strPath.at(0))
  {
    leadingSlash = true;  //a_Signals that slash leads the path so much include current name
  }

  //a_Remove the leading name (which should be this element's name)
  LIST_AString listPath;
  strPath.split(listPath, '/');
  if (leadingSlash)
  {
    if (0 == listPath.size())
    {
      //a_ "/" selects current node
      result.push_back(this);
      return 1;
    }
    else if (0 != listPath.front().compare(m_Name))
    {
      //a_First token MUST be the name of this element if / leads
      AString str("Absolute path must start with the name of the current root element: root=/");
      str.append(m_Name);
      str.append(" while path=");
      str.append(path);
      ATHROW_EX(this, AException::ProgrammingError, str);
    }
  }
  else if (0 == listPath.size())
  {
    //a_ "/" selects current node
    result.push_back(this);
    return 1;
  }
  else
  {
    //a_Relative path implies this node is first
    listPath.push_front(m_Name);
  }

  return _const_find(listPath, result);
}
Пример #2
0
BOOL KFunction::DeleteFolder(LPCTSTR szPath)
{
	BOOL bReturn = FALSE;
	BOOL bRetCode = FALSE;
	CString strPath(szPath);

	KFunction::PathAddBackslash(strPath);

	bRetCode = _DeleteFolder(strPath);
	if (!bRetCode) goto Exit0;

	bReturn = TRUE;

Exit0:
	log_w(L"KFunction::DeleteFolder return:%d, path:%s\n", bReturn, strPath);

	return bReturn;
}
Пример #3
0
/*
 * Get directory part of a filename.
 */
CTFileName CTFileName::FileDir() const
{
    ASSERT(IsValid());

    // make a temporary copy of string
    CTFileName strPath(*this);
    // find last backlash in it
    char *pPathBackSlash = strrchr( strPath.str_String, '\\');
    // if there is no backslash
    if( pPathBackSlash == NULL) {
        // return emptystring as directory
        return( CTFileName(""));
    }
    // set end of string after where the backslash was
    pPathBackSlash[1] = 0;
    // return a copy of temporary string
    return( CTFileName( strPath));
}
Пример #4
0
void operator()( const char* name ) const {
	if ( !extension_equal( path_get_extension( name ), "game" ) ) {
		return;
	}
	StringOutputStream strPath( 256 );
	strPath << mPath << name;
	globalOutputStream() << strPath.c_str() << '\n';

	xmlDocPtr pDoc = xmlParseFile( strPath.c_str() );
	if ( pDoc ) {
		mGames.push_front( new CGameDescription( pDoc, name ) );
		xmlFreeDoc( pDoc );
	}
	else
	{
		globalErrorStream() << "XML parser failed on '" << strPath.c_str() << "'\n";
	}
}
Пример #5
0
int	CDevCmn::fnLDCtrl_Initialize()
{
	int		nReturn = FALSE;
	int		nRegFlag = FALSE;

	CString strPath("");
	CString strYYMMDD("");
	char szTemp[1024];

MsgDump(TRACE_CODE_MODE, "Log", __FILE__, __LINE__, "fnLDCtrl_Initialize()");

	if (fnAPL_GetDefineDevice(DEV_RDCTRL))
	{
		nReturn = fnDll_ConnectRpcLock();

		if(nReturn == TRUE)
		{
			Delay_Msg(100);
			if(fnLDCtrl_GetDeviceStatus() != NORMAL)
				nReturn = FALSE;	
			else
			{
				Delay_Msg(200);
				fnLDCtrl_SetTimeWatchdogRpc(0);	// Regstry Setting
				Delay_Msg(200);
				fnLDCtrl_Ch1TimeResetRpc(0);	// Regstry Setting
				Delay_Msg(200);
				fnLDCtrl_Ch2TimeResetRpc(0);	// Regstry Setting
				Delay_Msg(200);
				fnLDCtrl_EnableWatchdogRpc(0);	

				if(!m_pDevCmn->fnLDCtrl_GetKeyCount())
				{
					fnLDCtrl_SetKeytableFile(0, "51515150");
					fnLDCtrl_GetErrorCode(szTemp);
			MsgDump(TRACE_CODE_MODE, "Log", __FILE__, __LINE__, "fnLDCtrl_Initialize():[%s]", szTemp);
				}
			}
		}
	}
	
MsgDump(TRACE_CODE_MODE, "Log", __FILE__, __LINE__, "fnLDCtrl_Initialize():return(%d)", nReturn);
	return nReturn;
}
Пример #6
0
void GetData(QList<ItemObject* > &data)
{
    QString strPath(":/MyImages/folder.png");
    for(int i=0;i<5;i++)
    {
        ItemObject* item=new ItemObject();
        item->setName("name"+QString::number(i));
        item->setDesc("desc"+QString::number(i));
        item->setMyIcon(strPath);
        for(int j=0;j<i+1;j++)
        {
            ItemObject* child=new ItemObject(item);
            child->setName("child "+QString::number(j));
            child->setMyIcon(strPath);
            item->appendChild(child);
        }
        data.append(item);
    }
}
Пример #7
0
bool testPathAppend(TCHAR *path, TCHAR *append)
{
	TCHAR cPath[MAX_PATH];

	generic_string strPath(path);
	generic_string strAppend(append);

	_tcscpy_s(cPath, MAX_PATH, path);

	BOOL strRet = PathAppend(strPath, strAppend);
	BOOL charRet = PathAppend(cPath, append);

	if (strRet != charRet || strPath != cPath)
	{
		_tprintf(_T("Testing |%s| append |%s|     String (ours) |%s| returned %d   Char (system) |%s| returned %d\r\n"), path, append, strPath.c_str(), strRet, cPath, charRet);
	}
	return ((strRet == charRet) &&
			(strPath == cPath));
}
Пример #8
0
	bool VDirAdapter::isDots() const
	{
		if (m_hFindFile == INVALID_HANDLE_VALUE)
			return false;

		if (!m_bExtractName)
		{
#ifdef UNICODE
			char szPath[512] = {0};
			::WideCharToMultiByte(CP_UTF8, 0, m_FindFileData.cFileName, MAX_PATH, szPath, sizeof(szPath), nullptr, nullptr);
			VString strPath(szPath);
#else
			VString strPath = m_FindFileData.cFileName;
#endif
			extractFileName(strPath, m_strName, m_strTitle);
		}

		return ((m_FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (m_strName == "." || m_strName == ".."));
	}
Пример #9
0
CPathID::CPathID(const char* path, bool doNotFromat)
{
    BEHAVIAC_ASSERT(path);

    if (doNotFromat)
    {
        behaviac::string strPath(path);
        strPath = make_lower(strPath);
        SetContentPrivate(strPath.c_str());
#ifdef BEHAVIAC_ENABLE_ASSERTS
        CPathID pathId(path);
        BEHAVIAC_ASSERT(GetUniqueID() == pathId.GetUniqueID());
#endif // #ifdef BEHAVIAC_ENABLE_ASSERTS
    }
    else
    {
        SetContent(path);
    }
}
Пример #10
0
BOOL CRunMacroDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// Clear any existing data
	m_CMacroList.ResetContent();

	// Find all files in the current directory with the
	// macro file extension, ".mac".
	TCHAR szCurrentDir[_MAX_PATH+1];
	GetCurrentDirectory(_MAX_PATH,szCurrentDir);
	CString strPath(szCurrentDir);
	if ( strPath[strPath.GetLength()-1] != '\\' ) {
		// The directory doesn't end with a backslash,
		// so we add one now.
		strPath += '\\';
	} // if
	CString strFile = strPath + "*.mac";
	WIN32_FIND_DATA wfd;
	HANDLE hSearchHandle = FindFirstFile(strFile,&wfd);
	if ( hSearchHandle != INVALID_HANDLE_VALUE ) {
		// Pull first filename
		CString strFileTitle(wfd.cFileName);
		strFileTitle = strFileTitle.Left(strFileTitle.Find("."));
		int iItem = m_CMacroList.AddString(strFileTitle);

		while ( FindNextFile(hSearchHandle,&wfd) ) {
			// While we have more files...
			strFileTitle = wfd.cFileName;
			strFileTitle = strFileTitle.Left(strFileTitle.Find("."));
			m_CMacroList.AddString(strFileTitle);
		} // while

		// Close our search handle
		FindClose(hSearchHandle);
	} // if
	
	// Make sure no macro files are selected...
	m_CMacroList.SetCurSel(-1);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Пример #11
0
std::string GetParentDir(const char *szPath)
{
	std::string strPath(szPath);
    EnsureNotTerminated(strPath);

    size_t nPos = strPath.find_last_of(PATH_DELIMITERS);
    if(nPos > 0)
        strPath = strPath.substr(0, nPos);
    else
        strPath = "";

#ifdef _WIN32
    EnsureTerminated(strPath, '\\');
#else
	EnsureTerminated(strPath, '/');
#endif

    return strPath;
}
Пример #12
0
HTREEITEM CTreePropSheet::CreatePageTreeItem(LPCTSTR lpszPath, HTREEITEM hParent /* = TVI_ROOT */)
{
	CString		strPath(lpszPath);
	CString		strTopMostItem(SplitPageTreePath(strPath));
	
	// Check if an item with the given text does already exist
	HTREEITEM	hItem = NULL;
	HTREEITEM	hChild = m_pwndPageTree->GetChildItem(hParent);
	while (hChild)
	{
		if (m_pwndPageTree->GetItemText(hChild) == strTopMostItem)
		{
			hItem = hChild;
			break;
		}
		hChild = m_pwndPageTree->GetNextItem(hChild, TVGN_NEXT);
	}

	// If item with that text does not already exist, create a new one
	// MORPH START tabbed options [leuk_he]
	if (strTopMostItem != "Multi user" && strTopMostItem != "NT Service"  )   { // MORPH leuk_he:run as ntservice v1..
	// MORPH END tabbed options [leuk_he]
	if (!hItem)
	{
		hItem = m_pwndPageTree->InsertItem(strTopMostItem, hParent);
		m_pwndPageTree->SetItemData(hItem, (DWORD_PTR)-1);
		if (!strPath.IsEmpty() && m_bTreeImages && m_DefaultImages.GetSafeHandle())
			// set folder image
			m_pwndPageTree->SetItemImage(hItem, m_Images.GetImageCount()-2, m_Images.GetImageCount()-2);
	}
	if (!hItem)
	{
		// ASSERT(FALSE); //MORPH tabbed  options
		return NULL;
	}
	} // Morph tabbed options. 

	if (strPath.IsEmpty())
		return hItem;
	else
		return CreatePageTreeItem(strPath, hItem);
}
Пример #13
0
int WINAPI GetCustomDataW(const wchar_t *FilePath, wchar_t **CustomData)
{
	*CustomData = NULL;
	
	const wchar_t* pszSlash = wcsrchr(FilePath, L'\\');
	if (!pszSlash || pszSlash <= FilePath) return FALSE;
	if (pszSlash[1] == 0) return FALSE; // Если хотят диз именно для папки - то нужно без слеша
	string  strPath(FilePath, pszSlash-FilePath);
	
	// оптимизацией чтения диз-файла занимается сам diz
	if (diz.Read(strPath) == 0)
	{
		// Если диз пустой - сразу выходим
		return FALSE;
	}

	
	const wchar_t* pszDiz = diz.GetDizTextAddr(pszSlash+1, L"", 0/*???*/);
	//if (!pszDiz || pszDiz[0] == 0) -- ConvertNameToShort занимает очень много времени
	//{
	//	string strShort;
	//	ConvertNameToShort(FilePath, strShort);
	//	pszDiz = diz.GetDizTextAddr(pszSlash+1, strShort, 0/*???*/);
	//}
	if (!pszDiz || pszDiz[0] == 0)
	{
		return FALSE;
	}
	
	size_t nLen = wcslen(pszDiz)+1;
	*CustomData = (wchar_t*)malloc(nLen*2);
	wcscpy(*CustomData, pszDiz);
	// Заменить некоторые символы
	wchar_t* pszTab = wcspbrk(*CustomData, L"\t");
	while (pszTab)
	{
		*pszTab = L' ';
		pszTab = wcspbrk(pszTab+1, L"\t");
	}

	return TRUE;
}
Пример #14
0
// This function reads the file at the given filepath, and returns the sparse
// matrix in the COO struct.
template< typename T > int
cooMatrixfromFile( std::vector< int >& row_indices, std::vector< int >& col_indices,
    std::vector< T >& values, const char* filePath )
{
    // Check that the file format is matrix market; the only format we can read right now
    // This is not a complete solution, and fails for directories with file names etc...
    // TODO: Should we use boost filesystem?
    std::string strPath( filePath );
    if( strPath.find_last_of( '.' ) != std::string::npos )
    {
        std::string ext = strPath.substr( strPath.find_last_of( '.' ) + 1 );
        if( ext != "mtx" )
            return 1;
    }
    else
        return 1;

    MatrixMarketReader< T > mm_reader;
    if( mm_reader.MMReadFormat( filePath ) )
        return 2;

    int m = mm_reader.GetNumRows( );
    int n = mm_reader.GetNumCols( );
    int nnz = mm_reader.GetNumNonZeroes( );

    row_indices.clear( );
    col_indices.clear( );
    values.clear( );
    row_indices.reserve( m );
    col_indices.reserve( n );
    values.reserve( nnz );

    Coordinate< T >* coords = mm_reader.GetUnsymCoordinates( );
    for( int c = 0; c < nnz; ++c )
    {
        row_indices.push_back( coords[ c ].x );
        col_indices.push_back( coords[ c ].y );
        values.push_back( coords[ c ].val );
    }

    return 0;
}
Пример #15
0
	std::string FileNameFromPath(const char* lpszPath)
	{
		if (NULL == lpszPath || NULL == *lpszPath)
			return ("");

		std::string strPath(lpszPath);

		std::string::iterator iter;
		for (iter = strPath.begin(); iter < strPath.end(); iter++)
		{
			if (('\\') == *iter)
				*iter = ('/');
		}

		std::string::size_type nPos = strPath.rfind(('/'));
		if (nPos != std::string::npos)
			strPath = strPath.substr(nPos + 1);

		return strPath;
	}
Пример #16
0
	VString VDirAdapter::getFilePath() const
	{
		if (m_hFindFile == INVALID_HANDLE_VALUE)
			return "";

#ifdef UNICODE
		char szPath[512] = {0};
		::WideCharToMultiByte(CP_UTF8, 0, m_FindFileData.cFileName, MAX_PATH, szPath, sizeof(szPath), nullptr, nullptr);
		VString strPath(szPath);
#else
		VString strPath = m_FindFileData.cFileName;
#endif

		if (!m_bExtractName)
		{
			extractFileName(strPath, m_strName, m_strTitle);
		}

		return m_strRoot + strPath;
	}
Пример #17
0
// 返回指定路径字符串的文件名和扩展名
tstring CPath::GetFileName(LPCTSTR lpszPath)
{
	if (NULL == lpszPath || NULL == *lpszPath)
		return _T("");

	tstring strPath(lpszPath);

	tstring::iterator iter;
	for (iter = strPath.begin(); iter < strPath.end(); iter++)
	{
		if (_T('\\') == *iter)
			*iter = _T('/');
	}

	tstring::size_type nPos = strPath.rfind(_T('/'));
	if (nPos != tstring::npos)
		strPath = strPath.substr(nPos+1);

	return strPath;
}
Пример #18
0
bool CModelToolCharDataTable::Create(const char * lpszPath)
{
	std::string strPath( lpszPath );
	std::string strFileName;

	//3가지 Xml을 모두 읽도록 변경을 한다.
	if(LoadPropertyList(lpszPath, "CharacterPropertyList.xml") == false)
		return false;

	if(LoadPropertyList(lpszPath, "MobPropertyList.xml") == false)
		return false;

	if(LoadPropertyList(lpszPath, "NPCPropertyList.xml") == false)
		return false;

	if(LoadPropertyList(lpszPath, "VehiclePropertyList.xml") == false)
		return false;

	return true;
}
Пример #19
0
void CNodeManageDir::OutputHtml()
{
	// 构造输出目录
	string strPath(OUTPUT_PATH);
	int x = strlen(CODE_PATH);
    if (m_strPath.length() == x) {
        strPath += INDEX_NAME;
    }
    else
    {
        strPath += INDEX_NAME;
        strPath += "/";
        strPath += m_strPath.substr(x, m_strPath.length()-x-1);// 默认路径中减去磁盘源文件路径
    }
    strPath += ".html";

	string strRelativePath = (m_strPath.c_str()+x);
	// 创建html文件
	m_node.OutputHtml(strPath, strRelativePath);
}
// detect the version of CLR
BOOL DetermineDotNetVersion(void)
{
	WCHAR wszPath[MAX_PATH] = {0};
	::GetModuleFileNameW( g_hClrModule, wszPath, MAX_PATH);
	CStringW strPath(wszPath);
	int nIndex = strPath.ReverseFind('\\');
	if( nIndex <= 0 )
		return FALSE;
	nIndex++;
	CStringW strFilename = strPath.Mid( nIndex, strPath.GetLength() - nIndex);
	if( strFilename.CompareNoCase(L"mscorwks.dll") == 0 )
	{
		g_tDotNetVersion = DotNetVersion_20;
		return TRUE;
	}

	if( strFilename.CompareNoCase(L"clr.dll") == 0 )
	{
		VS_FIXEDFILEINFO tVerInfo = {0};
		if ( CUtility::GetFileVersion( wszPath, &tVerInfo) &&
			 tVerInfo.dwSignature == 0xfeef04bd)
		{
			int nMajor = HIWORD(tVerInfo.dwFileVersionMS);
			int nMinor = LOWORD(tVerInfo.dwFileVersionMS);
			int nBuildMajor = HIWORD(tVerInfo.dwFileVersionLS);
			int nBuildMinor = LOWORD(tVerInfo.dwFileVersionLS);

			if( nMajor == 4 && nMinor == 0 && nBuildMajor == 30319 )
			{
				if( nBuildMinor < 10000 )
					g_tDotNetVersion = DotNetVersion_40;
				else
					g_tDotNetVersion = DotNetVersion_45;
				return TRUE;
			}
		}
		return FALSE;
	}

	return FALSE;
}
Пример #21
0
void CThumbCache::Delete(LPCTSTR pszPath)
{
	auto_ptr< CDatabase > db( theApp.GetDatabase( DB_THUMBS ) );
	if ( ! *db )
	{
		TRACE( "CThumbCache::InitDatabase : Database error: %s\n", (LPCSTR)CT2A( db->GetLastErrorMessage() ) );
		return;
	}

	CString strPath( pszPath );
	strPath.MakeLower();

	if ( ! db->Prepare( _T("DELETE FROM Files WHERE Filename == ?;") ) ||
		 ! db->Bind( 1, strPath ) )
	{
		TRACE( "CThumbCache::Load : Database error: %s\n", (LPCSTR)CT2A( db->GetLastErrorMessage() ) );
		return;
	}

	db->Step();
}
Пример #22
0
CString CBitziDownloader::LookupValue(LPCTSTR pszPath)
{
	CString strName, strPath( pszPath );
	CXMLElement* pXML = m_pXML;
	BOOL bFirst = TRUE;

	while ( strPath.GetLength() )
	{
		strName = strPath.SpanExcluding( _T("/") );
		strPath = strPath.Mid( strName.GetLength() );

		if ( strPath.IsEmpty() )
		{
			return pXML->GetAttributeValue( strName, NULL );
		}

		if ( bFirst )
		{
			bFirst = FALSE;
			if ( strName.CompareNoCase( pXML->GetName() ) ) pXML = NULL;
		}
		else
		{
			pXML = pXML->GetElementByName( strName );
		}

		if ( ! pXML )
		{
			strName.Empty();
			return strName;
		}

		strPath = strPath.Mid( 1 );
	}

	strName.Empty();
	if ( pXML ) strName = pXML->GetValue();

	return strName;
}
Пример #23
0
BOOL CMongoDB::GetFileFromMongoDB(const string& strFileName, const string&strSavePath, string& strErr)
{
	BOOL bRet = TRUE;
	string strTemp, strTempPath;
	int nStart(0);
	if (strFileName.length() <= 0)
		strErr = "FileName is empty!";
	gridfs_offset size(0), afsize(0);
	string strPath(strSavePath);

	if (connect.isStillConnected() && m_bConnect)
	{
		GridFS fs(connect, m_strDBName);
		auto pos = strFileName.find(";", nStart);
		while ((pos > 0) && (pos != strFileName.npos))
		{
			strTemp = strFileName.substr(nStart, pos - nStart);
			nStart = pos + 1;
			if (strTemp.length() > 0)
			{
				GridFile file = fs.findFileByName(strTemp);
				if (file.exists())
				{
					strPath = strSavePath;
					strPath.append("\\");
					strPath.append(strTemp);
					size = file.getContentLength();
					afsize = file.write(strPath);
				}
				else strErr = "File not exists!";
			}
			if (size > 0 && size == afsize)
				bRet = bRet ? TRUE : FALSE;
			else bRet = FALSE;
			pos = strFileName.find(";", nStart);
		}
	}
	return bRet;
}
Пример #24
0
/*
 * Class:     unquantum_search_SearchModule
 * Method:    InitModule
 * Signature: (Ljava/lang/String;)Z
 */
JNIEXPORT jboolean JNICALL Java_kr_co_uniquantum_search_SearchModule_InitModule
  (JNIEnv * env, jobject obj, jstring jstrPath )
{
	if( g_pSearchModule != NULL ) 
	{
		g_pSearchModule->Release();
		delete g_pSearchModule;
	}
	g_pSearchModule = new CUmSearchModule();
	
	if( g_pAdminBound != NULL )
	{
		g_pAdminBound->Release();
		delete g_pAdminBound;
	}
	g_pAdminBound = new CAdminBoundManager();

	CString strPath( env, &jstrPath );

	g_pAdminBound->Create( strPath.toString());
	return (jboolean)g_pSearchModule->Load( strPath.toString());
}  
int main(int argc, const char* argv[])
{
  std::string exeName("TEBNFCodeGenerator");
  if(argc < 4)
  {
    if(1 == argc)
    {
      std::string strPath(argv[0]);
      auto pos = strPath.find_last_of("/\\");
      exeName = std::string::npos != pos ? strPath.substr(pos + 1) : strPath;
    }
    std::cout << "Usage: " << exeName << " <source> <destination> <name>\n"
      << "Arguments:\n"
      << "  source - Path of file containing TEBNF grammar, including file name.\n"
      << "  destination - Path of the location on disk to write generated files.\n"
      << "  name - Name to give to the generated application.\n";
  }
  else
  {
    try
    {
      std::string srcFilePath(argv[1]);
      std::string destDirPath(argv[2]);
      std::string appName(argv[3]);
      Utils::Logger::setup(srcFilePath); //Setup static logger.
      Utils::Logger::log("\n--------- TEBNF Code Generator v" + Utils::getTEBNFVersion() + " ---------\n");
      Reader::read(srcFilePath);
      Scanner::scan(Reader::getFileText());
      Parser::parse();
      Generator::generate(destDirPath, appName);
      return EXIT_SUCCESS;
    }
    catch(std::exception& ex)
    {
      std::cout << std::string(ex.what()) << std::endl;
    }
  }
  return EXIT_FAILURE;
}
Пример #26
0
TEST_F(EngineTestParser,  obfuscate_haveFilesForObfuscation)
{
	//create work dir
	CString strCommand; 
	CString strTestDir(m_strRootPath.c_str());
	strTestDir += _T("TestDir\\");
	strCommand.Format(_T("/c mkdir %s"), strTestDir);
	ShellExecute(NULL, NULL,  _T("cmd.exe"),  strCommand, NULL, SW_HIDE);
	Sleep(TEST_DELAY);

	//copy file
	CString strSourceFile(m_strRootPath.c_str());
	strSourceFile += _T("Test\\Test\\Test.cpp");
	CString strDestFile(strTestDir);
	strDestFile += _T("Test.cpp");
	CopyFile(strSourceFile, strDestFile, TRUE);

	CString strFilename(_T("Test.cpp"));
	std::wstring strPath(strTestDir.GetBuffer());
	m_parser.setCurrentPath(strPath);
	int nRes = m_parser.obfuscate();

	//check
	CString strPathTempDirFile = strTestDir + g_strNameTempDir;
	strPathTempDirFile += _T("Test.cpp");
	bool bRes1 = isFileExist(strPathTempDirFile);
	CString strPathArchFile = strTestDir;
	strPathArchFile += _T("arch_obfuscate.obf");
	bool bRes2 = isFileExist(strPathArchFile);

	//del work dir
	strCommand = _T("");
	strCommand.Format(_T("/c rmdir %s /S /Q"), strTestDir);
	ShellExecute(NULL, NULL,  _T("cmd.exe"),  strCommand, NULL, SW_HIDE);
	Sleep(TEST_DELAY);

	SetCurrentDirectory(g_strCurrentDir.c_str());
	ASSERT_TRUE(!nRes && bRes1 && bRes2);
}
Пример #27
0
TEST_F(EngineTestParser,  parseFile_haveNullFileLength)
{
	//create work dir
	CString strCommand; 
	CString strTestDir(m_strRootPath.c_str());
	strTestDir += _T("TestDir\\");
	strCommand.Format(_T("/c mkdir %s"), strTestDir);
	ShellExecute(NULL, NULL,  _T("cmd.exe"),  strCommand, NULL, SW_HIDE);
	Sleep(TEST_DELAY);

	//create a nul file
	CString strFilePath(strTestDir);
	strFilePath += _T("ParserEngine.cpp");
	HANDLE hFile = CreateFile(strFilePath,  GENERIC_WRITE, 0,  
		NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
	if (hFile ==  INVALID_HANDLE_VALUE)
	{
		//del work dir
		strCommand = _T("");
		strCommand.Format(_T("/c rmdir %s /S /Q"), strTestDir);
		ShellExecute(NULL, NULL,  _T("cmd.exe"),  strCommand, NULL, SW_HIDE);
		ASSERT_TRUE(false);
	}
	CloseHandle(hFile);

	CString strPath(strTestDir);
	CString strFilename("ParserEngine.cpp");
	bool bCreateTempDir = false;
	int nRes = m_parser.parseFile(strPath, strFilename, bCreateTempDir);

	//del work dir
	strCommand = _T("");
	strCommand.Format(_T("/c rmdir %s /S /Q"), strTestDir);
	ShellExecute(NULL, NULL,  _T("cmd.exe"),  strCommand, NULL, SW_HIDE);
	Sleep(TEST_DELAY);

	SetCurrentDirectory(g_strCurrentDir.c_str());
	ASSERT_EQ(0, nRes);
}
Пример #28
0
void CDownloadsSettingsPage::OnIncompleteBrowse()
{
	CString strPath( BrowseForFolder( _T("Select folder for incomplete files:"),
		m_sIncompletePath ) );
	if ( strPath.IsEmpty() )
		return;

	// Warn user about a path that's too long
	if ( _tcslen( strPath ) > MAX_PATH - 60 )
	{
		CString strMessage;
		LoadString( strMessage, IDS_SETTINGS_FILEPATH_TOO_LONG );
		AfxMessageBox( strMessage, MB_ICONEXCLAMATION );
		return;
	}

	// Make sure download/incomplete folders aren't the same
	if ( _tcsicmp( strPath, m_sDownloadsPath ) == 0 )
	{
		CString strMessage;
		LoadString( strMessage, IDS_SETTINGS_FILEPATH_NOT_SAME );
		AfxMessageBox( strMessage, MB_ICONEXCLAMATION );
		return;
	}

	// Warn user about an incomplete folder in the library
	if ( LibraryFolders.IsFolderShared( strPath ) )
	{
		CString strMessage;
		LoadString( strMessage, IDS_SETTINGS_INCOMPLETE_LIBRARY );
		AfxMessageBox( strMessage, MB_ICONEXCLAMATION );
		return;
	}

	UpdateData( TRUE );
	m_sIncompletePath = strPath;
	UpdateData( FALSE );
}
Пример #29
0
HTREEITEM CTreePropSheet::CreatePageTreeItem(LPCTSTR lpszPath, HTREEITEM hParent /* = TVI_ROOT */)
{
	CString		strPath(lpszPath);
	CString		strTopMostItem(SplitPageTreePath(strPath));
	
	// Check if an item with the given text does already exist
	HTREEITEM	hItem = NULL;
	HTREEITEM	hChild = m_pwndPageTree->GetChildItem(hParent);
	while (hChild)
	{
		if (m_pwndPageTree->GetItemText(hChild) == strTopMostItem)
		{
			hItem = hChild;
			break;
		}
		hChild = m_pwndPageTree->GetNextItem(hChild, TVGN_NEXT);
	}

	// If item with that text does not already exist, create a new one
	if (!hItem)
	{
		hItem = m_pwndPageTree->InsertItem(strTopMostItem, hParent);
		m_pwndPageTree->SetItemData(hItem, -1);
		if (!strPath.IsEmpty() && m_bTreeImages && m_DefaultImages.GetSafeHandle())
			// set folder image
			m_pwndPageTree->SetItemImage(hItem, m_Images.GetImageCount()-2, m_Images.GetImageCount()-2);
	}
	if (!hItem)
	{
		ASSERT(FALSE);
		return NULL;
	}

	if (strPath.IsEmpty())
		return hItem;
	else
		return CreatePageTreeItem(strPath, hItem);
}
Пример #30
0
int WelsEncGetCurrentModulePath (char* lpModulePath, const int iPathMax) {
  if (lpModulePath == NULL || iPathMax <= 0) {
    return -1;
  }

  memset (lpModulePath, 0, iPathMax);

  char cCurrentPath[PATH_MAX];
  memset (cCurrentPath, 0, PATH_MAX);

  Dl_info 	dlInfo;
  static int  sDummy;
  dladdr ((void*)&sDummy, &dlInfo);

  strlcpy (cCurrentPath, dlInfo.dli_fname, PATH_MAX);

  int locateNumber = 1;

  std::string strPath (cCurrentPath);
  int pos = std::string::npos;
  for (int i = 0; i < locateNumber; i++) {
    pos = strPath.rfind ('/');
    if (std::string::npos == pos) {
      break;
    }
    strPath.erase (pos);
  }
  if (std::string::npos == pos) {
    return -2;
  }
  cCurrentPath[pos] = 0;

  strlcpy (lpModulePath, cCurrentPath, iPathMax);
  strlcat (lpModulePath, "/", iPathMax);

  return 0;

}