void cPiston::ExtendPiston(int pistx, int pisty, int pistz) { BLOCKTYPE pistonBlock; NIBBLETYPE pistonMeta; m_World->GetBlockTypeMeta(pistx, pisty, pistz, pistonBlock, pistonMeta); if (IsExtended(pistonMeta)) { // Already extended, bail out return; } int dist = FirstPassthroughBlock(pistx, pisty, pistz, pistonMeta); if (dist < 0) { // FirstPassthroughBlock says piston can't push anything, bail out return; } m_World->BroadcastBlockAction(pistx, pisty, pistz, 0, pistonMeta, pistonBlock); m_World->BroadcastSoundEffect("tile.piston.out", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f); // Drop the breakable block in the line, if appropriate: AddDir(pistx, pisty, pistz, pistonMeta, dist + 1); // "pist" now at the breakable / empty block BLOCKTYPE currBlock; NIBBLETYPE currMeta; m_World->GetBlockTypeMeta(pistx, pisty, pistz, currBlock, currMeta); if (currBlock != E_BLOCK_AIR) { cBlockHandler * Handler = BlockHandler(currBlock); if (Handler->DoesDropOnUnsuitable()) { cChunkInterface ChunkInterface(m_World->GetChunkMap()); cBlockInServerPluginInterface PluginInterface(*m_World); Handler->DropBlock(ChunkInterface, *m_World, PluginInterface, NULL, pistx, pisty, pistz); } } // Push blocks, from the furthest to the nearest: int oldx = pistx, oldy = pisty, oldz = pistz; NIBBLETYPE currBlockMeta; for (int i = dist + 1; i > 1; i--) { AddDir(pistx, pisty, pistz, pistonMeta, -1); m_World->GetBlockTypeMeta(pistx, pisty, pistz, currBlock, currBlockMeta); m_World->QueueSetBlock( oldx, oldy, oldz, currBlock, currBlockMeta, PISTON_TICK_DELAY); oldx = pistx; oldy = pisty; oldz = pistz; } int extx = pistx; int exty = pisty; int extz = pistz; AddDir(pistx, pisty, pistz, pistonMeta, -1); // "pist" now at piston body, "ext" at future extension m_World->SetBlock(pistx, pisty, pistz, pistonBlock, pistonMeta | 0x8); m_World->QueueSetBlock(extx, exty, extz, E_BLOCK_PISTON_EXTENSION, pistonMeta | (IsSticky(pistonBlock) ? 8 : 0), PISTON_TICK_DELAY); }
void DataDirLocater::AddDirs(const std::string& in) { size_t prev_colon = 0, colon; while ((colon = in.find(cPD, prev_colon)) != std::string::npos) { // cPD (depending on OS): ';' or ':' AddDir(in.substr(prev_colon, colon - prev_colon)); prev_colon = colon + 1; } AddDir(in.substr(prev_colon)); }
void DataDirLocater::AddDirs(const std::string& dirs) { if (dirs.empty()) return; size_t prev_colon = 0; size_t colon; while ((colon = dirs.find(cPD, prev_colon)) != std::string::npos) { // cPD (depending on OS): ';' or ':' AddDir(dirs.substr(prev_colon, colon - prev_colon)); prev_colon = colon + 1; } AddDir(dirs.substr(prev_colon)); }
void cPiston::RetractPiston(int pistx, int pisty, int pistz) { BLOCKTYPE pistonBlock; NIBBLETYPE pistonMeta; m_World->GetBlockTypeMeta(pistx, pisty, pistz, pistonBlock, pistonMeta); if (!IsExtended(pistonMeta)) { // Already retracted, bail out return; } // Check the extension: AddDir(pistx, pisty, pistz, pistonMeta, 1); if (m_World->GetBlock(pistx, pisty, pistz) != E_BLOCK_PISTON_EXTENSION) { LOGD("%s: Piston without an extension - still extending, or just in an invalid state?", __FUNCTION__); return; } AddDir(pistx, pisty, pistz, pistonMeta, -1); m_World->SetBlock(pistx, pisty, pistz, pistonBlock, pistonMeta & ~(8)); m_World->BroadcastBlockAction(pistx, pisty, pistz, 1, pistonMeta & ~(8), pistonBlock); m_World->BroadcastSoundEffect("tile.piston.in", pistx * 8, pisty * 8, pistz * 8, 0.5f, 0.7f); AddDir(pistx, pisty, pistz, pistonMeta, 1); // Retract the extension, pull block if appropriate if (IsSticky(pistonBlock)) { int tempx = pistx, tempy = pisty, tempz = pistz; AddDir(tempx, tempy, tempz, pistonMeta, 1); BLOCKTYPE tempBlock; NIBBLETYPE tempMeta; m_World->GetBlockTypeMeta(tempx, tempy, tempz, tempBlock, tempMeta); if (CanPull(tempBlock, tempMeta)) { // Pull the block m_World->QueueSetBlock(pistx, pisty, pistz, tempBlock, tempMeta, PISTON_TICK_DELAY); m_World->QueueSetBlock(tempx, tempy, tempz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY); } else { // Retract without pulling m_World->QueueSetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY); } } else { m_World->QueueSetBlock(pistx, pisty, pistz, E_BLOCK_AIR, 0, PISTON_TICK_DELAY); } }
void CPpcMainWnd::OnFileFind() { m_fNoListRedraw = TRUE; SendMessage(m_hwndLV, WM_SETREDRAW, 0, 0); CPpcFolderDlg dlg; TCHAR szPath[MAX_PATH] = {0}; dlg.SetSubFolder(((CPpcOptions*)m_pOptions)->m_fSearchSubFolders); if (dlg.ShowFolderDlg(m_hWnd, szPath, MAX_PATH) != IDCANCEL) { ((CPpcOptions*)m_pOptions)->m_fSearchSubFolders = dlg.GetSubFolder(); _tcscpy(((CPpcOptions*)m_pOptions)->m_szLastDir, szPath); AddDir(szPath); if (m_pPlayListDlg) m_pPlayListDlg->UpdatePlayList(); } SendMessage(m_hwndLV, WM_SETREDRAW, 1, 0); m_fNoListRedraw = FALSE; InvalidateRect(m_hwndLV, NULL, FALSE); UpdateWindow(m_hwndLV); }
void InputList::addFolderSlot() { QString directory = QFileDialog::getExistingDirectory( this, "Select directory", _lastDirectory ); if (directory.isEmpty()) return; //for each file in directory ( non-recursive, add it do thelist ) AddDir(directory); }
void CMainWnd::OnFileFind() { TCHAR szPath[MAX_PATH] = {0}; #ifdef _WIN32_WCE CFolderDlg dlg; dlg.SetSubFolder(m_pOptions->m_fSearchSubFolders); if (dlg.ShowFolderDlg(m_hWnd, szPath, MAX_PATH) == IDCANCEL) return; m_pOptions->m_fSearchSubFolders = dlg.GetSubFolder(); #else CTempStr strTitle(IDS_TITLE_FIND_FILE); //フォルダ選択ダイアログの表示 LPMALLOC pmalloc; LPITEMIDLIST lPIDL; LPITEMIDLIST pIDL; if (SUCCEEDED(SHGetMalloc(&pmalloc))) { if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &lPIDL))) { TCHAR szBuff[MAX_PATH]; _tcscpy(szBuff, m_pOptions->m_szLastDir); BROWSEINFO binfo = {0}; binfo.hwndOwner = m_hWnd; binfo.lpszTitle = strTitle; binfo.pidlRoot = lPIDL; binfo.pszDisplayName = szBuff; binfo.ulFlags = BIF_RETURNONLYFSDIRS; pIDL = SHBrowseForFolder(&binfo); if (pIDL) SHGetPathFromIDList(pIDL, szPath); pmalloc->Free(pIDL); } pmalloc->Release(); } if (!_tcslen(szPath)) return; #endif _tcscpy(m_pOptions->m_szLastDir, szPath); AddDir(szPath); if (m_pPlayListDlg) m_pPlayListDlg->UpdatePlayList(); }
int cPiston::FirstPassthroughBlock(int pistonX, int pistonY, int pistonZ, NIBBLETYPE pistonmeta) { // Examine each of the 12 blocks ahead of the piston: for (int ret = 0; ret < 12; ret++) { BLOCKTYPE currBlock; NIBBLETYPE currMeta; AddDir(pistonX, pistonY, pistonZ, pistonmeta, 1); m_World->GetBlockTypeMeta(pistonX, pistonY, pistonZ, currBlock, currMeta); if (CanBreakPush(currBlock, currMeta)) { // This block breaks when pushed, extend up to here return ret; } if (!CanPush(currBlock, currMeta)) { // This block cannot be pushed at all, the piston can't extend return -1; } } // There is no space for the blocks to move, piston can't extend return -1; }
// // AddStartDir // static void AddStartDir(Wad *wadRoot, Core::String wadName, Core::DirStream *dir, Core::String nameHead, std::pair<Core::String, Core::String> nameTail) { SubWadTemp wad{wadRoot, wadName}; while(dir->next()) { Core::String name = GetNameFromFile(dir->getStrPart()); char const *path = dir->getStrFull(); if(Core::IsDir(path)) { if(IsNameStart(name)) AddStartDir(wad, name, Core::DirOpenStream(path).get(), name, GetNameEnd(name)); else AddDir(wad, name, Core::DirOpenStream(path).get()); } else { Lump *lump = new Lump_File{name, Core::StrDup(path)}; if(name == nameTail.first || name == nameTail.second) wad.wadLump->tail.reset(lump); else if(name == nameHead) wad.wadLump->head.reset(lump); else wad->addLump(lump); } } if(!wad.wadLump->head) wad.wadLump->head.reset(new Lump_Empty{nameHead}); if(!wad.wadLump->tail) wad.wadLump->tail.reset(new Lump_Empty{nameTail.first}); wad.finish(); }
void wxPlaylist::OnAddDirRec(wxCommandEvent &WXUNUSED(event)) { AddDir(1); }
CMPath::CMPath(DEF_TYPE nDefType) { switch(nDefType) { // case CONF_PATH://用户配置文件路径 // { // #ifdef PLAT_SYMBIAN // TBuf<256> sApp; // CCoeEnv::Static()->FsSession().PrivatePath(sApp); // #ifdef __WINSCW__ // sApp.Insert( 0, _L("C:") ); // #else // sApp.Insert( 0, CEikonEnv::Static()->EikAppUi()->Application()->AppFullName().Left(2) ); // #endif // m_sPath =(const WCHAR*)sApp.PtrZ(); // BaflUtils::EnsurePathExistsL(CCoeEnv::Static()->FsSession(), sApp); // #else //WCHAR sApp[256]=L"0"; //::GetModuleFileName(NULL, sApp, 256); //for(INT32 i=wcslen(sApp)-1;i>0;i--) //{ // if(sApp[i]==L'\\') // { // sApp[i+1]=L'\0'; // break; // } //} //m_sPath = sApp; // #endif // //CMString sID; // //if(CMGlobal::TheOne().GetSessionID(sID) && !(SETTING.m_sName.IsEmpty())) // // AddDir(SETTING.m_sName + L"\\"); // break; // } case SYS_CONF_PATH://系统配置文件路径 case DATA_PATH://数据路径 case APP_PATH: { #ifdef PLAT_SYMBIAN TBuf<256> sApp; CCoeEnv::Static()->FsSession().PrivatePath(sApp); #ifdef __WINSCW__ sApp.Insert( 0, _L("C:") ); #else sApp.Insert( 0, CEikonEnv::Static()->EikAppUi()->Application()->AppFullName().Left(2) ); #endif m_sPath =(const WCHAR*)sApp.PtrZ(); BaflUtils::EnsurePathExistsL(CCoeEnv::Static()->FsSession(), sApp); #else WCHAR sApp[256]=L"0"; ::GetModuleFileName(NULL, sApp, 256); for(INT32 i=wcslen(sApp)-1;i>0;i--) { if(sApp[i]==L'\\') { sApp[i+1]=L'\0'; break; } } m_sPath = sApp; #endif break; } case TEMP_PATH: { m_sPath = CMPath::CMPath(DATA_PATH).String(); CMString stmp = L"tmp"; stmp += FILESEPARATOR; AddDir(stmp); break; } case DOWNLOAD_PATH: { m_sPath = CMPath::CMPath(CARD_PATH).String(); if(!m_sPath.IsEmpty()) { CMString stmp = L"download"; stmp += FILESEPARATOR; AddDir(stmp); } break; } case CARD_PATH://存储卡根目录 { #ifdef PLAT_SYMBIAN TBuf<30> mmcPath; mmcPath=PathInfo::MemoryCardRootPath(); RFs iFs2; User::LeaveIfError(iFs2.Connect()); if (iFs2.CheckDisk(mmcPath) == KErrNone) m_sPath =(const WCHAR*)mmcPath.PtrZ(); else m_sPath = CMPath::CMPath(DATA_PATH).String(); #else HANDLE hFlashCard; WIN32_FIND_DATA lpwfdFlashCard; hFlashCard = FindFirstFlashCard(&lpwfdFlashCard); if (hFlashCard != INVALID_HANDLE_VALUE) { if(lpwfdFlashCard.cFileName[0] != '\\') m_sPath = L"\\"; m_sPath += lpwfdFlashCard.cFileName; if(m_sPath[m_sPath.GetLength()-1] != '\\') m_sPath += L"\\"; } else m_sPath = CMPath::CMPath(DATA_PATH).String(); FindClose (hFlashCard); // Close the search handle. #endif break; } case WSYS_PATH://系统盘根目录 { #ifdef PLAT_SYMBIAN m_sPath = L"c:\\"; #else m_sPath = L"\\"; #endif break; } default: break; } }
CMPath::CMPath(DEF_TYPE nDefType) { switch(nDefType) { /* 该功能放到CMGlobal中 case CONF_PATH://用户配置文件路径 { m_sPath = CMPath(DATA_PATH).String(); CMString sID; if(CMGlobal::TheOne().GetSessionID(sID) && !(CMSettings::GetInstance().m_sName.IsEmpty())) AddDir(CMSettings::GetInstance().m_sName + L"/"); break; }*/ case SYS_CONF_PATH://系统配置文件路径 case DATA_PATH://数据路径 { /* char buf[260]; memset(buf,0,260); int ret = readlink("proc/self/exe", buf, 260); if(ret < 0 || ret >= 1024) break; for(INT32 i=strlen(buf)-1;i>0;i--) { if(buf[i]=='/') { buf[i+1]=L'\0'; break; } }*/ //CM_ERRP("DATA_PATH%s",buf); JNIEnv* env ; if (GetJavaVM()->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) return ; jmethodID method = env->GetStaticMethodID(GetGlobalCls(), "getInstance", "()Lcom/wunding/mlplayer/CMGlobal;"); if(!method) return; jobject obj = (jobject)env->CallStaticObjectMethod(GetGlobalCls(), method); if(!obj) return; method = env->GetMethodID(GetGlobalCls(), "GetDataDir", "()Ljava/lang/String;"); const char * buf = NULL; if(method) { jstring jstr = (jstring)env->CallObjectMethod(obj, method); if(jstr) { buf = env->GetStringUTFChars(jstr, NULL); m_sPath = buf; if(buf) env->ReleaseStringUTFChars(jstr, buf); } } m_sPath += L"/"; //CM_ERRP("DATA_PATH:%s",(const char*)m_sPath); break; } case TEMP_PATH: { m_sPath = CMPath(DATA_PATH).String(); AddDir(L"tmp/"); break; } case DOWNLOAD_PATH: { m_sPath = CMPath(DATA_PATH).String(); if(!m_sPath.IsEmpty()) AddDir(L"dld/"); break; // m_sPath = CMPath(CARD_PATH).String(); // if(!m_sPath.IsEmpty()){ // AddDir(L"wunding_ulp/"); // } // break; } case DOWNLOAD_OLD: { m_sPath = CMPath(CARD_PATH).String()+L"wunding_ulp/"; break; } case UNZIP_PATH: //下载课件解压缩后目录 { m_sPath = CMPath::CMPath(DOWNLOAD_PATH).String(); if (!m_sPath.IsEmpty()) { AddDir(L"download/"); } break; } case APP_PATH: { m_sPath = CMPath(DATA_PATH).String(); break; } case CARD_PATH://存储卡根目录 { JNIEnv* env ; if (GetJavaVM()->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) return ; jclass cls = (jclass)env->FindClass("android/os/Environment"); if(!cls) return; jmethodID method = env->GetStaticMethodID(cls, "getExternalStorageDirectory", "()Ljava/io/File;"); if(!method) return; jobject obj = (jobject)env->CallStaticObjectMethod(cls, method); if(!obj) return; cls = (jclass)env->FindClass("java/io/File"); if(!cls) return; method = env->GetMethodID(cls, "getPath", "()Ljava/lang/String;"); if(!method) return; const char * buf = NULL; if(method) { jstring jstr = (jstring)env->CallObjectMethod(obj, method); if(jstr) { buf = env->GetStringUTFChars(jstr, NULL); m_sPath = buf; if(buf) env->ReleaseStringUTFChars(jstr, buf); } } m_sPath += L"/"; break; } case WSYS_PATH://系统盘根目录 { m_sPath = L"/"; break; } default: break; } }
void Playlist::OnPlAddDirRec() { AddDir(GF_TRUE); }
void Playlist::OnPlAddDir() { AddDir(GF_FALSE); }
void Playlist::OnPlAddDir() { AddDir(0); }
void DataDirLocater::AddCurWorkDir() { AddDir(Platform::GetOrigCWD()); }
// Enumerate the MFT for all entries. Store the file reference numbers of // any directories in the database. void CDriveIndex::PopulateIndex() { Empty(); vector<DWORDLONG> FileParents; vector<DWORDLONG> DirectoryParents; USN_JOURNAL_DATA ujd; Query(&ujd); // Get the FRN of the root directory // This had BETTER work, or we can't do anything WCHAR szRoot[_MAX_PATH]; wsprintf(szRoot, TEXT("%c:\\"), m_cDrive); HANDLE hDir = CreateFile(szRoot, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); BY_HANDLE_FILE_INFORMATION fi; GetFileInformationByHandle(hDir, &fi); CloseHandle(hDir); DWORDLONG IndexRoot = (((DWORDLONG) fi.nFileIndexHigh) << 32) | fi.nFileIndexLow; wsprintf(szRoot, TEXT("%c:"), m_cDrive); AddDir(IndexRoot, &wstring(szRoot), 0); DirectoryParents.insert(DirectoryParents.end(), 0); m_dwDriveFRN = IndexRoot; MFT_ENUM_DATA med; med.StartFileReferenceNumber = 0; med.LowUsn = 0; med.HighUsn = ujd.NextUsn; // Process MFT in 64k chunks BYTE pData[sizeof(DWORDLONG) + 0x10000]; DWORDLONG fnLast = 0; DWORD cb; unsigned int num = 0; unsigned int numDirs = 1; while (DeviceIoControl(m_hVol, FSCTL_ENUM_USN_DATA, &med, sizeof(med), pData, sizeof(pData), &cb, NULL) != FALSE) { PUSN_RECORD pRecord = (PUSN_RECORD) &pData[sizeof(USN)]; while ((PBYTE) pRecord < (pData + cb)) { if ((pRecord->FileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) numDirs++; else num++; pRecord = (PUSN_RECORD) ((PBYTE) pRecord + pRecord->RecordLength); } med.StartFileReferenceNumber = * (DWORDLONG *) pData; } FileParents.reserve(num); DirectoryParents.reserve(numDirs); rgFiles.reserve(num); rgDirectories.reserve(numDirs); hash_map<DWORDLONG, HashMapEntry> hmFiles; hash_map<DWORDLONG, HashMapEntry> hmDirectories; hash_map<DWORDLONG, HashMapEntry>::iterator it; med.StartFileReferenceNumber = 0; while (DeviceIoControl(m_hVol, FSCTL_ENUM_USN_DATA, &med, sizeof(med), pData, sizeof(pData), &cb, NULL) != FALSE) { PUSN_RECORD pRecord = (PUSN_RECORD) &pData[sizeof(USN)]; while ((PBYTE) pRecord < (pData + cb)) { wstring sz((LPCWSTR) ((PBYTE) pRecord + pRecord->FileNameOffset), pRecord->FileNameLength / sizeof(WCHAR)); if ((pRecord->FileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { AddDir(pRecord->FileReferenceNumber, &sz, pRecord->ParentFileReferenceNumber); //DirectoryParents.insert(DirectoryParents.end(), pRecord->ParentFileReferenceNumber); HashMapEntry hme; hme.iOffset = rgDirectories.size() - 1; hme.ParentFRN = pRecord->ParentFileReferenceNumber; hmDirectories[pRecord->FileReferenceNumber] = hme; } else { Add(pRecord->FileReferenceNumber, &sz, pRecord->ParentFileReferenceNumber); HashMapEntry hme; hme.iOffset = rgFiles.size() - 1; hme.ParentFRN = pRecord->ParentFileReferenceNumber; //FileParents.insert(FileParents.end(), pRecord->ParentFileReferenceNumber); hmFiles[pRecord->FileReferenceNumber] = hme; } pRecord = (PUSN_RECORD) ((PBYTE) pRecord + pRecord->RecordLength); } med.StartFileReferenceNumber = * (DWORDLONG *) pData; } //Calculate files per directory. This takes most of the indexing time, but this information can be useful to reduce the time needed //for searching in directories with few files (less than 10k). for ( it=hmFiles.begin() ; it != hmFiles.end(); it++ ) { HashMapEntry* hme = &hmDirectories[it->second.ParentFRN]; do { rgDirectories[hme->iOffset].nFiles++; HashMapEntry* hme2 = &hmDirectories[it->second.ParentFRN]; if(hme != hme2) hme = hme2; else // This must not happen, otherwise a directory is its own parent! break; } while(hme->ParentFRN != 0); } //for(unsigned int i = 0; i != FileParents.size(); i++) //{ // DWORDLONG dwIndex = FileParents[i]; // while(dwIndex != 0) // { // int iOffset = -1; // for(unsigned int j = 0; j != rgDirectories.size(); j++) // if(rgDirectories[j].Index == dwIndex) // { // iOffset = j; // break; // } // if(iOffset == -1) // break; // rgDirectories[iOffset].nFiles++; // DWORDLONG dwIndex2 = DirectoryParents[iOffset]; // if(dwIndex != dwIndex2) // dwIndex = dwIndex2; // else // This must not happen, otherwise a directory is its own parent! // break; // } // //wstring strPath; // //GetDir(dwIndex, &strPath); // //do { // // //USNEntry file = FRNToName(dwIndex); // // int iOffset = -1; // // for(int j = 0; j != rgDirectories.size(); j++) // // if(rgDirectories[j].Index == dwIndex) // // { // // iOffset = j; // // break; // // } // // if(iOffset == -1) // // break; // // //USNEntry parent = FRNToName(file.ParentIndex); // // //USNEntry parent2 = FRNToName(rgDirectories[iOffset].Index); // // rgDirectories[iOffset].nFiles++; // // dwIndex = file.ParentIndex; // //} while (dwIndex != 0); //} rgFiles.shrink_to_fit(); rgDirectories.shrink_to_fit(); sort(rgFiles.begin(), rgFiles.end()); sort(rgDirectories.begin(), rgDirectories.end()); }
void Playlist::OnPlAddDirRec() { AddDir(1); }