MCPcopy Create free account
hub / github.com/chrxh/alien / FileDialog

Method FileDialog

external/ImFileDialog/ImFileDialog.cpp:349–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

347 }
348
349 FileDialog::FileDialog() {
350 m_isOpen = false;
351 m_type = 0;
352 m_calledOpenPopup = false;
353 m_sortColumn = 0;
354 m_sortDirection = ImGuiSortDirection_Ascending;
355 m_filterSelection = 0;
356 m_inputTextbox[0] = 0;
357 m_pathBuffer[0] = 0;
358 m_searchBuffer[0] = 0;
359 m_newEntryBuffer[0] = 0;
360 m_selectedFileItem = -1;
361 m_zoom = 1.0f;
362
363 m_previewLoader = nullptr;
364 m_previewLoaderRunning = false;
365
366 m_setDirectory(std::filesystem::current_path(), false);
367
368 // favorites are available on every OS
369 FileTreeNode* quickAccess = new FileTreeNode("Quick Access");
370 quickAccess->Read = true;
371 m_treeCache.push_back(quickAccess);
372
373#ifdef _WIN32
374 char username[UNLEN + 1] = { 0 };
375 DWORD username_len = UNLEN + 1;
376 GetUserNameA(username, &username_len);
377
378 std::string userPath = "C:\\Users\\" + std::string(username) + "\\";
379
380 // Quick Access / Bookmarks
381 quickAccess->Children.push_back(new FileTreeNode(userPath + "Desktop"));
382 quickAccess->Children.push_back(new FileTreeNode(userPath + "Documents"));
383 quickAccess->Children.push_back(new FileTreeNode(userPath + "Downloads"));
384 quickAccess->Children.push_back(new FileTreeNode(userPath + "Pictures"));
385
386 // OneDrive
387 FileTreeNode* oneDrive = new FileTreeNode(userPath + "OneDrive");
388 m_treeCache.push_back(oneDrive);
389
390 // This PC
391 FileTreeNode* thisPC = new FileTreeNode("This PC");
392 thisPC->Read = true;
393 if (std::filesystem::exists(userPath + "3D Objects"))
394 thisPC->Children.push_back(new FileTreeNode(userPath + "3D Objects"));
395 thisPC->Children.push_back(new FileTreeNode(userPath + "Desktop"));
396 thisPC->Children.push_back(new FileTreeNode(userPath + "Documents"));
397 thisPC->Children.push_back(new FileTreeNode(userPath + "Downloads"));
398 thisPC->Children.push_back(new FileTreeNode(userPath + "Music"));
399 thisPC->Children.push_back(new FileTreeNode(userPath + "Pictures"));
400 thisPC->Children.push_back(new FileTreeNode(userPath + "Videos"));
401 DWORD d = GetLogicalDrives();
402 for (int i = 0; i < 26; i++)
403 if (d & (1 << i))
404 thisPC->Children.push_back(new FileTreeNode(std::string(1, 'A' + i) + ":"));
405 m_treeCache.push_back(thisPC);
406#else

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected