예제 #1
0
파일: gamecore.c 프로젝트: nonakap/xkazoku
BOOL gamecore_init(const char *path) {

const char	*e;

	e = NULL;
	ZeroMemory(&gamecore, sizeof(gamecore));
	if (path == NULL) {
		e = "no suf file (NULL)";
		goto gcinit_err;
	}

	gamedef_create();

	if (archive_create()) {
		e = "couldn't read archives";
		goto gcinit_err;
	}
	readsuf(path);
	gamecfg_init();
	gamecfg_reset();
	gamecfg_load();
	gamecore.cfglist = listarray_new(sizeof(_GCDLG), 32);

	if (vramdraw_create() != SUCCESS) {
		e = "couldn't create vram";
		goto gcinit_err;
	}

	if (scr_init(gamecore.sys.defbits, gamecore.sys.defflags) != SUCCESS) {
		e = "couldn't create flags";
		goto gcinit_err;
	}

	sndplay_init();
	gamecore.dispwin.fontsize = 16;
	gamecore.dispwin.fonttype = TEXTCTRL_BOLD |
					((gamecore.sys.type & GAME_TEXTASCII)?TEXTCTRL_ASCII:0);
	textctrl_init(&gamecore.textdraw);
	textwin_create();
	event_mousereset();

	if (gamecore.sys.type & GAME_DRS) {
		savedrs_sysread();
	}

	if (scr_scriptcall("START")) {
		e = "couldn't reat start script";
		goto gcinit_err;
	}

	gamecore.initialized = TRUE;
	return(SUCCESS);

gcinit_err:
	gamecore.err = e;
	return(FAILURE);
}
예제 #2
0
bool CFileListView::OnCommand( WORD wNotifyCode, WORD wID, HWND hwndCtl )
{
	switch (wID)
	{
	case MENU_LOOK:
		LookItem(GetFirstSelected());
		break;
	case MENU_EXTRACT:
		ExtractSelect();
		break;
	case MENU_RENAME:
		break;
	case MENU_DELETE:
		{
			if(m_pArchive != NULL)
			{
				RemoveFileNode(*(m_FileStack.back()), GetCurrentSelected());
				ShowFileInfo(*(m_FileStack.back()));
			}
		}
		break;
	case MENU_NEW:
		{
			if(m_pArchive == NULL)
			{
				char szBuffer[MAX_PATH] = {0}; 
				OPENFILENAME ofn= {0}; 

				ofn.lStructSize = sizeof(ofn); 
				ofn.hwndOwner = m_hWnd; 
				ofn.lpstrFilter = "JArchive文件(*.arc)\0*.arc\0所有文件(*.*)\0*.*\0";
				ofn.nFilterIndex = 0; 
				ofn.lpstrInitialDir = NULL;
				ofn.lpstrFile = szBuffer;
				ofn.nMaxFile = MAX_PATH; 
				ofn.Flags = OFN_OVERWRITEPROMPT;

				if(GetSaveFileName(&ofn))
				{
					char* pExt = strrchr(szBuffer,'.');
					if(pExt == NULL)
						strcat_s(szBuffer, MAX_PATH, ".arc");

					m_pArchive = archive_create(szBuffer,0);
					if(m_pArchive != NULL && m_pParent != NULL)
					{
						char szTitle[MAX_PATH];
						sprintf_s(szTitle, MAX_PATH, "JArchiveEditor - %s",szBuffer);
						m_pParent->SetWindowText(szTitle);
						strcpy_s(m_szArchiveName, MAX_PATH, szBuffer);
					}
				}
			}
		}
		break;
	case MENU_OPEN:
		{
			if(m_pArchive == NULL)
			{
				char szBuffer[MAX_PATH] = {0}; 
				OPENFILENAME ofn= {0};

				ofn.lStructSize = sizeof(ofn); 
				ofn.hwndOwner = m_hWnd; 
				ofn.lpstrFilter = "JArchive文件(*.arc)\0*.arc\0所有文件(*.*)\0*.*\0";
				ofn.nFilterIndex = 0; 
				ofn.lpstrInitialDir = NULL;
				ofn.lpstrFile = szBuffer;
				ofn.nMaxFile = MAX_PATH; 
				ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;

				if(GetOpenFileName(&ofn))
					OpenArchive(szBuffer);
			}
		}
		break;
	case MENU_CLOSE:
		CloseArchive();
		break;
	case MENU_EXTRACT_FILEINFO:
		{
			char szSavePath[MAX_PATH];
			OPENFILENAME ofn = {0};

			if(m_pArchive == NULL)
				break;

			char* pName = strrchr(m_szArchiveName, '\\');
			if(pName != NULL)
				strcpy_s(szSavePath, MAX_PATH, pName+1);
			else
				strcpy_s(szSavePath, MAX_PATH, m_szArchiveName);

			pName = strrchr(szSavePath, '.');
			if(pName != NULL)
				*pName = 0;

			ofn.lStructSize = sizeof(ofn); 
			ofn.hwndOwner = m_hWnd; 
			ofn.lpstrFilter = "JArchive文件信息(*.afi)\0*.afi\0所有文件(*.*)\0*.*\0";
			ofn.nFilterIndex = 0; 
			ofn.lpstrInitialDir = NULL;
			ofn.lpstrFile = szSavePath;
			ofn.nMaxFile = MAX_PATH; 
			ofn.Flags = OFN_OVERWRITEPROMPT;

			if(GetSaveFileName(&ofn))
			{
				char* pExt = strrchr(szSavePath,'.');
				if(pExt == NULL)
					strcat_s(szSavePath, MAX_PATH, ".afi");

				archive_extract_describe(m_pArchive, szSavePath);
			}
		}
		break;
	}
	return false;
}
예제 #3
0
int main(int argc, char** argv) {
	char* archive = NULL;
	char buf[PATH_MAX];
	int pid;
	int opt;
	int perm = ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_TIME |
		ARCHIVE_EXTRACT_ACL | ARCHIVE_EXTRACT_FFLAGS | ARCHIVE_EXTRACT_SECURE_SYMLINKS;
	gchar cwd[PATH_MAX];
	gboolean remove = FALSE;
	const char *p = NULL;
	int res;

	getcwd(cwd, PATH_MAX);

	while (*++argv && **argv == '-') {
		p = *argv + 1;

		while ((opt = *p++) != '\0') {
			switch(opt) {
				case 'a':
					if (*p != '\0')
						archive = (char *) p;
					else
						archive = *++argv;
					p += strlen(p);
					break;
				case 'r':
					remove = TRUE;
					break;
			}
		}
	}
	if (! archive) {
		fprintf(stderr, "Missing archive name!\n");
		return EXIT_FAILURE;
	}
	if (!*argv) {
		fprintf(stderr, "Expected arguments after options!\n");
		return EXIT_FAILURE;
	}
	
	while (*argv) {
		archive_scan_folder(*argv++);
		res = archive_create(archive, file_list);
		if (res != ARCHIVE_OK) {
			fprintf(stderr, "%s: Creating archive failed\n", archive);
			return EXIT_FAILURE;
		}
	}
	pid = (int) getpid();
	sprintf(buf, "/tmp/%d", pid);
	fprintf(stdout, "Creating: %s\n", buf);
	mkdir(buf, 0700);
	chdir(buf);
	if (strcmp(dirname(archive), ".") == 0) 
		sprintf(buf, "%s/%s", cwd, basename(archive));
	else
		sprintf(buf, "%s", archive);
	archive_extract(buf, perm);
	chdir(cwd);
	if (remove) {
		sprintf(buf, "rm -rf /tmp/%d", pid);
		fprintf(stdout, "Executing: %s\n", buf);
		system(buf);
	}
	archive_free_list(file_list);
	return EXIT_SUCCESS;
}