//------------------------------------------------------------- // Post : Return TRUE if a new match found // Task : Find the next file that meets the conditions specified // in the last FindFirst call //------------------------------------------------------------- bool CPath::FindNext() { if (m_hFindFile == NULL) return FALSE; WIN32_FIND_DATA FindData; while(FindNextFile(m_hFindFile,&FindData) != FALSE) { // while(FindNext(...)) if(AttributesMatch(m_dwFindFileAttributes,FindData.dwFileAttributes)) { // if(AttributesMatch(...) if((_A_SUBDIR & FindData.dwFileAttributes) == _A_SUBDIR) { if (IsDirectory()) { // Found a directory UpDirectory(); } else { SetNameExtension(""); } AppendDirectory(FindData.cFileName); } else { // Found a file if (IsDirectory()) { // Found a directory UpDirectory(); } SetNameExtension(FindData.cFileName); } if((_A_SUBDIR & FindData.dwFileAttributes) == _A_SUBDIR) EnsureTrailingBackslash(m_strPath); return TRUE; } } return FALSE; }
void updateFilebrowser() { if(kDown & KEY_SELECT) { currentViewer = new SettingsViewer(); currentViewer->Init(); } //Find a better way to cycle through these if(kDown & KEY_L) { switch(mode) { case SELECT: mode = DELETE; break; case DELETE: mode = COPY; break; case COPY: mode = PASTE; break; case PASTE: mode = SELECT; break; } } //Mode action if(kDown & KEY_X) { switch(mode) { case SELECT: { selectedEntries[(currentPath + entries[currentSelection]->name)] = !selectedEntries[(currentPath + entries[currentSelection]->name)]; printf("Toggled selection for: %s\n", (currentPath + entries[currentSelection]->name).c_str()); } break; } } if(kDown & KEY_UP) { //Easy fix until i'm bothered to fix the issue if(currentSelection < 0 | viewOffset < 0) { currentSelection = 0; viewOffset = 0; } if(viewOffset != 0) { viewOffset -= 1; currentSelection -= 1; } if(currentSelection != 0) { currentSelection -= 1; } } if(kDown & KEY_DOWN) { //Failsafe to prevent crashing if(currentSelection > entries.size()) { currentSelection = 0; viewOffset = 0; } if(currentSelection == 13 + viewOffset) { viewOffset += 1; } if(currentSelection != entries.size() - 1) { currentSelection += 1; } } if(kDown & KEY_A) { if(!entries[currentSelection]->isDirectory) { ViewFile(entries[currentSelection]->name); } else { OpenDirectory(entries[currentSelection]->name, true); } } if(kDown & KEY_B) { if(currentPath != "./") UpDirectory(); } }
void FileBrowser::CD(string folder) { //Mattie: quickfix going up to root... ftp '/' is converted to ':' if(strcmp(folder.c_str(), ":") == 0) { UpToRoot(); return; } if(strcmp(folder.c_str(), "..") == 0) { UpDirectory(); } else { /* if (folder.c_str()[0] != '\\') { folder = GetCurrentPath() */ if(folder.c_str()[0] == '/') { UpToRoot(); vector<string> splits; StringSplit(folder,"/",&splits); for(unsigned int x=0;x<splits.size();x++) { string f = splits.at(x); if(m_CurrentFolder.size() == 0) { if(f.c_str()[f.size()-1] != ':') { f = f + ":"; } } m_CurrentFolder.push_back(f); } } else { if (folder.substr(0,4).compare("smb:") == 0 || GetCurrentPath().substr(0,4).compare("smb:") == 0) { // if (folder.compare("smb:") == 0) { // DebugMsg("FileBrowser","Entering smb:"); // m_CurrentFolder.push_back(folder); // return; //} vector<string> splits; StringSplit(folder,"/",&splits); if(splits.size()>1) { UpToRoot(); for(unsigned int x=0;x<splits.size();x++) //Dont do the file { string f = splits.at(x); CD(f); } } else { DebugMsg("FileBrowser","Entering smb:"); m_CurrentFolder.push_back(folder); } return; } //mattie: quickfix: dont allow folders that dont exist, cut trailing backslash //// if it ends in :, add \ ie. "hdd1: -> hdd1:\" if (folder.substr(folder.length() - 1, 1) == ":") folder.append("\\"); //// if the folder doesn't exist and there's a : in it, return ie. hdd1:\foobar , but not foobar if (!fexists(folder) && (folder.find(":") != folder.npos)) return; // if (!FileExistsA(folder)) return; //// if the folder ends in \, remove the slash ie. hdd1:\foo\ -> hdd1:\foo, but also hdd1:\ -> hdd1: if (folder.compare("\\") == 0) { m_CurrentFolder.clear(); return; } if (folder.substr(folder.length() - 1, 1) == "\\") folder = folder.substr(0, folder.length() - 1); // if the folder ends in :, call UpToRoot() if (folder.substr(folder.length() - 1, 1) == ":") UpToRoot(); vector<string> splits; StringSplit(folder,"\\",&splits); if(splits.size()>1) { UpToRoot(); for(unsigned int x=0;x<splits.size();x++) //Dont do the file { string f = splits.at(x); CD(f); } } else { if(m_CurrentFolder.size() == 0) { if(folder.c_str()[folder.size()-1] != ':') { folder = folder + ":"; } } m_CurrentFolder.push_back(folder); } } } }