コード例 #1
0
ファイル: luaSystem.cpp プロジェクト: siruhu/Rigidchips15C
int luaLoadLand(lua_State *L)
{
	char *str=(char*)lua_tostring(L, 1);
	int r=0;
	char st[_MAX_PATH];
	if(strcmp(szLandFileName0,str)!=0) {
		char *s=SearchFolder(CurrDataDir,str,st);
		if(s==NULL) {
			char *s=SearchFolder(DataDir,str,st);
			if(s==NULL) {
				s=SearchFolder(ResourceDir,str,st);
				if(s==NULL) {
					lua_pushnumber(L,0);
					return 1;
				}
			}
		}

  
		r=LoadLand(G3dDevice, s);
		if(r==0) {
			char szDrive[_MAX_DRIVE + 1];	// ドライブ名格納領域 
			char szPath [_MAX_PATH + 1];	// パス名格納領域 
			char szTitle[_MAX_FNAME + 1];	// ファイルタイトル格納領域 
			char szExt  [_MAX_EXT + 1];		// ファイル拡張子格納領域 

			// 絶対パスを分解 
			_splitpath ( str, 
						szDrive, szPath, 
						szTitle, szExt);
			lstrcpy(szLandFileName,str);
			lstrcpy(szLandFileName0,szTitle);
			lstrcat(szLandFileName0,szExt);
			GFloat y=World->Land->GetY(0,0);
			Chip[0]->CalcTotalCenter();
			Chip[0]->X=GVector(0,Chip[0]->Top->TotalRadius*2+2+y,0);
			Chip[0]->R=GMatrix33();
			World->RestoreLink(Chip[0],Chip[0]);
			if(Chip[0]->X.y<=-100000.0f)Chip[0]->X.y=0.0f;
			m_pLandMesh->InvalidateDeviceObjects();
			m_pLandMesh->RestoreDeviceObjects(G3dDevice);
		}
	}
	World->MainStepCount=-1;

	lua_pushnumber(L,r);
	return 1;
}
コード例 #2
0
ファイル: MAKEBOOK.CPP プロジェクト: QiuleiWang/eleeye
BOOL WINAPI MakeBook(LPCSTR szPath, LPCSTR szFile,
    LONG nWin, LONG nDraw, LONG nLoss, LONG nRatio) {
  BOOL bSuccess;
  Init();
  bSuccess = FALSE;
  MakeBook2.nWin = nWin;
  MakeBook2.nDraw = nDraw;
  MakeBook2.nLoss = nLoss;
  MakeBook2.nRatio = nRatio;
  MakeBook2.fpTempFile = tmpfile();
  if (MakeBook2.fpTempFile != NULL) {
    MakeBook2.nTempLen = 0;
    MakeBook2.fpBookFile = fopen(szFile, "wb");
    if (MakeBook2.fpBookFile != NULL) {
      SearchFolder(szPath);
      if (MakeBook2.nTempLen > 1) {
        MakeBook2.TempBuffer = new TempStruct[TEMP_BUFFER_SIZE];
        SortTemp(0, MakeBook2.nTempLen - 1);
        delete[] MakeBook2.TempBuffer;
      }
      MakeBook();
      fclose(MakeBook2.fpBookFile);
      bSuccess = TRUE;
    }
    fclose(MakeBook2.fpTempFile);
  }
  return bSuccess;
}
コード例 #3
0
ファイル: ADDECCO.CPP プロジェクト: QiuleiWang/eleeye
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
  char szPath[MAX_PATH], szLibEccoFile[MAX_PATH];
  EccoApiStruct EccoApi;
  BROWSEINFO bi;
  LPITEMIDLIST pidl;

  LocatePath(szLibEccoFile, cszLibEccoFile);
  if (!EccoApi.Startup(szLibEccoFile)) {
    MessageBox(NULL, "没有找到ECCO.DLL!", "ECCO开局信息整理工具", MB_ICONEXCLAMATION);
    return 0;
  }
  bi.hwndOwner = NULL;
  bi.pidlRoot = NULL;
  bi.pszDisplayName = NULL;
  bi.lpszTitle = "请选择可移植棋谱(*.PGN)所在的文件夹";
  bi.ulFlags = BIF_RETURNONLYFSDIRS;
  bi.lpfn = NULL;
  bi.lParam = NULL;
  bi.iImage = 0;
  pidl = SHBrowseForFolder(&bi);
  if (SHGetPathFromIDList(pidl, szPath)) {
    PreGenInit();
    ChineseInit();
    SearchFolder(szPath, EccoApi);
    MessageBox(NULL, "全部棋谱已加入ECCO开局信息。", "ECCO开局信息整理工具", MB_ICONINFORMATION);
  }
  EccoApi.Shutdown();
  return 0;
}
コード例 #4
0
void BrowseFolder( char drive , std::string drive_type ) {
#if !defined(HX_DOS)
	if (Drives[drive-'A']) {
		LOG_MSG("Unmount drive %c first, and then try again.",drive);
		return;
	}
	std::string title = "Select a drive/directory to mount";
	char path[MAX_PATH];
	BROWSEINFO bi = { 0 };
	if(drive_type=="CDROM")
		bi.lpszTitle = ( title + " CD-ROM\nMounting a directory as CD-ROM gives an limited support" ).c_str();
	else if(drive_type=="FLOPPY")
		bi.lpszTitle = ( title + " as Floppy" ).c_str();
	else if(drive_type=="LOCAL")
		bi.lpszTitle = ( title + " as Local").c_str();
	else
		bi.lpszTitle = (title.c_str());
	LPITEMIDLIST pidl = SHBrowseForFolder ( &bi );

	if ( pidl != 0 ) {
		SHGetPathFromIDList ( pidl, path );
//		SetCurrentDirectory ( path );
		SearchFolder( path , drive, drive_type );
		IMalloc * imalloc = 0;
		if ( SUCCEEDED( SHGetMalloc ( &imalloc )) ) {
			imalloc->Free ( pidl );
			imalloc->Release ( );
		}
	}
#endif
}
コード例 #5
0
ファイル: face-search.c プロジェクト: namwkim/FaceSearch
void SearchFolder(char* folder, FEATURE* feature, CvSeq* scores, void (*f)(char*, FEATURE*, CvSeq*)){
	char dir_path[FLEN];
	DIR *dbDir = NULL;
	struct dirent *file = NULL;
	struct stat buf;

	dbDir = opendir(folder);
	if(!dbDir) {
		fprintf(stderr, "ERROR\n");
	}
	while( (file = readdir(dbDir)) != NULL ){
        memset(&buf, 0, sizeof(struct stat));

        strcpy(dir_path, folder);
		strcat(dir_path,"/");
		strcat(dir_path, file->d_name);
		lstat(dir_path, &buf);
        if(	strcmp(file->d_name, ".")!=0 &&
			strcmp(file->d_name, "..")!=0 &&
			S_ISDIR(buf.st_mode)){ //folder
        	//printf("searching a folder: %s\n", dir_path);
        	SearchFolder(dir_path, feature, scores, f);

        }else if(S_ISREG(buf.st_mode)){  //regular file
            if (IsImageFile(file->d_name)){//For each Image File
            	//printf("comparing to an image: %s\n", dir_path);
            	(*f)(dir_path, feature, scores);
            }
        }
	}
	closedir(dbDir);
}
コード例 #6
0
void CFileSearchDlg::Search()
{
	if (m_Folder.IsEmpty())
		SearchAllDrives();
	else
		SearchFolder(m_Folder);
	PostMessage(WM_USER);
}
コード例 #7
0
ファイル: face-search.c プロジェクト: namwkim/FaceSearch
int SearchInMem(
		IplImage* 	RGBA,
		IplImage* 	depth,
		IplImage*	mask,
		char* DBFolderName,
		char* categoryFolders[],
		int numCategories,
		char* outputFileNames[],
		float* outputScores,
		int num){


	char cat_dir_path[FLEN];

	// calculate features for the query image
	FEATURE feature;
	MakeFeatureInMem(RGBA, depth, mask, &feature);

	//temporary storage for files
	CvMemStorage* storage = cvCreateMemStorage(0);

	//store comp scores
	CvSeq* scores = cvCreateSeq(0, sizeof(CvSeq), sizeof(FileWithScore), storage);

	// loop through the files in the category folders in DB.
	for (int i=0; i<numCategories; i++){
		strcpy(cat_dir_path, DBFolderName);
		strcat(cat_dir_path,"/");
		strcat(cat_dir_path, categoryFolders[i]);

		SearchFolder(cat_dir_path, &feature, scores, CompareImage);
	}

	//sort images by scores
	cvSeqSort(scores, CompFileWithScore, NULL);

	//release memories for scores & strings
	for (int i=0; i<scores->total; i++){
		FileWithScore* sc = (FileWithScore*) cvGetSeqElem(scores, i);
		if (i<num){
			outputFileNames[i] = (char*)malloc(strlen(sc->img_file));
			strcpy(outputFileNames[i], sc->img_file);
			outputScores[i] = sc->score;
		}
		//free(sc->img_file);
	}
	for (int i=scores->total; i<num; i++){
		outputFileNames[i] 	= NULL;
		outputScores[i]		= -1.0;
	}
	cvClearSeq(scores);
	cvReleaseMemStorage( &storage );
	ReleaseFeature(&feature);

	return 0;
}
コード例 #8
0
ファイル: MAKEBOOK.CPP プロジェクト: QiuleiWang/eleeye
static void SearchFile(const char *szFilePath, const WIN32_FIND_DATA &wfd) {
  if ((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
    if (strlen(szFilePath) > 4) {
      if (strnicmp(szFilePath + strlen(szFilePath) - 4, ".PGN", 4) == 0) {
        ParseFile(szFilePath);
      }
    }
  } else {
    if (strcmp(wfd.cFileName, ".") != 0 && strcmp(wfd.cFileName, "..") != 0) {
      SearchFolder(szFilePath);
    }
  }
}
コード例 #9
0
ファイル: ADDECCO.CPP プロジェクト: QiuleiWang/eleeye
static void SearchFile(const char *szFilePath, const WIN32_FIND_DATA &wfd, const EccoApiStruct &EccoApi) {
  int nPathLen;
  if ((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
    nPathLen = strlen(szFilePath) - 4;
    if (nPathLen > 0 && strnicmp(szFilePath + nPathLen, ".PGN", 4) == 0) {
      AddEcco(szFilePath, EccoApi);
    }
  } else {
    if (strcmp(wfd.cFileName, ".") != 0 && strcmp(wfd.cFileName, "..") != 0) {
      SearchFolder(szFilePath, EccoApi);
    }
  }
}
コード例 #10
0
bool CFileSearchDlg::SearchAllDrives()
{
	DWORD	len = GetLogicalDriveStrings(0, NULL);	// get list size
	CString	DriveList;
	char	*p = DriveList.GetBufferSetLength(len);
	GetLogicalDriveStrings(len, p);
	while (*p) {
		// if drive type is selected by type mask
		if ((1 << GetDriveType(p)) & m_DriveTypeMask) {
			p[2] = 0;	// remove backslash
			if (!SearchFolder(p))
				return(FALSE);
		}
		p += 4;		// drive letter, colon, backslash, null
	}
	return(TRUE);
}
コード例 #11
0
ファイル: Utils.cpp プロジェクト: Feoggou/filetransfer
void SearchFolder(IShellFolder* pSearchFolder, CDoubleList<FILE_ITEM> &Items, LARGE_INTEGER& liSize)
{
	//getting the enumerator object to enumerate the items of the search folder
	IEnumIDList* pEnumIDList = NULL;
	HRESULT hr = pSearchFolder->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &pEnumIDList);
	if (FAILED(hr))
	{
		if (hr != E_ACCESSDENIED)
			DisplayError(hr);
		return;
	}

	if (hr == S_FALSE) return;

	//getting pidl to each child item
	ITEMIDLIST* pidlChild = NULL;
	HRESULT hrEnum;
	do
	{
		hrEnum = pEnumIDList->Next(1, &pidlChild, NULL);
		if (FAILED(hrEnum))
		{
			pEnumIDList->Release();

			_ASSERT(0);
			DisplayError(hrEnum);
			return;
		}

		if (S_FALSE == hrEnum) break;

		//we need to know whether this is a folder or a file, and if it is a system item
		ULONG ulFlags = 0xFFFFFFFF;
		hr = pSearchFolder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidlChild, &ulFlags);
		if (FAILED(hr))
		{
			CoTaskMemFree(pidlChild);
			pidlChild = NULL;
			pEnumIDList->Release();

			_ASSERT(0);
			MessageBox(0, L"Could not get the attributes of the item: pSearchFolder->GetAttributesOf", 0, 0);
			return;
		}

		if (ulFlags & SFGAO_FILESYSTEM)
		{
			if (ulFlags & SFGAO_FOLDER && ulFlags & SFGAO_FILESYSANCESTOR && ulFlags & SFGAO_STORAGE)
			{
				//we need to search it
				IShellFolder* pNewSearchFolder = NULL;
				hr = pSearchFolder->BindToObject(pidlChild, NULL, IID_IShellFolder, (void**)&pNewSearchFolder);
				if (FAILED(hr))
				{
					CoTaskMemFree(pidlChild);
					pidlChild = NULL;
					pEnumIDList->Release();

					_ASSERT(0);
					MessageBox(0, L"Could not bind to new folder: pSearchFolder->BindToObject", 0, 0);
					return;
				}

				//it is a folder!!
				//get its full name
				STRRET strret;
				pSearchFolder->GetDisplayNameOf(pidlChild, SHGDN_FORPARSING, &strret);
				WCHAR* wsFullName;
				StrRetToStrW(&strret, NULL, &wsFullName);

				FILE_ITEM item;
				item.size = 0;

				item.wsFullName = wsFullName;
				item.type = ItemType::Folder;
				Items.push_back(item);

				SearchFolder(pNewSearchFolder, Items, liSize);
				pNewSearchFolder->Release();
			}
			else if (ulFlags & SFGAO_STREAM)
			{
				//it is a file!!
				//get its full name
				STRRET strret;
				pSearchFolder->GetDisplayNameOf(pidlChild, SHGDN_FORPARSING, &strret);
				WCHAR* wsFullName;
				StrRetToStrW(&strret, NULL, &wsFullName);

				FILE_ITEM item;
				LARGE_INTEGER li;
				CalcFileSize(wsFullName, li);
				item.size = li.QuadPart;
				liSize.QuadPart += item.size;

				item.wsFullName = wsFullName;
				item.type = ItemType::File;
				Items.push_back(item);
			}
		}

		CoTaskMemFree(pidlChild);
		pidlChild = NULL;

	#pragma warning(suppress: 4127)
	}while (1);

	if (pidlChild)
		CoTaskMemFree(pidlChild);
	pEnumIDList->Release();
}