CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Common/File/PathBrowser.h
Views: 1401
#pragma once12#include <condition_variable>3#include <mutex>4#include <string>5#include <cstring>6#include <thread>7#include <vector>8#include <cstdlib>910#include "Common/File/DirListing.h"11#include "Common/File/Path.h"1213// Abstraction above path that lets you navigate easily.14// "/" is a special path that means the root of the file system. On Windows,15// listing this will yield drives.16class PathBrowser {17public:18PathBrowser() {}19~PathBrowser();2021void SetPath(const Path &path);22void Refresh() {23HandlePath();24}25bool IsListingReady() const {26return ready_;27}28bool GetListing(std::vector<File::FileInfo> &fileInfo, const char *filter = nullptr, bool *cancel = nullptr);2930bool CanNavigateUp();31void NavigateUp();3233void Navigate(const std::string &subdir);3435const Path &GetPath() const {36return path_;37}38std::string GetFriendlyPath() const;3940void SetUserAgent(const std::string &s) {41userAgent_ = s;42}43void SetRootAlias(const std::string &alias, const Path &rootPath) {44aliasDisplay_ = alias;45aliasMatch_ = rootPath;46}47void RestrictToRoot(const Path &root);48bool empty() const {49return path_.empty();50}51bool Success() const {52return success_;53}5455private:56void HandlePath();57void ResetPending();58void ApplyRestriction();5960Path path_;61Path pendingPath_;62Path restrictedRoot_;63std::string userAgent_;64std::string aliasDisplay_;65Path aliasMatch_;66std::vector<File::FileInfo> pendingFiles_;67std::condition_variable pendingCond_;68std::mutex pendingLock_;69std::thread pendingThread_;70bool pendingActive_ = false;71bool pendingCancel_ = false;72bool pendingStop_ = false;73bool ready_ = false;74bool success_ = true;75};76777879