From 98536eb013b4945752b832a29bfb7b212cc881d5 Mon Sep 17 00:00:00 2001 From: aoleg94 Date: Tue, 21 Jun 2022 18:48:45 +0500 Subject: [PATCH 1/3] accept more http server listings, eg from darkhttpd --- source/remotefs/HTTPDir/HTTPDir.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/source/remotefs/HTTPDir/HTTPDir.cpp b/source/remotefs/HTTPDir/HTTPDir.cpp index bf53586..ed23289 100644 --- a/source/remotefs/HTTPDir/HTTPDir.cpp +++ b/source/remotefs/HTTPDir/HTTPDir.cpp @@ -67,13 +67,9 @@ void HTTPDir::DirList(std::string path,const std::vector &extension std::string s = chunk->memory; std::smatch sm; currentpath = path; - std::regex rgxdirlist("

Index of"); - if(!regex_search(s, sm, rgxdirlist)){ - return; - } - std::regex rgxlinks(".*?(?!Parent Directory)(.*?)<\/a>.*?<\/td><\/tr>"); + std::regex rgxlinks("(?!Parent Directory)(.*?)<\/a>"); while (regex_search(s, sm, rgxlinks)) { FS::FileEntry tmpentry; From 5bac2fa8aad36d66b3f6387484978c1e3539e8b4 Mon Sep 17 00:00:00 2001 From: aoleg94 Date: Tue, 21 Jun 2022 18:54:12 +0500 Subject: [PATCH 2/3] use http port if specified --- source/UI/networkBrowser.cpp | 6 +++--- source/remotefs/HTTPDir/HTTPDir.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/UI/networkBrowser.cpp b/source/UI/networkBrowser.cpp index d451439..81d64a7 100644 --- a/source/UI/networkBrowser.cpp +++ b/source/UI/networkBrowser.cpp @@ -191,7 +191,7 @@ namespace Windows { }else if (thislist[n].type == FS::FileEntryType::File){ - std::string openurl = thisurl.scheme + std::string("://") + thisurl.server + std::string("/") + httpdir->getCurrPath() + thislist[n].name; + std::string openurl = thisurl.scheme + std::string("://") + thisurl.server + (thisurl.port.empty() ? std::string() : ':' + thisurl.port) + std::string("/") + httpdir->getCurrPath() + thislist[n].name; std::string checkitemid = "##check" + std::to_string(n); ImGui::SetCursorPos({ImGui::GetCursorPos().x, ImGui::GetCursorPos().y + (40 - ImGui::GetFont()->FontSize - ImGui::GetStyle().FramePadding.y * 2) / 2}); if(ImGui::Checkbox(checkitemid.c_str(), httpdir->checked(n))){ @@ -219,7 +219,7 @@ namespace Windows { }else if (thislist[n].type == FS::FileEntryType::File){ urlschema thisurl = Utility::parseUrl(httpdir->getUrl()); - std::string openurl = thisurl.scheme + std::string("://") + thisurl.server + std::string("/") + httpdir->getCurrPath() + thislist[n].name; + std::string openurl = thisurl.scheme + std::string("://") + thisurl.server + (thisurl.port.empty() ? std::string() : ':' + thisurl.port) + std::string("/") + httpdir->getCurrPath() + thislist[n].name; item.laststate = item.state; playlist->clearPlaylist(); httpdir->clearChecked(); @@ -240,7 +240,7 @@ namespace Windows { ImVec4 textcolor = colors[ImGuiCol_Text]; if(sqlitedb != nullptr){ - std::string openurl = thisurl.scheme + std::string("://") + thisurl.server + std::string("/") + httpdir->getCurrPath() + thislist[n].name; + std::string openurl = thisurl.scheme + std::string("://") + thisurl.server + (thisurl.port.empty() ? std::string() : ':' + thisurl.port) + std::string("/") + httpdir->getCurrPath() + thislist[n].name; int dbfilestatus = sqlitedb->getFileDbStatus(openurl); if(dbfilestatus == 2){ textcolor = ImVec4(0.0f,1.0f,0.0f,1.0f); diff --git a/source/remotefs/HTTPDir/HTTPDir.cpp b/source/remotefs/HTTPDir/HTTPDir.cpp index ed23289..7304eda 100644 --- a/source/remotefs/HTTPDir/HTTPDir.cpp +++ b/source/remotefs/HTTPDir/HTTPDir.cpp @@ -61,7 +61,7 @@ HTTPDir::~HTTPDir(){ void HTTPDir::DirList(std::string path,const std::vector &extensions){ currentlist.clear(); urlschema thisurl = Utility::parseUrl(url); - std::string geturl = thisurl.scheme + std::string("://") + thisurl.server + std::string("/") + path; + std::string geturl = thisurl.scheme + std::string("://") + thisurl.server + (thisurl.port.empty() ? std::string() : ':' + thisurl.port) + std::string("/") + path; HTTPMemoryStruct *chunk = (HTTPMemoryStruct *)malloc(sizeof(HTTPMemoryStruct)); curlDownload((char *)geturl.c_str(),chunk); std::string s = chunk->memory; From bde4e6b6e603ca86050f35728e8680ae102b5820 Mon Sep 17 00:00:00 2001 From: aoleg94 Date: Tue, 21 Jun 2022 18:56:36 +0500 Subject: [PATCH 3/3] whitespace --- source/remotefs/HTTPDir/HTTPDir.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/remotefs/HTTPDir/HTTPDir.cpp b/source/remotefs/HTTPDir/HTTPDir.cpp index 7304eda..d3e80ce 100644 --- a/source/remotefs/HTTPDir/HTTPDir.cpp +++ b/source/remotefs/HTTPDir/HTTPDir.cpp @@ -68,8 +68,8 @@ void HTTPDir::DirList(std::string path,const std::vector &extension std::smatch sm; currentpath = path; - std::regex rgxlinks("(?!Parent Directory)(.*?)<\/a>"); + while (regex_search(s, sm, rgxlinks)) { FS::FileEntry tmpentry; @@ -133,4 +133,4 @@ void HTTPDir::backDir(){ currentpath = currentpath.substr(0, currentpath.find_last_of("\\/")+1); } -#endif \ No newline at end of file +#endif