37using namespace std::string_literals;
46bool IsWindowsLink(
const std::string &path)
48 return (path.length() > 4) && (path.rfind(
".lnk") == path.length() - 4);
76 if (IsWindowsLink(
fPath)) {
78 if (realWinPath)
fPath = realWinPath;
79 delete [] realWinPath;
89 auto hFile = CreateFile(
fPath.c_str(),
94 FILE_FLAG_BACKUP_SEMANTICS,
100 auto dwRet = GetFinalPathNameByHandle( hFile, path,
BUFSIZE, VOLUME_NAME_DOS );
102 if ((dwRet > 0) && (dwRet <
BUFSIZE))
103 if ((path[0] ==
'\\') && (path[1] ==
'\\') && (path[2] ==
'?') && (path[3] ==
'\\')) {
136 std::string path =
fPath;
138 const char *
slash =
"\\";
140 const char *
slash =
"/";
142 if (path.rfind(
slash) != path.length() - 1)
150 auto testname =
name;
157 if (pathinfores && !IsWindowsLink(path)) {
158 std::string lpath = path +
".lnk";
160 if (!pathinfores) testname.append(
".lnk");
201 std::string sname =
name;
203 if ((sname ==
".") || (sname ==
".."))
215 auto pos = fname.rfind(
".");
216 if ((pos != std::string::npos) && (pos < fname.length() - 1) && (pos > 0))
217 return fname.substr(pos+1);
229 bool Find(
const std::string &
name,
int = -1)
override
269 item->SetIcon(
"sap-icon://folder-blank"s);
274 item->SetSize(item->size);
277 time_t loctime = (time_t) item->modtime;
278 struct tm *newtime = localtime(&loctime);
280 snprintf(tmp,
sizeof(tmp),
"%d-%02d-%02d %02d:%02d", newtime->tm_year + 1900,
281 newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour,
285 item->SetMTime(
"1901-01-01 00:00");
289 snprintf(tmp,
sizeof(tmp),
"%c%c%c%c%c%c%c%c%c%c",
304 ((item->type &
kS_IRUSR) ?
'r' :
'-'),
305 ((item->type &
kS_IWUSR) ?
'w' :
'-'),
307 ((item->type &
kS_IRGRP) ?
'r' :
'-'),
308 ((item->type &
kS_IWGRP) ?
'w' :
'-'),
310 ((item->type &
kS_IROTH) ?
'r' :
'-'),
311 ((item->type &
kS_IWOTH) ?
'w' :
'-'),
321 item->SetUid(std::to_string(item->uid));
322 item->SetGid(std::to_string(item->gid));
336 if (elem)
return elem;
355 std::string
name = fname;
356 std::transform(
name.begin(),
name.end(),
name.begin(), ::tolower);
359 return (
name.length() > suffix.length()) ? (0 ==
name.compare (
name.length() - suffix.length(), suffix.length(), suffix)) :
false;
367 return "sap-icon://document-text"s;
370 return "sap-icon://picture"s;
372 return "sap-icon://org-chart"s;
374 return "sap-icon://document"s;
392 auto pos =
fFileName.find_last_of(
"\\/");
393 if ((pos != std::string::npos) && (pos <
fFileName.length() - 1)) {
403 : fStat(stat), fDirName(dirname), fFileName(
filename)
424 return std::equal(
name.begin(),
name.end(),
425 ownname.begin(), ownname.end(),
427 return tolower(a) == tolower(b);
431 return ownname ==
name;
445 if (icon ==
"sap-icon://document-text"s)
return kActEdit;
446 if (icon ==
"sap-icon://picture"s)
return kActImage;
447 if (icon ==
"sap-icon://org-chart"s)
return kActBrowse;
467 return std::make_unique<RSysDirLevelIter>(
GetFullName());
477 return std::string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
482 std::string content = std::string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
486 auto pos =
GetName().rfind(
".");
488 std::string image_kind =
GetName().substr(pos+1);
489 std::transform(image_kind.begin(), image_kind.end(), image_kind.begin(), ::tolower);
490 if (image_kind ==
"svg") image_kind =
"svg+xml";
492 return "data:image/"s + image_kind +
";base64,"s + encode.Data();
509 std::string seldir = workdir;
521 while ((obj = iter()) !=
nullptr) {
523 std::string dir =
name +
"\\"s;
524 comp->Add(std::make_shared<Browsable::RWrapper>(
name, std::make_unique<RSysFile>(dir)));
529 comp->Add(std::make_shared<Browsable::RWrapper>(
"File system", std::make_unique<RSysFile>(
"/")));
531 seldir =
"/File system"s + seldir;
535 if (!homedir.empty())
536 comp->Add(std::make_shared<Browsable::RWrapper>(
"Home", std::make_unique<RSysFile>(homedir)));
547 std::string seldir = workdir;
558 seldir =
"/File system"s + seldir;
#define R__LOG_ERROR(...)
#define R__LOG_DEBUG(DEBUGLEVEL,...)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
#define INVALID_HANDLE_VALUE
Bool_t R_ISFIFO(Int_t mode)
Bool_t R_ISSOCK(Int_t mode)
Bool_t R_ISBLK(Int_t mode)
Bool_t R_ISREG(Int_t mode)
Bool_t R_ISDIR(Int_t mode)
R__EXTERN TSystem * gSystem
Bool_t R_ISCHR(Int_t mode)
static EContentKind GetContentKind(const std::string &kind)
Find item with specified name Default implementation, should work for all.
@ kFileName
"filename" - file name if applicable
@ kText
"text" - plain text for code editor
@ kImage
"image64" - base64 for supported image formats (png/gif/gpeg)
EActionKind
Possible actions on double-click.
@ kActImage
can be shown in image viewer, can provide image
@ kActBrowse
just browse (expand) item
@ kActEdit
can provide data for text editor
static RElementPath_t ParsePath(const std::string &str)
Parse string path to produce RElementPath_t One should avoid to use string pathes as much as possible...
Iterator over single level hierarchy like any array, keys list, ...
static bool IsFileFormatSupported(const std::string &extension)
static std::shared_ptr< RElement > OpenFile(const std::string &extension, const std::string &fullname)
Iterator over files in in sub-directory.
~RSysDirLevelIter() override
void * fDir
! current directory handle
FileStat_t fCurrentStat
! stat for current file name
bool Find(const std::string &name, int=-1) override
Find item with specified name Default implementation, should work for all If index specified,...
std::string fItemName
! current item name
void CloseDir()
Close directory for listing.
std::string GetFileExtension(const std::string &fname) const
std::string FullDirName() const
Return full dir name with appropriate slash at the end.
std::shared_ptr< RElement > GetElement() override
Returns full information for current element.
bool TestDirEntry(const std::string &name)
Check if entry of that name exists.
std::string fCurrentName
! current file name
RSysDirLevelIter(const std::string &path="")
std::string fPath
! fully qualified path without final slash
std::unique_ptr< RItem > CreateItem() override
Create generic description item for RBrowser.
bool OpenDir()
Open directory for listing.
bool NextDirEntry()
Trying to produce next entry.
bool Next() override
Shift to next entry.
bool CanItemHaveChilds() const override
Returns true if directory or is file format supported.
std::string GetItemName() const override
Returns current entry name
std::string GetFullName() const
Returns full file name - including fully qualified path.
std::unique_ptr< RLevelIter > GetChildsIter() override
Returns iterator for files in directory.
std::string fDirName
! fully-qualified directory name
FileStat_t fStat
! file stat object
RSysFile(const std::string &filename)
Create file element.
std::string GetName() const override
Name of RElement - file name in this case.
static std::string GetFileIcon(const std::string &fname)
Get icon for the type of given file name.
EActionKind GetDefaultAction() const override
Get default action for the file Either start text editor or image viewer or just do file browsing.
std::string GetContent(const std::string &kind) override
Returns file content of requested kind.
static RElementPath_t ProvideTopEntries(std::shared_ptr< RGroup > &comp, const std::string &workdir="")
Provide top entries for file system On windows it is list of existing drivers, on Linux it is "File s...
bool MatchName(const std::string &name) const override
Checks if element name match to provided value.
std::string fFileName
! file name in current dir
static RElementPath_t GetWorkingPath(const std::string &workdir="")
Return working path in browser hierarchy.
static TString Encode(const char *data)
Transform data into a null terminated base64 string.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
const char * Data() const
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
virtual void FreeDirectory(void *dirp)
Free a directory.
virtual void * OpenDirectory(const char *name)
Open a directory.
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
virtual TList * GetVolumes(Option_t *) const
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
virtual const char * WorkingDirectory()
Return working directory.
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
virtual const char * GetError()
Return system error string.
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
std::vector< std::string > RElementPath_t
bool EndsWith(std::string_view string, std::string_view suffix)
ROOT::RLogChannel & BrowsableLog()
Log channel for Browsable diagnostics.