Exemple #1
0
int _tmain(int argc, _TCHAR* argv[]) //命令行传参调用
{
    TCHAR dir_in[MAX_PATH];           // 打包目录
    TCHAR dir_out[MAX_PATH];          // 输出目录
    TCHAR dir_index[MAX_PATH];        // 索引文件目录
 
    switch (argc)
    {
    case 2:
        // 检查路径是否合法(不允许反斜线结束)
        if (isFolderExist(argv[1]))
        {
            lstrcpynW(dir_in, argv[1], MAX_PATH);
            swprintf_s(dir_out, MAX_PATH, _T("%s.pak"), dir_in);
            swprintf_s(dir_index, MAX_PATH, _T("%s.dat"), dir_in);
        }
        else
        {
            printf_s("无法打开指定的路径\n");
            return 0;
        }
        break;
        
    case 3:
        if (isFolderExist(argv[1]) && isFolderExist(argv[2]))
        {
            lstrcpynW(dir_in, argv[1], MAX_PATH);
            swprintf_s(dir_out, MAX_PATH, _T("%s\\%s.pak"), argv[2], GetFolderName(argv[2]));
            swprintf_s(dir_index, MAX_PATH, _T("%s\\%s.dat"), argv[2], GetFolderName(argv[2]));
        }
        else
        {
            printf_s("无法打开指定的路径\n");
            return 0;
        }
        break;
        
    default:
        printf_s("用法: KEPacker 资源目录 [输出目录]\n注意: 路径不能以反斜线结尾\n");
        return 0;
    }
 
    try
    {
        pack mypack(dir_out, TCHAR dir_index, TCHAR dir_in);
    }
    catch(int)
    {
        printf_s("打包过程中出现错误\n");
    }
    
    getchar();
    return 0;
}
Exemple #2
0
void SceneryPage::CheckAutosave(int& debugPagesSaved, int& debugPropsSaved)
{
	if(mPendingChanges == 0)
		return;

	char buffer[256];

	if(mSceneryList.size() == 0)
	{
		GetFileName(buffer, sizeof(buffer));
		RemoveFile(buffer);
		mPendingChanges = 0;
	}
	else
	{
		if(mHasSourceFile == false)
		{
			GetFolderName(buffer, sizeof(buffer));
			Platform::MakeDirectory(buffer);
		}

		GetFileName(buffer, sizeof(buffer));
		if(SaveFile(buffer) == true)
		{
			mPendingChanges = 0;
			debugPropsSaved += mSceneryList.size();
			mHasSourceFile = true;
		}
	}
	debugPagesSaved++;
}
bool CFileStream::RecursionInsertFile(char* treepath,memory_tree_s* fileTree,memory_tree_s* DirTree)
{
	char TreeRoot[MAX_PATH];
	if(treepath[0] == '/')
	{
		treepath++;
		return RecursionInsertFile(treepath,fileTree,&memoryTreeRoot);
	}
	if(DirTree)
	{
		strcpy(TreeRoot,treepath);
		char * folderName = GetFolderName(TreeRoot);
		if(folderName)
		{
			int listsize = DirTree->dataList.size();
			if(listsize)
			{
				DWORD hashvalue = GetHashValue(folderName);
				for(int i=0;i<listsize;i++)
				{
					if(DirTree->dataList[i]->bDirectory &&
						DirTree->dataList[i]->dwHashValue == hashvalue &&
						m_strcmp(DirTree->dataList[i]->nStringIdx,folderName))
					{
						char* nextdir = &treepath[strlen(folderName)+1];
						return RecursionInsertFile(nextdir,fileTree,DirTree->dataList[i]); 
					}
				}
				memory_tree_s* newdir = new memory_tree_s;
				newdir->bDirectory = TRUE;
				newdir->nStringIdx = AllocString(folderName);
				newdir->dataSize = 0;
				newdir->dataOffset = 0;
				newdir->dwHashValue = GetHashValue(folderName);
				DirTree->dataList.push_back(newdir);
				char* nextdir = &treepath[strlen(folderName)+1];
				return RecursionInsertFile(nextdir,fileTree,newdir);
			}
			else
			{
				memory_tree_s* newdir = new memory_tree_s;
				newdir->bDirectory = TRUE;
				newdir->nStringIdx = AllocString(folderName);
				newdir->dataSize = 0;
				newdir->dataOffset = 0;
				newdir->dwHashValue = GetHashValue(folderName);
				DirTree->dataList.push_back(newdir);
				char* nextdir = &treepath[strlen(folderName)+1];
				return RecursionInsertFile(nextdir,fileTree,newdir);
			}
		}
		else
		{
			DirTree->dataList.push_back(fileTree);
			return true;
		}
	}
	return false;
}
ULONG CExMapi::GetContactCount()
{	
	BOOL doLog = m_pCtrl->IsEnableLog();
	if(doLog)
	{
		m_logHelper.LogPAB(L"------------------------------------");
		m_logHelper.LogPAB(L"Function GetPABCotactCount START:");
		m_logHelper.LogPAB(L"------------------------------------");
	}

	ULONG count = 0;
	LPMAPIFOLDER pFolder = NULL;
	LPMAPITABLE lpMsgStoreTable = NULL;
	lpMsgStoreTable = GetMessageStoresTable();	
	CString strFolder;
	int msgStoreCount = 0;
	wchar_t buffer[5];
	while(OpenNextMessageStore(lpMsgStoreTable))
	{			
		//pFolder = GetContactCount(OpenRootFolder(),count);			

		msgStoreCount++;
		_itow(msgStoreCount,buffer,10);
		if(doLog)
		{
			if(msgStoreCount > 1)
				m_logHelper.LogPAB(L"-------------------------------------");
			m_logHelper.LogPAB(L"Message Store No : "+CString(buffer));
			m_logHelper.LogPAB(L"-------------------------------------");
		}

		pFolder = OpenContacts();
		if(pFolder && IsContactFolder(pFolder))
		{
			strFolder = GetFolderName(pFolder);
			if(GetContents(pFolder))
			{
				count += GetRowCount();
			}		
			pFolder = GetContactCount(pFolder,count,doLog);
		}		
		if(m_pCtrl->IsPABContactCoutningAbort())
			break;
		__recursionCount = 0;
	}
	if(doLog)
	{
		m_logHelper.LogPAB(L"------------------------------------");
		m_logHelper.LogPAB(L"Function GetPABCotactCount END:");
		m_logHelper.LogPAB(L"------------------------------------");	
		m_logHelper.ClosePABLog();
	}
	__recursionCount = 0;
	RELEASE(lpMsgStoreTable);		
	
	return count;
}
memory_tree_t * CFileStream::FileIsExists(char* TreePath)
{
	static char szPath[MAX_PATH];
	char* szChars;
	char* pszFolderName;
	if(TreePath && TreePath[0] == '/')
	{
		strcpy(szPath,TreePath);
		szChars = (char*)&szPath;
		if(memoryTreeRoot.dataList.size() == 0)
		{
			return NULL;
		}
		szChars++;
		pszFolderName = GetFolderName(szChars);
		if(pszFolderName)
		{
			int listsize = memoryTreeRoot.dataList.size();
			if(listsize)
			{
				DWORD hashvalue = GetHashValue(pszFolderName);
				for(int i=0;i<listsize;i++)
				{
					if(memoryTreeRoot.dataList[i]->bDirectory &&
						memoryTreeRoot.dataList[i]->dwHashValue == hashvalue &&
						m_strcmp(memoryTreeRoot.dataList[i]->nStringIdx,pszFolderName))
					{
						char* nextdir = &szChars[strlen(pszFolderName)+1];
						return RecursionFileExists(nextdir,memoryTreeRoot.dataList[i]);
					}
				}
			}
			return NULL;
		}
		else
		{
			int listsize = memoryTreeRoot.dataList.size();
			if(listsize)
			{
				DWORD hashvalue = GetHashValue(szChars);
				for(int i=0;i<listsize;i++)
				{

					if(!memoryTreeRoot.dataList[i]->bDirectory &&
						memoryTreeRoot.dataList[i]->dwHashValue == hashvalue &&
						m_strcmp(memoryTreeRoot.dataList[i]->nStringIdx,szChars)
						)
					{
						return memoryTreeRoot.dataList[i];
					}
				}
			}
		}
	}
	return NULL;
}
Exemple #6
0
void CDlgArmLogICImage::LoadImage() 
{
	CString csFolderName = GetFolderName();
	CString csFileName = GetFileName();
	CString csFilePath = m.FilePath.ArmLogICImagePath + "" + csFolderName + "\\" + csFileName;

#ifdef _Demo
	AfxMessageBox( csFilePath );
#endif

	pViewICImage->SetFileName( csFilePath );	
	pViewICImage->Invalidate( FALSE );
	CenterWindow();
}
memory_tree_s* CFileStream::RecursionFileExists(char* TreePath,memory_tree_s* DirTree)
{
	char* pszFolderName = GetFolderName(TreePath);
	if(pszFolderName)
	{
		DWORD hashvalue = GetHashValue(pszFolderName);
		
		int listsize = DirTree->dataList.size();
		if(listsize)
		{
			for(int i=0;i<listsize;i++)
			{
				if(DirTree->dataList[i]->bDirectory && DirTree->dataList[i]->dwHashValue == hashvalue && m_strcmp(DirTree->dataList[i]->nStringIdx,pszFolderName))
				{
					char* nextdir = &TreePath[strlen(pszFolderName)+1];
					return RecursionFileExists(nextdir,DirTree->dataList[i]);
				}
			}
		}
		else
		{
			return NULL;
		}

	}
	else
	{
		int listsize = DirTree->dataList.size();
		if(listsize)
		{
			DWORD hashvalue = GetHashValue(TreePath);
			for(int i=0;i<listsize;i++)
			{
				if(!DirTree->dataList[i]->bDirectory)
				{
					if( DirTree->dataList[i]->dwHashValue == hashvalue &&
						m_strcmp(DirTree->dataList[i]->nStringIdx,TreePath))
						return DirTree->dataList[i];
				}
			}
		}
		else
		{
			return NULL;
		}
	}
	return NULL;
}
//////////////
// Initialize
bool KanaMemo::OnInit() {
	// Configuration
	SetAppName(_T("KanaMemo"));
	srand((unsigned)time(NULL));

	// Get path
	GetFullPath(argv[0]);
	GetFolderName();

	// Create the window
	GameWindow *window = new GameWindow();
	window->Show();

	// Initialization OK
	return true;
}
Exemple #9
0
void CDlgArmLogICImage::OnDblclkListFolder() 
{
	CString csFolderName = GetFolderName();
	CString csFilePath = _T("");
	CString csMsg = _T("");
	csMsg.Format("Delete Folder [%s] ?\n", csFolderName );
	if(IDYES != AfxMessageBox( csMsg,
			MB_YESNO|MB_ICONEXCLAMATION))
	{
		// No
	}
	else
	{
		DeleteImageFolder( csFolderName );
		UpdataFolderStatus();
		SetFolderValue(0);
	}
}
Exemple #10
0
void CDlgArmLogICImage::SetFolderValue(int iIndex)
{
	int iSize = m_Folder.GetSize();
	if( iIndex > iSize )
		iIndex = 0;

	if( iSize == 0 )
	{
		m_listFolderFileStatus.ResetContent(); // last one clear all
		return;
	}

	m_listFolderStatus.SetCurSel(iIndex);

	//
	CString csFolderName = GetFolderName();
	UpdataFileStatus( csFolderName );
}
Exemple #11
0
void CDlgArmLogICImage::OnDblclkListFile() 
{
	CString csFileName = GetFileName();
	CString csMsg = _T("");
	csMsg.Format("Delete this file [%s] ?\n", csFileName );
	if(IDYES != AfxMessageBox( csMsg,
			MB_YESNO|MB_ICONEXCLAMATION))
	{
		// No
	}
	else
	{
		// Delete
		CString csFolderName = GetFolderName();
		CString csFilePath = _T("");
		csFilePath = m.FilePath.ArmLogICImagePath + "\\" + csFolderName + "\\" + csFileName;
		::DeleteFile( csFilePath );
		
		//
		UpdataFileStatus( csFolderName );
	}	
}
Exemple #12
0
static PyObject *Folder_GetFolderName(PyObject *_self, PyObject *_args)
{
	PyObject *_res = NULL;
	OSErr _err;
	short vRefNum;
	OSType foldType;
	short foundVRefNum;
	Str255 name;
	if (!PyArg_ParseTuple(_args, "hO&O&",
	                      &vRefNum,
	                      PyMac_GetOSType, &foldType,
	                      PyMac_GetStr255, name))
		return NULL;
	_err = GetFolderName(vRefNum,
	                     foldType,
	                     &foundVRefNum,
	                     name);
	if (_err != noErr) return PyMac_Error(_err);
	_res = Py_BuildValue("h",
	                     foundVRefNum);
	return _res;
}
BOOL CExMapi::GetContacts(CObArray& contactArray,CTRError& error)
{
	BOOL doLog = m_pCtrl->IsEnableLog();
	if(doLog)
	{
		m_logHelper.LogPAB(L"------------------------------------");
		m_logHelper.LogPAB(L"Function GetPABCotacts START:");
		m_logHelper.LogPAB(L"------------------------------------");
	}

	CString strFilterBy = m_pCtrl->GetPABSerachBy();
	CString strStartWith = m_pCtrl->GetPABSerachStartWith();
	strStartWith = strStartWith.MakeLower();
	ULONG pageSize;
	m_pCtrl->get_PABPageSize(&pageSize);
	ULONG pageNumber = m_pCtrl->GetPABPageNumber();
	LONG contactCount = 0;
	LONG skipCount = 0;
	LONG startIndex = -1;
	LONG contactIndex = 0;
	LONG folderCount = 0;
	if(pageSize>0)
	{
		startIndex = (pageSize * pageNumber) - pageSize;
	}

	CString strFolder;
	int msgStoreCount = 0;
	wchar_t buffer[5];

	LPMAPIFOLDER pSubFolder=NULL;	
	LPMAPITABLE lpMsgStoreTable = NULL;
	lpMsgStoreTable = GetMessageStoresTable();	
	if(lpMsgStoreTable)
	{
		while(OpenNextMessageStore(lpMsgStoreTable))
		{	
			//GetContacts(OpenRootFolder(),folderCount,contactCount,skipCount,contactIndex,contactArray);

			msgStoreCount++;
			_itow(msgStoreCount,buffer,10);
			if(doLog)
			{
				if(msgStoreCount > 1)
					m_logHelper.LogPAB(L"-------------------------------------");
				m_logHelper.LogPAB(L"Message Store No : "+CString(buffer));
				m_logHelper.LogPAB(L"-------------------------------------");
			}

			pSubFolder = OpenContacts();
			if(pSubFolder && IsContactFolder(pSubFolder))
			{
				if(doLog)
					m_logHelper.LogPAB(L"Open Main Contacts Folder");

				strFolder = GetFolderName(pSubFolder);
				folderCount++;
				if(GetContents(pSubFolder))
				{
					SortContents(TABLE_SORT_ASCEND,PR_DISPLAY_NAME);
					//SortContents(TABLE_SORT_ASCEND,PR_SUBJECT);

					CString strText;
					CExMapiContact mapiContact;
					CString name;
					CString email;
					BOOL mustFilter = FALSE;
					mustFilter = strStartWith != "";
					
					if(doLog)
						m_logHelper.LogPAB(L"Start reading contacts from main contact fodler");

					while(GetNextContact(mapiContact) && !m_pCtrl->IsPABSearchAbort()) 
					{
						if(pageSize > 0)
						{
							if(contactCount == pageSize)
							{
								break;								
							}
						}

						contactIndex++;
						if(mustFilter)
						{
							if(strFilterBy == "Name")
							{
								mapiContact.GetName(name,PR_GIVEN_NAME);
								name = name.MakeLower();
								if(name.Find(strStartWith) != 0)				
								{
									continue;									
								}
							}

							if(strFilterBy == "Email")
							{
								mapiContact.GetEmail(email);
								email = email.MakeLower();
								if(email.Find(strStartWith) != 0)
								{
									continue;
								}
							}																
						}
						if(startIndex > 0 && skipCount < startIndex)
						{
							skipCount++;
							continue;								
						}

						CContact* pContact = new CContact();

						pContact->SetId(contactIndex);

						pContact->SetFolderName(strFolder);

						mapiContact.GetName(strText);
						pContact->SetFullName(strText);

						mapiContact.GetCompany(strText);
						pContact->SetCompany(strText);

						mapiContact.GetIMAddress(strText);
						pContact->SetIMAddress(strText);

						mapiContact.GetName(strText,PR_GIVEN_NAME);
						pContact->SetFirstName(strText);

						mapiContact.GetName(strText,PR_MIDDLE_NAME);
						pContact->SetMiddleName(strText);

						mapiContact.GetName(strText,PR_SURNAME);
						pContact->SetLastName(strText);

						mapiContact.GetEmail(strText);
						pContact->SetEmail(strText);	

						mapiContact.GetEmail(strText,2);//Email 2
						pContact->SetEmail2(strText);

						mapiContact.GetEmail(strText,3);//Email 3
						pContact->SetEmail3(strText);

						mapiContact.GetPhoneNumber(strText,PR_BUSINESS_TELEPHONE_NUMBER);
						pContact->SetBusinessPhone(strText);

						mapiContact.GetPhoneNumber(strText,PR_COMPANY_MAIN_PHONE_NUMBER);
						pContact->SetCompanyPhone(strText);

						mapiContact.GetPhoneNumber(strText,PR_BUSINESS_FAX_NUMBER);
						pContact->SetFax(strText);

						mapiContact.GetPhoneNumber(strText,PR_MOBILE_TELEPHONE_NUMBER);
						pContact->SetMobilePhone(strText);

						mapiContact.GetPhoneNumber(strText,PR_HOME_TELEPHONE_NUMBER);
						pContact->SetHomePhone(strText);

						if(m_pCtrl->FetchUnique())
						{
							BOOL isContactExist = FALSE;
							for(int i=0;i<contactArray.GetCount();i++)
							{
								CContact* pTemp = (CContact*)contactArray.GetAt(i);

								if(pContact->GetEmail() != "" && pTemp->GetEmail() == pContact->GetEmail())
								{
									isContactExist = TRUE;
									break;																	
								}
								else if(pContact->GetFullName() != "" && pTemp->GetFullName() == pContact->GetFullName())
								{
									isContactExist = TRUE;
									break;
								}
								else if(pContact->GetMobilePhone() != "" && pTemp->GetMobilePhone() == pContact->GetMobilePhone())
								{
									isContactExist = TRUE;
									break;
								}
								else if(pContact->GetHomePhone() != "" && pTemp->GetHomePhone() == pContact->GetHomePhone())
								{
									isContactExist = TRUE;
									break;
								}
								else if(pContact->GetBusinessPhone() != "" && pTemp->GetBusinessPhone() == pContact->GetBusinessPhone())
								{
									isContactExist = TRUE;
									break;
								}
							}

							if(isContactExist)
							{
								continue;
							}
						}														
						contactArray.Add(pContact);							
						contactCount++;							
					}
				}
				if(doLog)
					m_logHelper.LogPAB(L"Open Sub Contacts Folder");
				GetContacts(pSubFolder,folderCount,contactCount,skipCount,contactIndex,contactArray,doLog);
			}
			if(pageSize > 0)
			{
				if(contactCount == pageSize)
					break;								
			}
			if(m_pCtrl->IsPABSearchAbort())
				break;
			__recursionCount = 0;
		}
	}	
	if(doLog)
	{
		m_logHelper.LogPAB(L"------------------------------------");
		m_logHelper.LogPAB(L"Function GetPABCotacts END:");
		m_logHelper.LogPAB(L"------------------------------------");	
		m_logHelper.ClosePABLog();
	}
	__recursionCount = 0;
	RELEASE(lpMsgStoreTable);		

	if(folderCount == 0 && !m_pCtrl->IsPABSearchAbort())
	{
		error.code = 107;
		error.err = "TRContactFinder Cannot find private folders.";
		return FALSE;
	}

	return TRUE;
}
Exemple #14
0
///////////////////////////
// Initialization function
// -----------------------
// Gets called when application starts, creates MainFrame
bool AegisubApp::OnInit() {
	try {
		// Initialize randomizer
		srand(time(NULL));

		// App name
		SetAppName(_T("Aegisub"));
		#ifndef _DEBUG
		wxHandleFatalExceptions(true);
		#endif

		// Set config file
		GetFullPath(argv[0]);
		GetFolderName();
		Options.SetFile(folderName + _T("/config.dat"));
		Options.Load();
		AssTime::UseMSPrecision = Options.AsBool(_T("Use nonstandard Milisecond Times"));
		AssDialogue::keepData = Options.AsBool(_T("Keep raw dialogue data"));

		// Set hotkeys file
		Hotkeys.SetFile(folderName + _T("/hotkeys.dat"));
		Hotkeys.Load();

#ifdef __WINDOWS__
		// Set locale
		int lang = Options.AsInt(_T("Locale Code"));
		if (lang == -1) {
			lang = locale.PickLanguage();
			Options.SetInt(_T("Locale Code"),lang);
			Options.Save();
		}
		locale.Init(lang);
#else
		locale.Init(wxLocale::GetSystemLanguage());
#endif

		// Load export filters
		AssExportFilterChain::PrepareFilters();

		// Set association
		RegistryAssociate();

		// Get parameter subs
		wxArrayString subs;
		for (int i=1;i<argc;i++) {
			subs.Add(argv[i]);
		}

		// Open main frame
		frame = new FrameMain(subs);
		frame->Show(true);
		SetTopWindow(frame);
	}

	catch (const wchar_t *err) {
		wxMessageBox(err,_T("Fatal error while initializing"));
		return false;
	}

	catch (...) {
		wxMessageBox(_T("Unhandled exception"),_T("Fatal error while initializing"));
		return false;
	}

	return true;
}
Exemple #15
0
void CDlgArmLogICImage::OnSelchangeListFolder() 
{
	CString csFolderName = GetFolderName();
	UpdataFileStatus( csFolderName );	
}