before_code
stringlengths
14
465k
reviewer_comment
stringlengths
16
64.5k
after_code
stringlengths
9
467k
diff_context
stringlengths
0
97k
file_path
stringlengths
5
226
comment_line
int32
0
26
language
stringclasses
37 values
quality_score
float32
0.07
1
comment_type
stringclasses
9 values
comment_length
int32
16
64.5k
before_lines
int32
1
17.2k
after_lines
int32
1
12.1k
is_negative
bool
2 classes
pr_title
stringlengths
1
308
pr_number
int32
1
299k
repo_name
stringclasses
533 values
repo_stars
int64
321
419k
repo_language
stringclasses
27 values
reviewer_username
stringlengths
0
39
author_username
stringlengths
2
39
std::unique_lock lock(m_critSection); Clear(); m_database = std::make_shared<CPVRDatabase>(); m_providers = std::make_shared<CPVRProviders>(); m_channelGroups = std::make_shared<CPVRChannelGroupsContainer>(); m_recordings = std::make_shared<CPVRRecordings>(); m_timers = std::make_shared<CPVRTimers>(); ...
Doesn't `Process()` call `delete this;`? Even if not, the question raises flags.
std::unique_lock lock(m_critSection); Clear(); m_database = std::make_shared<CPVRDatabase>(); m_providers = std::make_shared<CPVRProviders>(); m_channelGroups = std::make_shared<CPVRChannelGroupsContainer>(); m_recordings = std::make_shared<CPVRRecordings>(); m_timers = std::make_shared<CPVRTimers>(); ...
@@ -351,16 +351,30 @@ void CPVRManager::ResetProperties() m_knownClients.clear(); } +namespace +{ +class CClientsInitThread : private CThread +{ +public: + explicit CClientsInitThread(const std::shared_ptr<CPVRClients>& clients) + : CThread("PVRClientsInitThread"), m_clients(clients) + { + Create(true); +...
xbmc/pvr/PVRManager.cpp
26
C++
0.357
question
80
51
51
false
[PVR][profiles] Fixes for problems with PVR stop/start on profile switch
27,032
xbmc/xbmc
17,740
C++
garbear
ksooo
CVariant profileVariant = CVariant(CVariant::VariantTypeObject); profileVariant["label"] = currentProfile.getName(); for (CVariant::const_iterator_array propertyiter = parameterObject["properties"].begin_array(); propertyiter != parameterObject["properties"].end_array(); ++propertyiter) { if (propertyiter->...
Maybe `if (index <= INVALID_PROFILE_ID)`? That seems to fit the logic above.
CVariant profileVariant = CVariant(CVariant::VariantTypeObject); profileVariant["label"] = currentProfile.getName(); for (CVariant::const_iterator_array propertyiter = parameterObject["properties"].begin_array(); propertyiter != parameterObject["properties"].end_array(); ++propertyiter) { if (propertyiter->...
@@ -91,7 +91,7 @@ JSONRPC_STATUS CProfilesOperations::LoadProfile(const std::string &method, ITran std::string profilename = parameterObject["profile"].asString(); int index = profileManager->GetProfileIndex(profilename); - if (index < 0) + if (index < MASTER_PROFILE_ID)
xbmc/interfaces/json-rpc/ProfilesOperations.cpp
26
C++
0.357
suggestion
76
51
51
false
[PVR][profiles] Fixes for problems with PVR stop/start on profile switch
27,032
xbmc/xbmc
17,740
C++
garbear
ksooo
{ CLog::Log(LOGERROR, "Failed to load profile - might be corrupted - falling back to master profile"); m_profiles.clear(); CFile::Delete(file); ret = true; } if (m_profiles.empty()) { // add the master user CProfile profile("special://masterprofile/", "Master user", MASTER_PR...
`else if (m_autoLoginProfile > INVALID_PROFILE_ID)`
{ CLog::Log(LOGERROR, "Failed to load profile - might be corrupted - falling back to master profile"); m_profiles.clear(); CFile::Delete(file); ret = true; } if (m_profiles.empty()) { // add the master user CProfile profile("special://masterprofile/", "Master user", MASTER_PR...
@@ -194,26 +194,27 @@ bool CProfileManager::Load() if (m_profiles.empty()) { // add the master user - CProfile profile("special://masterprofile/", "Master user", 0); + CProfile profile("special://masterprofile/", "Master user", MASTER_PROFILE_ID); AddProfile(profile); } // check the validity ...
xbmc/profiles/ProfileManager.cpp
26
C++
0.357
suggestion
51
51
51
false
[PVR][profiles] Fixes for problems with PVR stop/start on profile switch
27,032
xbmc/xbmc
17,740
C++
garbear
ksooo
for (const SDirData& dir : vecDirsOpen) { if (dirp == (DIR*)&dir) { emulated = true; break; } } if (!emulated) return readdir(dirp); // local dir // dirp is actually a SDirData* SDirData* dirData = reinterpret_cast<SDirData*>(dirp); if (dirData->last_...
You can use `strncpy_s` to make sure not introduce unwanted behavior change ```suggestion strncpy_s(entry->d_name, sizeof(entry->d_name), dirData->items[dirData->curr_index - 2]->GetLabel().c_str(), sizeof(entry->d_name)); ```
for (const SDirData& dir : vecDirsOpen) { if (dirp == (DIR*)&dir) { emulated = true; break; } } if (!emulated) return readdir(dirp); // local dir // dirp is actually a SDirData* SDirData* dirData = reinterpret_cast<SDirData*>(dirp); if (dirData->last_...
@@ -999,8 +999,8 @@ extern "C" strncpy(entry->d_name, "..\0", 3); else { - strncpy(entry->d_name, dirData->items[dirData->curr_index - 2]->GetLabel().c_str(), sizeof(entry->d_name)); - entry->d_name[sizeof(entry->d_name)-1] = '\0'; // null-terminate any truncated paths + snpr...
xbmc/cores/DllLoader/exports/emu_msvcrt.cpp
26
C++
1
suggestion
277
51
51
false
[cores][dllLoader] Use snprintf instead of strncpy/strncat for safer …
27,042
xbmc/xbmc
17,740
C++
thexai
the-black-eagle
for (int i = 0; i < EMU_MAX_ENVIRONMENT_ITEMS && free_position == NULL; i++) { if (dll__environ[i] != NULL) { // we only support overwriting the old values if (StringUtils::CompareNoCase(dll__environ[i], var, strlen(var)) == 0) { ...
Replace `strncpy` to `strncpy_s` and `strncat` to `strncat_s` is also an option: ```c++ strncpy_s(*free_position, size, var, size); (*free_position)[size - 1] = '\0'; strncat_s(*free_position, size, "=", size - strlen(*free_position)); strncat_s(*free_posit...
for (int i = 0; i < EMU_MAX_ENVIRONMENT_ITEMS && free_position == NULL; i++) { if (dll__environ[i] != NULL) { // we only support overwriting the old values if (StringUtils::CompareNoCase(dll__environ[i], var, strlen(var)) == 0) { ...
@@ -1881,19 +1881,14 @@ extern "C" if (free_position != NULL) { - // free position, copy value size = strlen(var) + strlen(value) + 2; - *free_position = (char*)malloc(size); // for '=' and 0 termination - if ((*free_position)) + *free_pos...
xbmc/cores/DllLoader/exports/emu_msvcrt.cpp
26
C++
1
suggestion
374
51
51
false
[cores][dllLoader] Use snprintf instead of strncpy/strncat for safer …
27,042
xbmc/xbmc
17,740
C++
thexai
the-black-eagle
{"foo S02E01-02-03.mkv", {{2, 1}, {2, 2}, {2, 3}}, {{2, 1}, {2, 2}, {2, 3}}}, {"foo 2x01x02.mkv", {{2, 1}, {2, 2}}, {{2, 1}, {2, 2}}}, {"foo ep01-02.mkv", {{1, 1}, {1, 2}}, {{1, 1}, {1, 2}}}, {"foo.S02E01S02E03.mkv", {{2, 1}, {2, 3}}, {{2, 1}, {2, 3}}}, // spanning episodes {"foo.E03-05.mkv", {{...
I would suggest to interpret this case as always being single episode, not a range of episodes.
{{1, 1}, {1, 2}}, {{1, 1}, {1, 2}}}, {"foo s01e01-episode1.title-s01e02-episode2.title.mkv", {{1, 1}, {1, 2}}, {{1, 1}, {1, 2}}}, {"foo.S01E01E02.mkv", {{1, 1}, {1, 2}}, {{1, 1}, {1, 2}}}, {"foo.S01E03E04E05.mkv", {{1, 3}, {1, 4}, {1, 5}}, {{1, 3}, {1, 4}, {1, 5}}}, {"foo.S02E01-S02E02.mkv", {...
@@ -73,6 +73,7 @@ static const TestEntry TestData[] = { {{0, 1}, {0, 2}, {0, 3}, {0, 4}, {5, 3}, {5, 4}, {5, 5}, {5, 6}}, {{0, 1}, {0, 4}, {5, 3}, {5, 6}}}, // expected (partial) failure + {"foo.S01E01-200.mkv", {}, {{1, 1}, {1, 200}}}, // episode range too large
xbmc/video/test/TestVideoInfoScanner.cpp
26
C++
0.357
suggestion
96
51
51
false
[Video] Improve episode range determination when scanning library and add further tests.
27,049
xbmc/xbmc
17,740
C++
ksooo
78andyp
// spanning episode ranges {"foo.ep03-ep05.mkv", {{1, 3}, {1, 4}, {1, 5}}, {{1, 3}, {1, 5}}}, {"foo.S05E03-E05.mkv", {{5, 3}, {5, 4}, {5, 5}}, {{5, 3}, {5, 5}}}, {"foo.S05E03-S05E05.mkv", {{5, 3}, {5, 4}, {5, 5}}, {{5, 3}, {5, 5}}}, {"foo.S05E01-E03-E05.mkv", {{5, 1}, {5, 2}, {5, 3}, {5, 4}, {5, 5}}...
you're creating work for yourself with that one lol. not a priority if something has to go to code a reasonable implementation.
{"foo S02E01-02-03.mkv", {{2, 1}, {2, 2}, {2, 3}}, {{2, 1}, {2, 2}, {2, 3}}}, {"foo 2x01x02.mkv", {{2, 1}, {2, 2}}, {{2, 1}, {2, 2}}}, {"foo ep01-02.mkv", {{1, 1}, {1, 2}}, {{1, 1}, {1, 2}}}, {"foo.S02E01S02E03.mkv", {{2, 1}, {2, 3}}, {{2, 1}, {2, 3}}}, // spanning episode ranges {"foo.ep03-ep05...
@@ -52,37 +58,46 @@ static const TestEntry TestData[] = { {"foo 2x01x02.mkv", {{2, 1}, {2, 2}}, {{2, 1}, {2, 2}}}, {"foo ep01-02.mkv", {{1, 1}, {1, 2}}, {{1, 1}, {1, 2}}}, {"foo.S02E01S02E03.mkv", {{2, 1}, {2, 3}}, {{2, 1}, {2, 3}}}, - // spanning episodes - {"foo.E03-05.mkv", {{1, 3}, {1, 4}, {1, ...
xbmc/video/test/TestVideoInfoScanner.cpp
26
C++
0.286
suggestion
127
51
51
false
[Video] Improve episode range determination when scanning library and add further tests.
27,049
xbmc/xbmc
17,740
C++
CrystalP
78andyp
#include "settings/AdvancedSettings.h" #include "settings/SettingsComponent.h" #include "video/VideoInfoScanner.h" #include <gtest/gtest.h> using namespace KODI; using ::testing::Test; using ::testing::WithParamInterface; using ::testing::ValuesIn; struct TestEntry { const char* path; std::vector<VIDEO::EPISODE>...
Those are outside the intended scope, but if you're adding them, could you add the "no season" column of the wiki as well?
#include "settings/AdvancedSettings.h" #include "settings/SettingsComponent.h" #include "video/VideoInfoScanner.h" #include <gtest/gtest.h> using namespace KODI; using ::testing::Test; using ::testing::WithParamInterface; using ::testing::ValuesIn; struct TestEntry { const char* path; std::vector<VIDEO::EPISODE>...
@@ -29,6 +29,11 @@ struct TestEntry static const TestEntry TestData[] = { //season+episode {"foo.S02E03.mkv", {{2, 3}}, {{2, 3}}}, + {"foo.S2E3.mkv", {{2, 3}}, {{2, 3}}}, + {"foo.S02.E03.mkv", {{2, 3}}, {{2, 3}}}, + {"foo.S02_E03.mkv", {{2, 3}}, {{2, 3}}}, + {"foo.S02xE03.mkv", {{2, 3}}, {{2, 3}}...
xbmc/video/test/TestVideoInfoScanner.cpp
26
C++
0.5
question
122
51
51
false
[Video] Improve episode range determination when scanning library and add further tests.
27,049
xbmc/xbmc
17,740
C++
CrystalP
78andyp
static const TestEntry TestData[] = { //season+episode {"foo.S02E03.mkv", {{2, 3}}, {{2, 3}}}, {"foo.S2E3.mkv", {{2, 3}}, {{2, 3}}}, {"foo.S02.E03.mkv", {{2, 3}}, {{2, 3}}}, {"foo.S02_E03.mkv", {{2, 3}}, {{2, 3}}}, {"foo.S02xE03.mkv", {{2, 3}}, {{2, 3}}}, {"foo.2x03.mkv", {{2, 3}}, {{2, 3}}...
As mentioned in an earlier comment, it's difficult to impossible to make this one work reliably, the episode title could be a number that will be interpreted as an episode number. Impact was low before episode ranges, it's higher now. Low priority as far as I am concerned.
static const TestEntry TestData[] = { //season+episode {"foo.S02E03.mkv", {{2, 3}}, {{2, 3}}}, {"foo.S2E3.mkv", {{2, 3}}, {{2, 3}}}, {"foo.S02.E03.mkv", {{2, 3}}, {{2, 3}}}, {"foo.S02_E03.mkv", {{2, 3}}, {{2, 3}}}, {"foo.S02xE03.mkv", {{2, 3}}, {{2, 3}}}, {"foo.2x03.mkv", {{2, 3}}, {{2, 3}}...
@@ -37,10 +42,11 @@ static const TestEntry TestData[] = { {"foo.Part.3.mkv", {{1, 3}}, {{1, 3}}}, {"foo.E03.mkv", {{1, 3}}, {{1, 3}}}, {"foo.2009.E03.mkv", {{1, 3}}, {{1, 3}}}, - // multi-episode + // multi-episode (not ranges) {"The Legend of Korra - S01E01-02 - Welcome to Republic City & A L...
xbmc/video/test/TestVideoInfoScanner.cpp
26
C++
0.571
suggestion
273
51
51
false
[Video] Improve episode range determination when scanning library and add further tests.
27,049
xbmc/xbmc
17,740
C++
CrystalP
78andyp
if (lTimeDate == 0) // if modification date is missing, use create date lTimeDate = st.st_ctime; iSize = st.st_size; } KODI::TIME::FileTime fileTime, localTime; KODI::TIME::TimeTToFileTime(lTimeDate, &fileTime); KODI::TIME::FileTimeToLocalFileTime(&fileTime, &localTime); if (bI...
Instead of the legacy typedef use the real type `std::make_shared<CFileItem>`
if (hidden) item->SetProperty("file:hidden", true); if (isDir) { std::string path(strRoot); path = URIUtils::AddFileToFolder(path, name); URIUtils::AddSlashAtEnd(path); item->SetPath(path); item->SetFolder(true); } else { item->SetPath(strRoot + name); ...
@@ -121,137 +107,107 @@ bool CSMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) int ngetattr = 0; std::cout << "Reading directory" << std::endl; auto start = std::chrono::steady_clock::now(); - while ((dirEnt = smbc_readdir(fd))) - { - CachedDirEntry aDir; - aDir.type = dirEnt->smbc_typ...
xbmc/platform/posix/filesystem/SMBDirectory.cpp
26
C++
0.857
suggestion
77
51
51
false
[smb] Rewrite GetDirectory to use smbc_readdirplus2() where possible for orders of magnitude performance improvements.
27,068
xbmc/xbmc
17,740
C++
sundermann
eduarrrd
bool hidden = false; if (StringUtils::StartsWith(strFile, ".")) hidden = true; // only stat files that can give proper responses if (S_ISREG(st.st_mode) || bIsDir) { nstats++; // This is also present in stuct stat using S_IXOTH but given the potential for confusion // let's...
Instead of the legacy typedef use the real type `std::make_shared<CFileItem>` and also drop `p` prefix
hidden = hidden || fi->attrs & SMBC_DOS_MODE_HIDDEN; timeDate = st.st_mtime; if (timeDate == 0) // if modification date is missing, use create date timeDate = st.st_ctime; size = st.st_size; } KODI::TIME::FileTime fileTime, localTime; KODI::TIME::TimeTToFileTime(timeDate, &...
@@ -121,137 +107,107 @@ bool CSMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) int ngetattr = 0; std::cout << "Reading directory" << std::endl; auto start = std::chrono::steady_clock::now(); - while ((dirEnt = smbc_readdir(fd))) - { - CachedDirEntry aDir; - aDir.type = dirEnt->smbc_typ...
xbmc/platform/posix/filesystem/SMBDirectory.cpp
26
C++
1
suggestion
102
51
51
false
[smb] Rewrite GetDirectory to use smbc_readdirplus2() where possible for orders of magnitude performance improvements.
27,068
xbmc/xbmc
17,740
C++
sundermann
eduarrrd
URIUtils::AddSlashAtEnd(strRoot); URIUtils::AddSlashAtEnd(strAuth); lock.lock(); if (!smb.IsSmbValid()) return false; int nstats = 0; int ngetattr = 0; std::cout << "Reading directory" << std::endl; auto start = std::chrono::steady_clock::now(); const libsmb_file_info* fi; struct stat st; ...
Can this be const? Also for new code don't prefix with the type.
lock.lock(); if (!smb.IsSmbValid()) return false; const libsmb_file_info* fi; struct stat st; bool atLeastOneEntry = false; while ((fi = smbc_readdirplus2(fd, &st))) { atLeastOneEntry = true; // We use UTF-8 internally, as does SMB std::string name = fi->name; if (name == "." || nam...
@@ -121,137 +107,107 @@ bool CSMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) int ngetattr = 0; std::cout << "Reading directory" << std::endl; auto start = std::chrono::steady_clock::now(); - while ((dirEnt = smbc_readdir(fd))) - { - CachedDirEntry aDir; - aDir.type = dirEnt->smbc_typ...
xbmc/platform/posix/filesystem/SMBDirectory.cpp
26
C++
0.429
suggestion
64
51
51
false
[smb] Rewrite GetDirectory to use smbc_readdirplus2() where possible for orders of magnitude performance improvements.
27,068
xbmc/xbmc
17,740
C++
sundermann
eduarrrd
lock.lock(); if (!smb.IsSmbValid()) return false; int nstats = 0; int ngetattr = 0; std::cout << "Reading directory" << std::endl; auto start = std::chrono::steady_clock::now(); const libsmb_file_info* fi; struct stat st; bool atLeastOneEntry = false; while ((fi = smbc_readdirplus2(fd, &st)...
`const bool hidden = StringUtils::StartsWith(strFile, ".")`
if (!smb.IsSmbValid()) return false; const libsmb_file_info* fi; struct stat st; bool atLeastOneEntry = false; while ((fi = smbc_readdirplus2(fd, &st))) { atLeastOneEntry = true; // We use UTF-8 internally, as does SMB std::string name = fi->name; if (name == "." || name == ".." || nam...
@@ -121,137 +107,107 @@ bool CSMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) int ngetattr = 0; std::cout << "Reading directory" << std::endl; auto start = std::chrono::steady_clock::now(); - while ((dirEnt = smbc_readdir(fd))) - { - CachedDirEntry aDir; - aDir.type = dirEnt->smbc_typ...
xbmc/platform/posix/filesystem/SMBDirectory.cpp
26
C++
0.357
suggestion
59
51
51
false
[smb] Rewrite GetDirectory to use smbc_readdirplus2() where possible for orders of magnitude performance improvements.
27,068
xbmc/xbmc
17,740
C++
sundermann
eduarrrd
else { std::shared_ptr<CFileItem> item(new CFileItem(name)); item->SetPath(strRoot + fi->name); item->SetFolder(false); item->SetSize(size); item->SetDateTime(localTime); if (hidden) item->SetProperty("file:hidden", true); items.Add(item); } } // No res...
```suggestion const auto item = std::make_shared<CFileItem>(dirent->name); ```
// No results from smbc_readdirplus2() suggests server or share browsing. // Use smbclient's legacy API for this. if (!atLeastOneEntry) { if (smbc_lseekdir(fd, 0) < 0) { CLog::LogF(LOGERROR, "Unable to seek directory : '{}'\nunix_err:'{:x}' error: '{}'", CURL::GetRedacted(strAuth)...
@@ -103,146 +99,116 @@ bool CSMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) URIUtils::AddSlashAtEnd(strRoot); URIUtils::AddSlashAtEnd(strAuth); - std::string strFile; - - // need to keep the samba lock for as short as possible. - // so we first cache all directory entries and then go over ...
xbmc/platform/posix/filesystem/SMBDirectory.cpp
26
C++
0.857
suggestion
84
51
51
false
[smb] Rewrite GetDirectory to use smbc_readdirplus2() where possible for orders of magnitude performance improvements.
27,068
xbmc/xbmc
17,740
C++
sundermann
eduarrrd
if (timeDate == 0) // if modification date is missing, use create date timeDate = st.st_ctime; size = st.st_size; } KODI::TIME::FileTime fileTime, localTime; KODI::TIME::TimeTToFileTime(timeDate, &fileTime); KODI::TIME::FileTimeToLocalFileTime(&fileTime, &localTime); if (isDir)...
```suggestion const auto item = std::make_shared<CFileItem>(name); ```
const auto item = std::make_shared<CFileItem>(name); item->SetDateTime(localTime); if (hidden) item->SetProperty("file:hidden", true); if (isDir) { std::string path(strRoot); path = URIUtils::AddFileToFolder(path, name); URIUtils::AddSlashAtEnd(path); item->SetPath(pa...
@@ -103,146 +99,116 @@ bool CSMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) URIUtils::AddSlashAtEnd(strRoot); URIUtils::AddSlashAtEnd(strAuth); - std::string strFile; - - // need to keep the samba lock for as short as possible. - // so we first cache all directory entries and then go over ...
xbmc/platform/posix/filesystem/SMBDirectory.cpp
26
C++
0.857
suggestion
76
51
51
false
[smb] Rewrite GetDirectory to use smbc_readdirplus2() where possible for orders of magnitude performance improvements.
27,068
xbmc/xbmc
17,740
C++
sundermann
eduarrrd
int64_t size = 0; const bool isDir = S_ISDIR(st.st_mode); int64_t timeDate = 0; bool hidden = StringUtils::StartsWith(name, "."); // only stat files that can give proper responses if (S_ISREG(st.st_mode) || isDir) { nstats++; // This is also present in stuct stat using S_IXOTH b...
```suggestion const auto item = std::make_shared<CFileItem>(name); ```
{ // This is also present in stuct stat using S_IXOTH but given the potential for confusion // let's be explicit. hidden = hidden || fi->attrs & SMBC_DOS_MODE_HIDDEN; timeDate = st.st_mtime; if (timeDate == 0) // if modification date is missing, use create date timeDate = st.s...
@@ -103,146 +99,116 @@ bool CSMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) URIUtils::AddSlashAtEnd(strRoot); URIUtils::AddSlashAtEnd(strAuth); - std::string strFile; - - // need to keep the samba lock for as short as possible. - // so we first cache all directory entries and then go over ...
xbmc/platform/posix/filesystem/SMBDirectory.cpp
26
C++
0.857
suggestion
76
51
51
false
[smb] Rewrite GetDirectory to use smbc_readdirplus2() where possible for orders of magnitude performance improvements.
27,068
xbmc/xbmc
17,740
C++
sundermann
eduarrrd
while ((dirent = smbc_readdir(fd))) { if (dirent->smbc_type != SMBC_FILE_SHARE && dirent->smbc_type != SMBC_SERVER) continue; std::shared_ptr<CFileItem> item(new CFileItem(dirent->name)); std::string path(strRoot); // needed for network / workgroup browsing // skip if root...
I guess we should log an error if it returns < 0.
// skip if root if we are given a server if (dirent->smbc_type == SMBC_SERVER) { /* create url with same options, user, pass.. but no filename or host*/ CURL rooturl(strRoot); rooturl.SetFileName(""); rooturl.SetHostName(""); path = smb.URLEncode(rooturl); ...
@@ -103,146 +99,116 @@ bool CSMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) URIUtils::AddSlashAtEnd(strRoot); URIUtils::AddSlashAtEnd(strAuth); - std::string strFile; - - // need to keep the samba lock for as short as possible. - // so we first cache all directory entries and then go over ...
xbmc/platform/posix/filesystem/SMBDirectory.cpp
26
C++
0.571
suggestion
49
51
51
false
[smb] Rewrite GetDirectory to use smbc_readdirplus2() where possible for orders of magnitude performance improvements.
27,068
xbmc/xbmc
17,740
C++
sundermann
eduarrrd
URIUtils::AddSlashAtEnd(path); item->SetPath(path); item->SetFolder(true); item->SetDateTime(localTime); if (hidden) item->SetProperty("file:hidden", true); items.Add(item); } else { std::shared_ptr<CFileItem> item(new CFileItem(name)); item->SetPath(s...
Do we need to check for an error here or at least add error logging?
{ item->SetPath(strRoot + name); item->SetFolder(false); item->SetSize(size); } items.Add(item); } // No results from smbc_readdirplus2() suggests server or share browsing. // Use smbclient's legacy API for this. if (!atLeastOneEntry) { if (smbc_lseekdir(fd, 0) < 0) { ...
@@ -103,146 +99,116 @@ bool CSMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) URIUtils::AddSlashAtEnd(strRoot); URIUtils::AddSlashAtEnd(strAuth); - std::string strFile; - - // need to keep the samba lock for as short as possible. - // so we first cache all directory entries and then go over ...
xbmc/platform/posix/filesystem/SMBDirectory.cpp
26
C++
0.429
bug
68
51
51
false
[smb] Rewrite GetDirectory to use smbc_readdirplus2() where possible for orders of magnitude performance improvements.
27,068
xbmc/xbmc
17,740
C++
sundermann
eduarrrd
int64_t size = 0; const bool isDir = S_ISDIR(st.st_mode); int64_t timeDate = 0; bool hidden = StringUtils::StartsWith(name, "."); // only stat files that can give proper responses if (S_ISREG(st.st_mode) || isDir) { // This is also present in stuct stat using S_IXOTH but given the pot...
Can this just be `item->SetProperty("file:hidden", hidden)` or does have explicitly setting hidden to false have special semantics from "unset"?
int64_t size = 0; const bool isDir = S_ISDIR(st.st_mode); int64_t timeDate = 0; bool hidden = StringUtils::StartsWith(name, "."); // only stat files that can give proper responses if (S_ISREG(st.st_mode) || isDir) { // This is also present in stuct stat using S_IXOTH but given the pot...
@@ -103,146 +97,114 @@ bool CSMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) URIUtils::AddSlashAtEnd(strRoot); URIUtils::AddSlashAtEnd(strAuth); - std::string strFile; - - // need to keep the samba lock for as short as possible. - // so we first cache all directory entries and then go over ...
xbmc/platform/posix/filesystem/SMBDirectory.cpp
26
C++
0.5
question
144
51
51
false
[smb] Rewrite GetDirectory to use smbc_readdirplus2() where possible for orders of magnitude performance improvements.
27,068
xbmc/xbmc
17,740
C++
eduarrrd
eduarrrd
if (isDir) { std::string path(strRoot); path = URIUtils::AddFileToFolder(path, fi->name); URIUtils::AddSlashAtEnd(path); item->SetPath(path); item->SetFolder(true); } else { item->SetPath(strRoot + fi->name); item->SetFolder(false); item->SetSize(size...
You can use `CLog::LogF` here and remove `SMBDirectory->GetDirectory:` from message `LogF` automatically adds `Class::Method:` prefix
if (isDir) { std::string path(strRoot); path = URIUtils::AddFileToFolder(path, name); URIUtils::AddSlashAtEnd(path); item->SetPath(path); item->SetFolder(true); } else { item->SetPath(strRoot + name); item->SetFolder(false); item->SetSize(size); }...
@@ -103,146 +97,113 @@ bool CSMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) URIUtils::AddSlashAtEnd(strRoot); URIUtils::AddSlashAtEnd(strAuth); - std::string strFile; - - // need to keep the samba lock for as short as possible. - // so we first cache all directory entries and then go over ...
xbmc/platform/posix/filesystem/SMBDirectory.cpp
26
C++
0.714
suggestion
136
51
51
false
[smb] Rewrite GetDirectory to use smbc_readdirplus2() where possible for orders of magnitude performance improvements.
27,068
xbmc/xbmc
17,740
C++
thexai
eduarrrd
if (dirent->smbc_type != SMBC_FILE_SHARE && dirent->smbc_type != SMBC_SERVER) continue; const auto item = std::make_shared<CFileItem>(dirent->name); std::string path(strRoot); // needed for network / workgroup browsing // skip if root if we are given a server if (dirent->smb...
```suggestion CLog::LogF(LOGERROR, ```
continue; const auto item = std::make_shared<CFileItem>(dirent->name); std::string path(strRoot); // needed for network / workgroup browsing // skip if root if we are given a server if (dirent->smbc_type == SMBC_SERVER) { /* create url with same options, user, pass.....
@@ -103,146 +97,113 @@ bool CSMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) URIUtils::AddSlashAtEnd(strRoot); URIUtils::AddSlashAtEnd(strAuth); - std::string strFile; - - // need to keep the samba lock for as short as possible. - // so we first cache all directory entries and then go over ...
xbmc/platform/posix/filesystem/SMBDirectory.cpp
26
C++
1
suggestion
44
51
51
false
[smb] Rewrite GetDirectory to use smbc_readdirplus2() where possible for orders of magnitude performance improvements.
27,068
xbmc/xbmc
17,740
C++
thexai
eduarrrd
const auto item = std::make_shared<CFileItem>(dirent->name); std::string path(strRoot); // needed for network / workgroup browsing // skip if root if we are given a server if (dirent->smbc_type == SMBC_SERVER) { /* create url with same options, user, pass.. but no filename o...
This "return true" here is not necessary and redundant, return true anyway on the next line.
const auto item = std::make_shared<CFileItem>(dirent->name); std::string path(strRoot); // needed for network / workgroup browsing // skip if root if we are given a server if (dirent->smbc_type == SMBC_SERVER) { /* create url with same options, user, pass.. but no filename o...
@@ -103,146 +97,111 @@ bool CSMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) URIUtils::AddSlashAtEnd(strRoot); URIUtils::AddSlashAtEnd(strAuth); - std::string strFile; - - // need to keep the samba lock for as short as possible. - // so we first cache all directory entries and then go over ...
xbmc/platform/posix/filesystem/SMBDirectory.cpp
26
C++
0.143
suggestion
92
51
51
false
[smb] Rewrite GetDirectory to use smbc_readdirplus2() where possible for orders of magnitude performance improvements.
27,068
xbmc/xbmc
17,740
C++
thexai
eduarrrd
void SetPremiered(const CDateTime& premiered); void SetPremieredFromDBDate(const std::string& premieredString); virtual void SetYear(int year); void SetArtist(std::vector<std::string> artist); void SetSet(std::string_view set); void SetSetOverview(std::string_view setOverview); void SetTags(std::vector<st...
In C++20 you can do ```c++ bool operator==(const SeasonAttributes& other) const = default ``` I think
void SetPremiered(const CDateTime& premiered); void SetPremieredFromDBDate(const std::string& premieredString); virtual void SetYear(int year); void SetArtist(std::vector<std::string> artist); void SetSet(std::string_view set); void SetSetOverview(std::string_view setOverview); void SetTags(std::vector<st...
@@ -167,7 +167,17 @@ class CVideoInfoTag : public IArchivable, public ISerializable, public ISortable void SetShowLink(std::vector<std::string> showLink); void SetUniqueID(std::string_view uniqueid, const std::string& type = "", bool def = false); void RemoveUniqueID(const std::string& type); - void SetNamedS...
xbmc/video/VideoInfoTag.h
26
C/C++
0.786
suggestion
107
51
51
false
Add Season Plot
27,077
xbmc/xbmc
17,740
C++
garbear
CrystalP
{ strChangedFile = strFile; strChangedFile += strNewExtension; } return strChangedFile; } std::string URIUtils::GetFileName(const CURL& url) { return GetFileName(url.GetFileName()); } /* returns a filename given an url */ /* handles both / and \, and options in urls*/ std::string URIUtils::GetFileName...
Can you do ```c++ const char ch = strFileNameAndPath[i]; ``` ? We don't need dangling lifetime and optimizers like this better.
{ strChangedFile = strFile; strChangedFile += strNewExtension; } return strChangedFile; } std::string URIUtils::GetFileName(const CURL& url) { return GetFileName(url.GetFileName()); } /* returns a filename given an url */ /* handles both / and \, and options in urls*/ std::string URIUtils::GetFileName...
@@ -199,9 +199,17 @@ std::string URIUtils::GetFileName(const std::string& strFileNameAndPath) return GetFileName(url.GetFileName()); } - /* find the last slash */ - const size_t slash = strFileNameAndPath.find_last_of("/\\"); - return strFileNameAndPath.substr(slash+1); + int i = strFileNameAndPath.size()...
xbmc/utils/URIUtils.cpp
26
C++
1
performance
131
51
51
false
[CURL][URIUtils] Fixed inconsistency when getting filename from a windows drive spec.
27,087
xbmc/xbmc
17,740
C++
garbear
damienruscoe
#include <limits.h> #include <nfsc/libnfs-raw-nfs.h> #include <nfsc/libnfs.h> #if defined(TARGET_WINDOWS) #define S_IFLNK 0120000 #define S_ISBLK(m) (0) #define S_ISSOCK(m) (0) #define S_ISLNK(m) ((m & S_IFLNK) != 0) #define S_ISCHR(m) ((m & _S_IFCHR) != 0) #define S_ISDIR(m) ((m & _S_IFDIR) != 0) #define S_ISFIFO(m)...
Since this code is touched, please follow code guidelines: one variable per line (https://github.com/xbmc/xbmc/blob/master/docs/CODE_GUIDELINES.md#52-multiple-declarations). And better initialize structs: ```c++ KODI::TIME::FileTime fileTime{}; KODI::TIME::FileTime localTime{}; ```
#include <nfsc/libnfs-raw-nfs.h> #include <nfsc/libnfs.h> #if defined(TARGET_WINDOWS) #define S_IFLNK 0120000 #define S_ISBLK(m) (0) #define S_ISSOCK(m) (0) #define S_ISLNK(m) ((m & S_IFLNK) != 0) #define S_ISCHR(m) ((m & _S_IFCHR) != 0) #define S_ISDIR(m) ((m & _S_IFDIR) != 0) #define S_ISFIFO(m) ((m & _S_IFIFO) != 0...
@@ -40,6 +42,28 @@ using namespace XFILE; #define S_ISREG(m) ((m & _S_IFREG) != 0) #endif +namespace +{ + +KODI::TIME::FileTime GetDirEntryTime(struct nfsdirent* dirent) +{ + // if modification date is missing, use create date + const int64_t lTimeDate = + (dirent->mtime.tv_sec == 0) ? dirent->ctime.tv_sec :...
xbmc/filesystem/NFSDirectory.cpp
26
C++
1
suggestion
291
51
51
false
[filesystem] Refactored CNFSDirectory::GetDirectory
27,092
xbmc/xbmc
17,740
C++
thexai
damienruscoe
{ //connect has failed - so try to get the exported filesystems if no path is given to the url if (url.GetShareName().empty()) { if (url.GetHostName().empty()) return GetServerList(items); else { std::string myStrPath(url.Get()); URIUtils::AddSlashAtEnd(myStrPath)...
```suggestion constexpr std::array<std::string_view, 3> exclusions = {".", "..", "lost+found"}; ``` Here fits better `std::array` as number of elements is fixed and known at compile time.
//connect has failed - so try to get the exported filesystems if no path is given to the url if (url.GetShareName().empty()) { std::vector<CFileItemPtr> fileItems = url.GetHostName().empty() ? GetServerList() : GetDirectoryFromExportList(url); bool ret = !fileItems.empty(); items...
@@ -200,112 +224,76 @@ bool CNFSDirectory::ResolveSymlink( const std::string &dirName, struct nfsdirent bool CNFSDirectory::GetDirectory(const CURL& url, CFileItemList &items) { // We accept nfs://server/path[/file]]]] - int ret = 0; - KODI::TIME::FileTime fileTime, localTime; std::unique_lock lock(gNfsConnec...
xbmc/filesystem/NFSDirectory.cpp
26
C++
1
suggestion
194
51
51
false
[filesystem] Refactored CNFSDirectory::GetDirectory
27,092
xbmc/xbmc
17,740
C++
thexai
damienruscoe
std::string myStrPath(url.Get()); URIUtils::AddSlashAtEnd(myStrPath); URIUtils::AddSlashAtEnd(strDirName); std::string resolvedPath; std::vector<CFileItemPtr> fileItems; struct nfsdirent* dirent = NULL; while ((dirent = nfs_readdir(gNfsConnection.GetNfsContext(), nfsdir)) != NULL) { const std::stri...
Since you are already touching these. Drop the `p` prefix from the variable name. Type prefixing is discouraged
while ((dirent = nfs_readdir(gNfsConnection.GetNfsContext(), nfsdir)) != nullptr) { const std::string& name = dirent->name; //resolve symlinks //resolve symlink changes dirent and name const bool isSymLink = dirent->type == NF3LNK; if (isSymLink && !ResolveSymlink(strDirName, dirent, resolvedPa...
@@ -200,112 +224,76 @@ bool CNFSDirectory::ResolveSymlink( const std::string &dirName, struct nfsdirent bool CNFSDirectory::GetDirectory(const CURL& url, CFileItemList &items) { // We accept nfs://server/path[/file]]]] - int ret = 0; - KODI::TIME::FileTime fileTime, localTime; std::unique_lock lock(gNfsConnec...
xbmc/filesystem/NFSDirectory.cpp
26
C++
0.786
suggestion
111
51
51
false
[filesystem] Refactored CNFSDirectory::GetDirectory
27,092
xbmc/xbmc
17,740
C++
sundermann
damienruscoe
URIUtils::AddSlashAtEnd(myStrPath); //be sure the dir ends with a slash return GetDirectoryFromExportList(myStrPath, items); } } return false; } struct nfsdir* nfsdir = NULL; if (nfs_opendir(gNfsConnection.GetNfsContext(), strDirName.c_str(), &nfsdir) != 0) { CLog::Log(LOGERRO...
```suggestion struct nfsdirent* dirent = nullptr; ```
return false; } struct nfsdir* nfsdir = nullptr; if (nfs_opendir(gNfsConnection.GetNfsContext(), strDirName.c_str(), &nfsdir) != 0) { CLog::Log(LOGERROR, "Failed to open({}) {}", strDirName, nfs_get_error(gNfsConnection.GetNfsContext())); return false; } lock.unlock(); std::str...
@@ -200,112 +224,76 @@ bool CNFSDirectory::ResolveSymlink( const std::string &dirName, struct nfsdirent bool CNFSDirectory::GetDirectory(const CURL& url, CFileItemList &items) { // We accept nfs://server/path[/file]]]] - int ret = 0; - KODI::TIME::FileTime fileTime, localTime; std::unique_lock lock(gNfsConnec...
xbmc/filesystem/NFSDirectory.cpp
26
C++
1
bug
55
51
51
false
[filesystem] Refactored CNFSDirectory::GetDirectory
27,092
xbmc/xbmc
17,740
C++
sundermann
damienruscoe
return GetDirectoryFromExportList(myStrPath, items); } } return false; } struct nfsdir* nfsdir = NULL; if (nfs_opendir(gNfsConnection.GetNfsContext(), strDirName.c_str(), &nfsdir) != 0) { CLog::Log(LOGERROR, "Failed to open({}) {}", strDirName, nfs_get_error(gNfsConnecti...
```suggestion while ((dirent = nfs_readdir(gNfsConnection.GetNfsContext(), nfsdir)) != nullptr) ```
} struct nfsdir* nfsdir = nullptr; if (nfs_opendir(gNfsConnection.GetNfsContext(), strDirName.c_str(), &nfsdir) != 0) { CLog::Log(LOGERROR, "Failed to open({}) {}", strDirName, nfs_get_error(gNfsConnection.GetNfsContext())); return false; } lock.unlock(); std::string myStrPath(url....
@@ -200,112 +224,76 @@ bool CNFSDirectory::ResolveSymlink( const std::string &dirName, struct nfsdirent bool CNFSDirectory::GetDirectory(const CURL& url, CFileItemList &items) { // We accept nfs://server/path[/file]]]] - int ret = 0; - KODI::TIME::FileTime fileTime, localTime; std::unique_lock lock(gNfsConnec...
xbmc/filesystem/NFSDirectory.cpp
26
C++
1
bug
101
51
51
false
[filesystem] Refactored CNFSDirectory::GetDirectory
27,092
xbmc/xbmc
17,740
C++
sundermann
damienruscoe
} bool CNFSDirectory::GetDirectory(const CURL& url, CFileItemList &items) { // We accept nfs://server/path[/file]]]] std::unique_lock lock(gNfsConnection); std::string strDirName = ""; if (!gNfsConnection.Connect(url, strDirName)) { //connect has failed - so try to get the exported filesystems if no pat...
```suggestion struct nfsdir* nfsdir = nullptr; ```
bool CNFSDirectory::GetDirectory(const CURL& url, CFileItemList &items) { // We accept nfs://server/path[/file]]]] std::unique_lock lock(gNfsConnection); std::string strDirName = ""; if (!gNfsConnection.Connect(url, strDirName)) { //connect has failed - so try to get the exported filesystems if no path ...
@@ -200,112 +224,76 @@ bool CNFSDirectory::ResolveSymlink( const std::string &dirName, struct nfsdirent bool CNFSDirectory::GetDirectory(const CURL& url, CFileItemList &items) { // We accept nfs://server/path[/file]]]] - int ret = 0; - KODI::TIME::FileTime fileTime, localTime; std::unique_lock lock(gNfsConnec...
xbmc/filesystem/NFSDirectory.cpp
26
C++
1
bug
52
51
51
false
[filesystem] Refactored CNFSDirectory::GetDirectory
27,092
xbmc/xbmc
17,740
C++
sundermann
damienruscoe
{ CLog::Log(LOGERROR, "Failed to open({}) {}", strDirName, nfs_get_error(gNfsConnection.GetNfsContext())); return false; } lock.unlock(); const std::vector<std::string> exclusions = {".", "..", "lost+found"}; const auto notExcluded = exclusions.end(); std::string myStrPath(url.Get())...
This seems a bit overkilling, use simple: ```c++ if (strName == "." || strName == ".." || strName == "lost + found") continue; ``` Is more readable and even faster --> tested while loop with ~3600 files: std::ranges::find --> **~36 ms** plain compare and continue --> **~22 ms** (tested several times...
} lock.unlock(); std::string myStrPath(url.Get()); URIUtils::AddSlashAtEnd(myStrPath); URIUtils::AddSlashAtEnd(strDirName); std::string resolvedPath; std::vector<CFileItemPtr> fileItems; struct nfsdirent* dirent = nullptr; while ((dirent = nfs_readdir(gNfsConnection.GetNfsContext(), nfsdir)) != null...
@@ -200,112 +224,76 @@ bool CNFSDirectory::ResolveSymlink( const std::string &dirName, struct nfsdirent bool CNFSDirectory::GetDirectory(const CURL& url, CFileItemList &items) { // We accept nfs://server/path[/file]]]] - int ret = 0; - KODI::TIME::FileTime fileTime, localTime; std::unique_lock lock(gNfsConnec...
xbmc/filesystem/NFSDirectory.cpp
26
C++
1
suggestion
393
51
51
false
[filesystem] Refactored CNFSDirectory::GetDirectory
27,092
xbmc/xbmc
17,740
C++
thexai
damienruscoe
if (nfs_opendir(gNfsConnection.GetNfsContext(), strDirName.c_str(), &nfsdir) != 0) { CLog::Log(LOGERROR, "Failed to open({}) {}", strDirName, nfs_get_error(gNfsConnection.GetNfsContext())); return false; } lock.unlock(); std::string myStrPath(url.Get()); URIUtils::AddSlashAtEnd(myStrP...
Before we checked for `lost+found` now it's `lost + found` is that intentional?
CLog::Log(LOGERROR, "Failed to open({}) {}", strDirName, nfs_get_error(gNfsConnection.GetNfsContext())); return false; } lock.unlock(); std::string myStrPath(url.Get()); URIUtils::AddSlashAtEnd(myStrPath); URIUtils::AddSlashAtEnd(strDirName); std::string resolvedPath; std::vector<C...
@@ -200,112 +225,71 @@ bool CNFSDirectory::ResolveSymlink( const std::string &dirName, struct nfsdirent bool CNFSDirectory::GetDirectory(const CURL& url, CFileItemList &items) { // We accept nfs://server/path[/file]]]] - int ret = 0; - KODI::TIME::FileTime fileTime, localTime; std::unique_lock lock(gNfsConnec...
xbmc/filesystem/NFSDirectory.cpp
26
C++
0.357
question
79
51
51
false
[filesystem] Refactored CNFSDirectory::GetDirectory
27,092
xbmc/xbmc
17,740
C++
sundermann
damienruscoe
* This file is part of Kodi - https://kodi.tv * * SPDX-License-Identifier: GPL-2.0-or-later * See LICENSES/README.md for more information. */ #ifdef TARGET_WINDOWS #include <mutex> #include <sys\stat.h> #endif #include "FileItem.h" #include "FileItemList.h" #include "NFSDirectory.h" #include "utils/StringUti...
This header is still necessary? Also `#include "utils/StringUtils.h"` can be removed now Unrelated, but previous Windows Jenkins failures was because missing `<array>` header (not necessary now with latest force push). Anyway seems better squash commits to avoid problems.
* This file is part of Kodi - https://kodi.tv * * SPDX-License-Identifier: GPL-2.0-or-later * See LICENSES/README.md for more information. */ #ifdef TARGET_WINDOWS #include <mutex> #include <sys\stat.h> #endif #include "FileItem.h" #include "FileItemList.h" #include "NFSDirectory.h" #include "utils/URIUtils....
@@ -25,9 +25,11 @@ #endif using namespace XFILE; +#include <algorithm>
xbmc/filesystem/NFSDirectory.cpp
26
C++
0.786
bug
280
51
51
false
[filesystem] Refactored CNFSDirectory::GetDirectory
27,092
xbmc/xbmc
17,740
C++
thexai
damienruscoe
#define S_IFLNK 0120000 #define S_ISBLK(m) (0) #define S_ISSOCK(m) (0) #define S_ISLNK(m) ((m & S_IFLNK) != 0) #define S_ISCHR(m) ((m & _S_IFCHR) != 0) #define S_ISDIR(m) ((m & _S_IFDIR) != 0) #define S_ISFIFO(m) ((m & _S_IFIFO) != 0) #define S_ISREG(m) ((m & _S_IFREG) != 0) #endif namespace { KODI::TIME::FileTime Ge...
Could you replace the c-style cats with c++-style casts, please
#define S_IFLNK 0120000 #define S_ISBLK(m) (0) #define S_ISSOCK(m) (0) #define S_ISLNK(m) ((m & S_IFLNK) != 0) #define S_ISCHR(m) ((m & _S_IFCHR) != 0) #define S_ISDIR(m) ((m & _S_IFDIR) != 0) #define S_ISFIFO(m) ((m & _S_IFIFO) != 0) #define S_ISREG(m) ((m & _S_IFREG) != 0) #endif namespace { KODI::TIME::FileTime Ge...
@@ -40,6 +40,31 @@ using namespace XFILE; #define S_ISREG(m) ((m & _S_IFREG) != 0) #endif +namespace +{ + +KODI::TIME::FileTime GetDirEntryTime(struct nfsdirent* dirent) +{ + // if modification date is missing, use create date + const int64_t timeDate = + (dirent->mtime.tv_sec == 0) ? dirent->ctime.tv_sec : ...
xbmc/filesystem/NFSDirectory.cpp
26
C++
0.643
style
63
51
51
false
[filesystem] Refactored CNFSDirectory::GetDirectory
27,092
xbmc/xbmc
17,740
C++
ksooo
damienruscoe
{ gNfsConnection.AddIdleConnection(); } std::vector<CFileItemPtr> CNFSDirectory::GetDirectoryFromExportList(const CURL& inputURL) { std::string pathWithSlash(inputURL.Get()); URIUtils::AddSlashAtEnd(pathWithSlash); //be sure the dir ends with a slash CURL url(pathWithSlash); std::string pathWithoutSlash(pa...
As a suggestion: `CFileItem`has a ctor taking both path and folderflag and it also has a `SetLabel` method. so, we could save some code in the PR if we switch to that pattern: ```c++ std::shared_ptr<CFileItem>& item{fileItems.emplace_back(std::make_shared<CFileItem>(path, true))}; item->SetLabel(currentExp...
{ gNfsConnection.AddIdleConnection(); } std::vector<CFileItemPtr> CNFSDirectory::GetDirectoryFromExportList(const CURL& inputURL) { std::string pathWithSlash(inputURL.Get()); URIUtils::AddSlashAtEnd(pathWithSlash); //be sure the dir ends with a slash CURL url(pathWithSlash); std::string pathWithoutSlash(pa...
@@ -50,79 +75,74 @@ CNFSDirectory::~CNFSDirectory(void) gNfsConnection.AddIdleConnection(); } -bool CNFSDirectory::GetDirectoryFromExportList(const std::string& strPath, CFileItemList &items) +std::vector<CFileItemPtr> CNFSDirectory::GetDirectoryFromExportList(const CURL& inputURL) { - CURL url(strPath); - std...
xbmc/filesystem/NFSDirectory.cpp
26
C++
1
suggestion
459
51
51
false
[filesystem] Refactored CNFSDirectory::GetDirectory
27,092
xbmc/xbmc
17,740
C++
ksooo
damienruscoe
void CFileItemList::Clear() { std::unique_lock lock(m_lock); ClearItems(); m_sortDescription.sortBy = SortByNone; m_sortDescription.sortOrder = SortOrderNone; m_sortDescription.sortAttributes = SortAttributeNone; m_sortIgnoreFolders = false; m_cacheToDisc = CacheType::IF_SLOW; m_sortDetails.clear(); ...
Why remove the GetURL() from the previous code? It looked like the URL was cached, so even if the CURL was created for this function and there is no immediate saving, another caller later on may.
ClearItems(); m_sortDescription.sortBy = SortByNone; m_sortDescription.sortOrder = SortOrderNone; m_sortDescription.sortAttributes = SortAttributeNone; m_sortIgnoreFolders = false; m_cacheToDisc = CacheType::IF_SLOW; m_sortDetails.clear(); m_replaceListing = false; m_content.clear(); } void CFileIte...
@@ -127,14 +123,23 @@ void CFileItemList::ClearItems() m_map.clear(); } +void CFileItemList::AddFastLookupItem(const CFileItemPtr& item) +{ + m_map.try_emplace( + m_ignoreURLOptions ? CURL(item->GetPath()).GetWithoutOptions() : item->GetPath(), item);
xbmc/FileItemList.cpp
26
C++
0.5
performance
195
51
51
false
[filesystem] Refactored CNFSDirectory::GetDirectory
27,092
xbmc/xbmc
17,740
C++
CrystalP
damienruscoe
if (!smb.IsSmbValid()) return -1; fd = smbc_opendir(s.c_str()); } while (fd < 0) /* only to avoid goto in following code */ { std::string cError; if (errno == EACCES || errno == EPERM || errno == EAGAIN || errno == EINVAL) { if (m_flags & DIR_FLAG_ALLOW_PROMPT) { if...
Direct uses of fmt should also include the fmt header. ```diff --- a/xbmc/platform/posix/filesystem/SMBDirectory.cpp +++ b/xbmc/platform/posix/filesystem/SMBDirectory.cpp @@ -36,6 +36,7 @@ #include <mutex> +#include <fmt/format.h> #include <libsmbclient.h> using namespace XFILE; ```
std::unique_lock lock(smb); if (!smb.IsSmbValid()) return -1; fd = smbc_opendir(s.c_str()); } while (fd < 0) /* only to avoid goto in following code */ { std::string cError; if (errno == EACCES || errno == EPERM || errno == EAGAIN || errno == EINVAL) { if (m_flags & DIR_FLAG_...
@@ -273,7 +272,7 @@ int CSMBDirectory::OpenDir(const CURL& url, std::string& strAuth) } if (errno == ENODEV || errno == ENOENT) - cError = StringUtils::Format(g_localizeStrings.Get(770), errno); + cError = fmt::format(fmt::runtime(g_localizeStrings.Get(770)), errno);
xbmc/platform/posix/filesystem/SMBDirectory.cpp
26
C++
1
suggestion
303
51
51
false
SMBDirectory: remove dependence on StringUtils and modernize logs
27,096
xbmc/xbmc
17,740
C++
Rechi
thexai
if (fd < 0) return false; URIUtils::AddSlashAtEnd(strRoot); URIUtils::AddSlashAtEnd(strAuth); lock.lock(); if (!smb.IsSmbValid()) return false; const libsmb_file_info* fi; struct stat st; bool atLeastOneEntry = false; while ((fi = smbc_readdirplus2(fd, &st))) { atLeastOneEntry = true;...
I would prefer `name.starts_with('.')` as it is save in case `name` is empty for some weird reason.
if (fd < 0) return false; URIUtils::AddSlashAtEnd(strRoot); URIUtils::AddSlashAtEnd(strAuth); lock.lock(); if (!smb.IsSmbValid()) return false; const libsmb_file_info* fi; struct stat st; bool atLeastOneEntry = false; while ((fi = smbc_readdirplus2(fd, &st))) { atLeastOneEntry = true;...
@@ -116,7 +116,7 @@ bool CSMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) int64_t size = 0; const bool isDir = S_ISDIR(st.st_mode); int64_t timeDate = 0; - bool hidden = StringUtils::StartsWith(name, "."); + bool hidden = name.front() == '.';
xbmc/platform/posix/filesystem/SMBDirectory.cpp
26
C++
0.571
suggestion
99
51
51
false
SMBDirectory: remove dependence on StringUtils and modernize logs
27,096
xbmc/xbmc
17,740
C++
neo1973
thexai
static bool ParseXML(const AddonInfoPtr& addon, const tinyxml2::XMLElement* element, const std::string& addonPath, const RepositoryDirInfo& repo); static bool ParseXMLTypes(CAddonType& addonType, const AddonInfoPtr& inf...
Nope. This is no different from `SetId`, `SetName`, etc., it's just clang-tidys heuristics that are not good enough to see that. Same with `SetChangelog` below.
static bool ParseXML(const AddonInfoPtr& addon, const tinyxml2::XMLElement* element, const std::string& addonPath, const RepositoryDirInfo& repo); static bool ParseXMLTypes(CAddonType& addonType, const AddonInfoPtr& inf...
@@ -85,9 +85,9 @@ class CAddonInfoBuilderFromDB void SetId(std::string id); void SetName(std::string name); void SetLicense(std::string license); - void SetSummary(std::string summary); - void SetDescription(std::string description); - void SetDisclaimer(std::string disclaimer); + void SetSummary(const std...
xbmc/addons/addoninfo/AddonInfoBuilder.h
26
C/C++
0.714
suggestion
163
51
51
false
[clang-tidy] fix performance-* warnings
27,105
xbmc/xbmc
17,740
C++
neo1973
Rechi
{ CLog::LogF(LOGERROR, "Failed to open video database!"); return false; } // Select the playlist using the simple menu const std::string oldPath{item->GetDynPath()}; item->SetProperty("force_playlist_selection", true); const int idMovie{m_database.GetMovieId(oldPath)}; if (CGUIDialogSimpleMenu::...
I'd get rid of `oldItem` and use `item` directly.
{ CLog::LogF(LOGERROR, "Failed to open video database!"); return false; } // Select the playlist using the simple menu const std::string oldPath{item->GetDynPath()}; item->SetProperty("force_playlist_selection", true); const int idMovie{m_database.GetMovieId(oldPath)}; if (CGUIDialogSimpleMenu::...
@@ -354,7 +354,7 @@ bool CGUIDialogVideoManagerVersions::ChoosePlaylist(const std::shared_ptr<CFileI item->GetDynPath()); // Notify all windows to update the file item - std::shared_ptr<CFileItem> oldItem{item}; + const std::shared_ptr<CFileItem>& old...
xbmc/video/dialogs/GUIDialogVideoManagerVersions.cpp
26
C++
0.5
suggestion
49
51
51
false
[clang-tidy] fix performance-* warnings
27,105
xbmc/xbmc
17,740
C++
neo1973
Rechi
and returns it. This methods goes through the given path and removes any "." (as it states "this directory") and resolves any ".." by removing the previous directory from the path. This is done for file paths and host names (in case of VFS paths). \param path Path to be cleaned up \return Actual ...
out of curiousity. why not only declare the `const CURL&` function and define it like this? ```cpp CURL URIUtils::AddCredentials(const CURL& url) { CURL authUrl{url}; if (CPasswordManager::GetInstance().IsURLSupported(authUrl) && authUrl.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateU...
and returns it. This methods goes through the given path and removes any "." (as it states "this directory") and resolves any ".." by removing the previous directory from the path. This is done for file paths and host names (in case of VFS paths). \param path Path to be cleaned up \return Actual ...
@@ -332,6 +332,9 @@ class URIUtils */ static bool UpdateUrlEncoding(std::string &strFilename); + static CURL AddCredentials(const CURL& url); + static CURL AddCredentials(CURL&& url);
xbmc/utils/URIUtils.h
26
C/C++
1
security
490
40
39
false
[PasswordManager] Factor out common credentials code.
27,117
xbmc/xbmc
17,740
C++
howie-f
damienruscoe
url.Parse(stackPath); } // if the protocol has an encoded hostname we need to work with its hostname else if (URIUtils::HasEncodedHostname(url)) { std::string hostname = url.GetHostName(); UpdateUrlEncoding(hostname); url.SetHostName(hostname); } else return false; std::string newFile...
One single function can handle both cases: ```cpp CURL URIUtils::AddCredentials(CURL authUrl) { if (CPasswordManager::GetInstance().IsURLSupported(authUrl) && authUrl.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(authUrl); return authUrl; } ```
url.Parse(stackPath); } // if the protocol has an encoded hostname we need to work with its hostname else if (URIUtils::HasEncodedHostname(url)) { std::string hostname = url.GetHostName(); UpdateUrlEncoding(hostname); url.SetHostName(hostname); } else return false; std::string newFile...
@@ -1721,3 +1722,15 @@ bool URIUtils::UpdateUrlEncoding(std::string &strFilename) strFilename = newFilename; return true; } + +CURL URIUtils::AddCredentials(const CURL& url) +{ + return AddCredentials(CURL(url)); +} + +CURL URIUtils::AddCredentials(CURL&& authUrl) +{ + if (CPasswordManager::GetInstance().IsURL...
xbmc/utils/URIUtils.cpp
26
C++
1
security
285
32
27
false
[PasswordManager] Factor out common credentials code.
27,117
xbmc/xbmc
17,740
C++
neo1973
damienruscoe
{ CURL realURL = URIUtils::SubstitutePath(url); if (!pDirectory) return false; // check our cache for this path if (g_directoryCache.GetDirectory(realURL, items, (hints.flags & DIR_FLAG_READ_CACHE) == DIR_FLAG_READ_CACHE)) items.SetURL(url); else ...
If you want to save on copies then you should use `std::move`: ```suggestion authUrl = URIUtils::AddCredentials(std::move(authUrl)); ``` There are a couple more locations below where it would make sense.
{ CURL realURL = URIUtils::SubstitutePath(url); if (!pDirectory) return false; // check our cache for this path if (g_directoryCache.GetDirectory(realURL, items, (hints.flags & DIR_FLAG_READ_CACHE) == DIR_FLAG_READ_CACHE)) items.SetURL(url); else ...
@@ -183,17 +183,15 @@ bool CDirectory::GetDirectory(const CURL& url, g_directoryCache.ClearDirectory(realURL); pDirectory->SetFlags(hints.flags); + items.SetURL(url); bool result = false; CURL authUrl = realURL; while (!result) { // don't change auth if it...
xbmc/filesystem/Directory.cpp
26
C++
1
security
216
51
51
false
[PasswordManager] Factor out common credentials code.
27,117
xbmc/xbmc
17,740
C++
neo1973
damienruscoe
#include <system_error> #include <vector> #include <fmt/xchar.h> using namespace ADDON; CURL::~CURL() = default; void CURL::Reset() { m_strHostName.clear(); m_strDomain.clear(); m_strUserName.clear(); m_strPassword.clear(); m_strShareName.clear(); m_strFileName.clear(); m_strProtocol.clear(); m_strF...
nice cleanup of legacy code, thanks. i'd just move those definitions into the header. +1 for adding tests
#include <system_error> #include <vector> #include <fmt/xchar.h> using namespace ADDON; CURL::CURL(std::string strURL) { Parse(std::move(strURL)); } bool CURL::operator==(const CURL& url) const { return url == Get(); } bool operator==(const CURL& url, const std::string& str) { return url.Get() == str; } boo...
@@ -32,7 +32,25 @@ using namespace ADDON; -CURL::~CURL() = default; +CURL::CURL(std::string strURL) +{ + Parse(std::move(strURL)); +} + +bool CURL::operator==(const CURL& url) const +{ + return url == Get(); +} + +bool operator==(const CURL& url, const std::string& str) +{ + return url.Get() == str; +} + +bool ...
xbmc/URL.cpp
26
C++
0.5
suggestion
105
51
51
false
[PasswordManager] Factor out common credentials code.
27,117
xbmc/xbmc
17,740
C++
howie-f
damienruscoe
#include <system_error> #include <vector> #include <fmt/xchar.h> using namespace ADDON; CURL::~CURL() = default; void CURL::Reset() { m_strHostName.clear(); m_strDomain.clear(); m_strUserName.clear(); m_strPassword.clear(); m_strShareName.clear(); m_strFileName.clear(); m_strProtocol.clear(); m_strF...
something looks wrong to me here. both `operator==` are the same (only parameters order is swapped) but the return statements differ. ``` return url.Get() == str; return url == str; ```
#include <system_error> #include <vector> #include <fmt/xchar.h> using namespace ADDON; CURL::CURL(std::string strURL) { Parse(std::move(strURL)); } bool CURL::operator==(const CURL& url) const { return url == Get(); } bool operator==(const CURL& url, const std::string& str) { return url.Get() == str; } boo...
@@ -32,7 +32,25 @@ using namespace ADDON; -CURL::~CURL() = default; +CURL::CURL(std::string strURL) +{ + Parse(std::move(strURL)); +} + +bool CURL::operator==(const CURL& url) const +{ + return url == Get(); +} + +bool operator==(const CURL& url, const std::string& str) +{ + return url.Get() == str; +} + +bool ...
xbmc/URL.cpp
26
C++
0.786
bug
189
51
51
false
[PasswordManager] Factor out common credentials code.
27,117
xbmc/xbmc
17,740
C++
howie-f
damienruscoe
{ CLog::Log(LOGERROR, "Database is not present, does the user has CREATE DATABASE permission"); return false; } ret = (mysql_num_rows(result) > 0); mysql_free_result(result); // Check if there is some tables ( to permit user with no create database rights if (ret) { result = mysql_list_table...
works but not sure it's the best way to convert a string_view to string. maybe someone in Slack knows.
{ CLog::Log(LOGERROR, "Database is not present, does the user has CREATE DATABASE permission"); return false; } ret = (mysql_num_rows(result) > 0); mysql_free_result(result); // Check if there is some tables ( to permit user with no create database rights if (ret) { result = mysql_list_table...
@@ -649,9 +649,9 @@ bool MysqlDatabase::exists() // methods for formatting // --------------------------------------------- -std::string MysqlDatabase::vprepare(const char* format, va_list args) +std::string MysqlDatabase::vprepare(std::string_view format, va_list args) { - std::string strFormat = format; + std:...
xbmc/dbwrappers/mysqldataset.cpp
26
C++
0.286
suggestion
102
51
51
false
[dbwrappers] Avoid copies of strings in database queries.
27,118
xbmc/xbmc
17,740
C++
CrystalP
damienruscoe
/* * Copyright (C) 2005-2018 Team Kodi * This file is part of Kodi - https://kodi.tv * * SPDX-License-Identifier: GPL-2.0-or-later * See LICENSES/README.md for more information. */ #include "WinSystemGbmEGLContext.h" #include "OptionalsReg.h" #include "cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.h" #include...
This breaks the abstraction. It would be nice if we could check the next layer up `if (supportsFences())` in CWinSystemGbm which then calls into CDRMUtils of the same call. The atomic and legacy version can then provide overrides if they support using fences or not.
/* * Copyright (C) 2005-2018 Team Kodi * This file is part of Kodi - https://kodi.tv * * SPDX-License-Identifier: GPL-2.0-or-later * See LICENSES/README.md for more information. */ #include "WinSystemGbmEGLContext.h" #include "OptionalsReg.h" #include "cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.h" #include...
@@ -11,6 +11,7 @@ #include "OptionalsReg.h" #include "cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.h" #include "cores/VideoPlayer/VideoRenderers/RenderFactory.h" +#include "drm/DRMAtomic.h"
xbmc/windowing/gbm/WinSystemGbmEGLContext.cpp
14
C++
0.786
refactor
267
39
39
false
CDRMAtomic: don't create egl fence unless atomic drm init was succesful
27,119
xbmc/xbmc
17,740
C++
lrusak
Siberiss
CLog::LogF(LOGERROR, "({}) failed", idSet); } RollbackTransaction(); return -1; } int CVideoDatabase::AddMovieVersion(CFileItem& item, int idMovie, const ART::Artwork& art) { CVideoInfoTag* tag{item.GetVideoInfoTag()}; const int idFile{ AddFile(item.GetDynPath(), "", tag->m_dateAdded, tag->GetPlay...
suggestion, use the other version of SetArtForItem, no loop needed in the caller: ``` if (!SetArtForItem(idFile, MediaTypeVideoVersion, art)) return -1; ```
CLog::LogF(LOGERROR, "({}) failed", idSet); } RollbackTransaction(); return -1; } int CVideoDatabase::AddMovieVersion(CFileItem& item, int idMovie, const ART::Artwork& art) { CVideoInfoTag* tag{item.GetVideoInfoTag()}; const int idFile{ AddFile(item.GetDynPath(), "", tag->m_dateAdded, tag->GetPlay...
@@ -3026,16 +3026,15 @@ int CVideoDatabase::AddMovieVersion(CFileItem& item, int idMovie, const ART::Art if (tag->HasStreamDetails() && !SetStreamDetailsForFileId(tag->m_streamDetails, idFile)) return -1; - const int idVersion{AddVideoVersion(item.GetVideoContentType(), idMovie, idFile, - ...
xbmc/video/VideoDatabase.cpp
26
C++
1
suggestion
166
51
51
false
[Video] Fix fail to update videoversion when updating library.
27,129
xbmc/xbmc
17,740
C++
CrystalP
78andyp
CommitTransaction(); return idSet; } catch (...) { CLog::LogF(LOGERROR, "({}) failed", idSet); } RollbackTransaction(); return -1; } int CVideoDatabase::AddMovieVersion(CFileItem& item, int idMovie, const ART::Artwork& art) { CVideoInfoTag* tag{item.GetVideoInfoTag()}; const int idFile{ ...
uh? I missed something or this calls the non-updating function and doesn't fix the bug. Since this is the only caller, only AddOrUpdateVideoVersion (without the existsAction) is needed. To follow the existing patterns more closely please make idFile the first parameter. It will be fine as a quick fix, but later o...
CommitTransaction(); return idSet; } catch (...) { CLog::LogF(LOGERROR, "({}) failed", idSet); } RollbackTransaction(); return -1; } int CVideoDatabase::AddMovieVersion(CFileItem& item, int idMovie, const ART::Artwork& art) { CVideoInfoTag* tag{item.GetVideoInfoTag()}; const int idFile{ ...
@@ -3026,16 +3026,15 @@ int CVideoDatabase::AddMovieVersion(CFileItem& item, int idMovie, const ART::Art if (tag->HasStreamDetails() && !SetStreamDetailsForFileId(tag->m_streamDetails, idFile)) return -1; - const int idVersion{AddVideoVersion(item.GetVideoContentType(), idMovie, idFile, - ...
xbmc/video/VideoDatabase.cpp
26
C++
0.714
bug
394
51
51
false
[Video] Fix fail to update videoversion when updating library.
27,129
xbmc/xbmc
17,740
C++
CrystalP
78andyp
VideoAssetType assetType) { return AddOrUpdateVideoVersion(itemType, dbIdSource, idFile, idVideoVersion, assetType, FileExistsAction::ACTION_NONE); } bool CVideoDatabase::AddOrUpdateVideoVersion(VideoDbContentType itemType, ...
as mentioned in other comment, the INSERT only behavior is not needed.
{ if (!m_pDB || !m_pDS) return false; std::string sql; try { sql = PrepareSQL("SELECT 1 FROM videoversion WHERE idFile=%i", idFile); m_pDS->query(sql); if (m_pDS->num_rows() > 0) { m_pDS->close(); sql = PrepareSQL("UPDATE videoversion " "SET idMedia = %i,...
@@ -13425,31 +13424,65 @@ bool CVideoDatabase::ConvertVideoToVersion(VideoDbContentType itemType, return true; } -int CVideoDatabase::AddVideoVersion(VideoDbContentType itemType, - int dbIdSource, - int idFile, - ...
xbmc/video/VideoDatabase.cpp
26
C++
0.143
suggestion
70
51
51
false
[Video] Fix fail to update videoversion when updating library.
27,129
xbmc/xbmc
17,740
C++
CrystalP
78andyp
const int idSet{m_database.AddSet(movieDetails.m_strTitle)}; m_database.SetArtForItem(idSet, MediaTypeVideoCollection, art); movieDetails.SetSet(movieDetails.m_strTitle); } } // Add '(Disc n)' to title (in local language) movieDetails.m_strTitle = ...
maybe, depends on usage of movieDetails afterwards. Did you check?
} lResult = m_database.SetDetailsForMovie(movieDetails, art); movieDetails.m_iDbId = lResult; movieDetails.m_type = MediaTypeMovie; // setup links to shows if the linked shows are in the db for (unsigned int i=0; i < movieDetails.m_showLink.size(); ++i) { CFileItemLis...
@@ -1965,7 +1965,7 @@ CVideoInfoScanner::~CVideoInfoScanner() if (idMovie != -1) { lResult = m_database.AddMovieVersion(*pItem, idMovie, art); - movieDetails.m_iDbId = static_cast<int>(lResult); + movieDetails.m_iDbId = idMovie;
xbmc/video/VideoInfoScanner.cpp
26
C++
0.143
question
66
51
51
false
[Video] Fix fail to update videoversion when updating library.
27,129
xbmc/xbmc
17,740
C++
CrystalP
78andyp
/* * Copyright (C) 2011-2018 Team Kodi * This file is part of Kodi - https://kodi.tv * * SPDX-License-Identifier: GPL-2.0-or-later * See LICENSES/README.md for more information. */ #pragma once #include "FileItem.h" #include "FileItemList.h" #include "IDirectory.h" #include "NFSFile.h" #include <vector> s...
FileItem.h actually needs not to be included in this header file. For `CFileItemPtr` use the native type instead of the typedef from FileItem.h . Include `<memory>`, put `class CFileItem;` in this header and replace `CFileItemPtr` occurrences with `std::shared_ptr<CFileItem>`.
/* * Copyright (C) 2011-2018 Team Kodi * This file is part of Kodi - https://kodi.tv * * SPDX-License-Identifier: GPL-2.0-or-later * See LICENSES/README.md for more information. */ #pragma once #include "IDirectory.h" #include "NFSFile.h" #include <memory> #include <vector> class CFileItem; struct nfsdire...
@@ -8,9 +8,13 @@ #pragma once +#include "FileItem.h" +#include "FileItemList.h"
xbmc/filesystem/NFSDirectory.h
12
C/C++
1
suggestion
280
37
37
false
NFSDirectory: Remove duplicate header and improve logs
27,133
xbmc/xbmc
17,740
C++
ksooo
thexai
/* * Copyright (C) 2011-2018 Team Kodi * This file is part of Kodi - https://kodi.tv * * SPDX-License-Identifier: GPL-2.0-or-later * See LICENSES/README.md for more information. */ #pragma once #include "IDirectory.h" #include "NFSFile.h" #include <memory> #include <vector> class CFileItem; class CFileIte...
There is this method defined in the header: ```c++ CacheType GetCacheType(const CURL& url) const override { return CacheType::ONCE; } ``` For `CacheType::ONCE` you need to include `CFileItemList.h`, where this value is defined. Alternatively, you could outline the implementation.
/* * Copyright (C) 2011-2018 Team Kodi * This file is part of Kodi - https://kodi.tv * * SPDX-License-Identifier: GPL-2.0-or-later * See LICENSES/README.md for more information. */ #pragma once #include "IDirectory.h" #include "NFSFile.h" #include <memory> #include <vector> class CFileItem; struct nfsdire...
@@ -11,6 +11,11 @@ #include "IDirectory.h" #include "NFSFile.h" +#include <memory> +#include <vector> + +class CFileItem; +class CFileItemList;
xbmc/filesystem/NFSDirectory.h
18
C/C++
1
performance
292
42
41
false
NFSDirectory: Remove duplicate header and improve logs
27,133
xbmc/xbmc
17,740
C++
ksooo
thexai
class CURL; class CAdvancedSettings; class CFileItem; /*! \brief Defines the methodology to find hosts on a given subnet \sa IsHostOnLAN */ enum class LanCheckMode { /*! \brief Only match if the host is on the same subnet as the kodi host */ ONLY_LOCAL_SUBNET, /*! \brief Match the host if it belongs to any...
There is basically never a situation where passing a `std::string_view` by const reference is better than passing by value. ```suggestion static std::string URLEncode(std::string_view strURLData, std::string_view URLSpec = RFC1738); ```
class CURL; class CAdvancedSettings; class CFileItem; /*! \brief Defines the methodology to find hosts on a given subnet \sa IsHostOnLAN */ enum class LanCheckMode { /*! \brief Only match if the host is on the same subnet as the kodi host */ ONLY_LOCAL_SUBNET, /*! \brief Match the host if it belongs to any...
@@ -29,6 +29,15 @@ enum class LanCheckMode class URIUtils { public: + // Don't URL encode "-_.!()" according to RFC1738 + //! @todo Update it to "-_.~" after Gotham according to RFC3986 + static constexpr std::string_view RFC1738{"-._!()"}; + static constexpr std::string_view RFC3986{"-_.~"}; + + static std::st...
xbmc/utils/URIUtils.h
26
C/C++
1
suggestion
241
51
51
false
[URIUtils] Added tests around URL Encoding and Decoding.
27,134
xbmc/xbmc
17,740
C++
neo1973
damienruscoe
#include <algorithm> #include <cassert> #include <charconv> #include <ranges> #include <vector> #include <arpa/inet.h> #include <netinet/in.h> using namespace PVR; using namespace XFILE; const CAdvancedSettings* URIUtils::m_advancedSettings = nullptr; namespace { constexpr std::string_view DecodeURLSpecialChars{"+...
If your length is only two the `[2]` de-references a value after the string. You have to use pointer arithmetic to create the end iterator. ```suggestion const auto res = std::from_chars(encoded.data(), encoded.data() + 2, decimal, 16); ```
#include <algorithm> #include <cassert> #include <charconv> #include <ranges> #include <vector> #include <arpa/inet.h> #include <netinet/in.h> using namespace PVR; using namespace XFILE; const CAdvancedSettings* URIUtils::m_advancedSettings = nullptr; namespace { constexpr std::string_view DecodeURLSpecialChars{"+...
@@ -44,6 +45,69 @@ using namespace XFILE; const CAdvancedSettings* URIUtils::m_advancedSettings = nullptr; +namespace +{ + +constexpr std::string_view DecodeURLSpecialChars{"+%"}; + +std::optional<char> DecodeOctlet(std::string_view& encoded) +{ + if (encoded.length() < 2) + return {}; + + uint8_t decimal{}; ...
xbmc/utils/URIUtils.cpp
26
C++
1
suggestion
245
51
51
false
[URIUtils] Added tests around URL Encoding and Decoding.
27,134
xbmc/xbmc
17,740
C++
neo1973
damienruscoe
#include <charconv> #include <ranges> #include <vector> #include <arpa/inet.h> #include <netinet/in.h> using namespace PVR; using namespace XFILE; const CAdvancedSettings* URIUtils::m_advancedSettings = nullptr; namespace { constexpr std::string_view DecodeURLSpecialChars{"+%"}; std::optional<char> DecodeOctlet(s...
For the same reason as above: ```suggestion if (res.ec != std::errc() || res.ptr != encoded.data() + 2) ```
#include <charconv> #include <ranges> #include <vector> #include <arpa/inet.h> #include <netinet/in.h> using namespace PVR; using namespace XFILE; const CAdvancedSettings* URIUtils::m_advancedSettings = nullptr; namespace { constexpr std::string_view DecodeURLSpecialChars{"+%"}; std::optional<char> DecodeOctlet(s...
@@ -44,6 +45,69 @@ using namespace XFILE; const CAdvancedSettings* URIUtils::m_advancedSettings = nullptr; +namespace +{ + +constexpr std::string_view DecodeURLSpecialChars{"+%"}; + +std::optional<char> DecodeOctlet(std::string_view& encoded) +{ + if (encoded.length() < 2) + return {}; + + uint8_t decimal{}; ...
xbmc/utils/URIUtils.cpp
26
C++
1
suggestion
112
51
51
false
[URIUtils] Added tests around URL Encoding and Decoding.
27,134
xbmc/xbmc
17,740
C++
neo1973
damienruscoe
const auto res = std::from_chars(&encoded[0], &encoded[2], decimal, 16); if (res.ec != std::errc() || res.ptr != &encoded[2]) return {}; encoded = encoded.substr(2); return decimal; } } // Unnamed namespace std::string URIUtils::URLDecode(std::string_view encoded) { /* result will always be less than ...
```suggestion const char specialChar = encoded[special]; ```
const auto res = std::from_chars(encoded.data(), encoded.data() + 2, decimal, 16); if (res.ec != std::errc() || res.ptr != encoded.data() + 2) return {}; encoded = encoded.substr(2); return decimal; } } // Unnamed namespace std::string URIUtils::URLDecode(std::string_view encoded) { /* result will alw...
@@ -44,6 +45,69 @@ using namespace XFILE; const CAdvancedSettings* URIUtils::m_advancedSettings = nullptr; +namespace +{ + +constexpr std::string_view DecodeURLSpecialChars{"+%"}; + +std::optional<char> DecodeOctlet(std::string_view& encoded) +{ + if (encoded.length() < 2) + return {}; + + uint8_t decimal{}; ...
xbmc/utils/URIUtils.cpp
26
C++
0.857
suggestion
66
51
51
false
[URIUtils] Added tests around URL Encoding and Decoding.
27,134
xbmc/xbmc
17,740
C++
neo1973
damienruscoe
} // Unnamed namespace std::string URIUtils::URLDecode(std::string_view encoded) { /* result will always be less than or equal to source */ std::string decodedUrl{}; decodedUrl.reserve(encoded.length()); while (true) { const auto special = encoded.find_first_of(DecodeURLSpecialChars); decodedUrl +=...
```suggestion if (specialChar == '+') decodedUrl += ' '; else decodedUrl += DecodeOctlet(encoded).value_or('%'); ```
} // Unnamed namespace std::string URIUtils::URLDecode(std::string_view encoded) { /* result will always be less than or equal to source */ std::string decodedUrl{}; decodedUrl.reserve(encoded.length()); while (true) { const auto special = encoded.find_first_of(DecodeURLSpecialChars); decodedUrl +=...
@@ -44,6 +45,69 @@ using namespace XFILE; const CAdvancedSettings* URIUtils::m_advancedSettings = nullptr; +namespace +{ + +constexpr std::string_view DecodeURLSpecialChars{"+%"}; + +std::optional<char> DecodeOctlet(std::string_view& encoded) +{ + if (encoded.length() < 2) + return {}; + + uint8_t decimal{}; ...
xbmc/utils/URIUtils.cpp
26
C++
1
suggestion
141
51
51
false
[URIUtils] Added tests around URL Encoding and Decoding.
27,134
xbmc/xbmc
17,740
C++
neo1973
damienruscoe
if (special == std::string::npos) break; const char& specialChar = encoded[special]; encoded = encoded.substr(special + 1); if (specialChar == '+') decodedUrl += ' '; else if (auto decoded = DecodeOctlet(encoded); decoded) decodedUrl += *decoded; // Decoded octet triplet '%2f' ...
No need for a temporary string: ```suggestion fmt::format_to(std::ostreambuf_iterator(oss), "%{:02x}", ch); ```
if (special == std::string::npos) break; const char specialChar = encoded[special]; encoded = encoded.substr(special + 1); if (specialChar == '+') decodedUrl += ' '; else decodedUrl += DecodeOctlet(encoded).value_or('%'); // Decoded octet triplet '%2f' } return decodedUrl; }...
@@ -44,6 +45,69 @@ using namespace XFILE; const CAdvancedSettings* URIUtils::m_advancedSettings = nullptr; +namespace +{ + +constexpr std::string_view DecodeURLSpecialChars{"+%"}; + +std::optional<char> DecodeOctlet(std::string_view& encoded) +{ + if (encoded.length() < 2) + return {}; + + uint8_t decimal{}; ...
xbmc/utils/URIUtils.cpp
26
C++
1
suggestion
120
51
51
false
[URIUtils] Added tests around URL Encoding and Decoding.
27,134
xbmc/xbmc
17,740
C++
neo1973
damienruscoe
const char& specialChar = encoded[special]; encoded = encoded.substr(special + 1); if (specialChar == '+') decodedUrl += ' '; else if (auto decoded = DecodeOctlet(encoded); decoded) decodedUrl += *decoded; // Decoded octet triplet '%2f' else decodedUrl += '%'; } return decod...
Move the string out of the `std::ostringstream` instead of creating a copy: ```suggestion return std::move(oss).str(); ```
const char specialChar = encoded[special]; encoded = encoded.substr(special + 1); if (specialChar == '+') decodedUrl += ' '; else decodedUrl += DecodeOctlet(encoded).value_or('%'); // Decoded octet triplet '%2f' } return decodedUrl; } std::string URIUtils::URLEncode(std::string_view ...
@@ -44,6 +45,69 @@ using namespace XFILE; const CAdvancedSettings* URIUtils::m_advancedSettings = nullptr; +namespace +{ + +constexpr std::string_view DecodeURLSpecialChars{"+%"}; + +std::optional<char> DecodeOctlet(std::string_view& encoded) +{ + if (encoded.length() < 2) + return {}; + + uint8_t decimal{}; ...
xbmc/utils/URIUtils.cpp
26
C++
1
suggestion
127
51
51
false
[URIUtils] Added tests around URL Encoding and Decoding.
27,134
xbmc/xbmc
17,740
C++
neo1973
damienruscoe
EXPECT_TRUE(URIUtils::UpdateUrlEncoding(oldUrl)); EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str()); oldUrl = "zip://%2fpath%2fto%2farchive%2fsome%2darchive%2efile%2ezip/video.avi"; newUrl = "zip://%2fpath%2fto%2farchive%2fsome-archive.file.zip/video.avi"; EXPECT_TRUE(URIUtils::UpdateUrlEncoding(oldUrl)); ...
```suggestion std::string_view input; std::string_view encoded; ```
EXPECT_TRUE(URIUtils::UpdateUrlEncoding(oldUrl)); EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str()); oldUrl = "zip://%2fpath%2fto%2farchive%2fsome%2darchive%2efile%2ezip/video.avi"; newUrl = "zip://%2fpath%2fto%2farchive%2fsome-archive.file.zip/video.avi"; EXPECT_TRUE(URIUtils::UpdateUrlEncoding(oldUrl)); ...
@@ -645,6 +645,149 @@ TEST_F(TestURIUtils, UpdateUrlEncoding) EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str()); } +struct URLEncodings +{ + std::string input; + std::string encoded;
xbmc/utils/test/TestURIUtils.cpp
26
C++
0.857
suggestion
74
51
51
false
[URIUtils] Added tests around URL Encoding and Decoding.
27,134
xbmc/xbmc
17,740
C++
neo1973
damienruscoe
oldUrl = "zip://%2fpath%2fto%2farchive%2fsome%2darchive%2efile%2ezip/video.avi"; newUrl = "zip://%2fpath%2fto%2farchive%2fsome-archive.file.zip/video.avi"; EXPECT_TRUE(URIUtils::UpdateUrlEncoding(oldUrl)); EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str()); oldUrl = "/path/to/some/long%2dnamed%2efile"; newU...
When using `std::string_view` this and the following arrays can be `constexpr`.
oldUrl = "zip://%2fpath%2fto%2farchive%2fsome%2darchive%2efile%2ezip/video.avi"; newUrl = "zip://%2fpath%2fto%2farchive%2fsome-archive.file.zip/video.avi"; EXPECT_TRUE(URIUtils::UpdateUrlEncoding(oldUrl)); EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str()); oldUrl = "/path/to/some/long%2dnamed%2efile"; newU...
@@ -645,6 +645,149 @@ TEST_F(TestURIUtils, UpdateUrlEncoding) EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str()); } +struct URLEncodings +{ + std::string input; + std::string encoded; +}; + +URLEncodings EncodingTestData[] = {
xbmc/utils/test/TestURIUtils.cpp
26
C++
0.357
suggestion
79
51
51
false
[URIUtils] Added tests around URL Encoding and Decoding.
27,134
xbmc/xbmc
17,740
C++
neo1973
damienruscoe
const kodi::addon::InputstreamContentlightMetadata& contentLightMetadata) { m_contentLightMetadata = contentLightMetadata; m_cStructure->m_contentLightMetadata = m_contentLightMetadata; } /// @brief To get with @ref SetContentLightMetadata changed values. const kodi::addon::InputstreamContentligh...
i find this implementation rusty, it dont follow in same way other implementations of other properties also i dont see pointer distruction in safe ways imo it should be implemented with `CStructHdl` that take care of pointer and not use raw pointer directly as done here you can take a look for example at `Inputst...
void SetCryptoSession(const kodi::addon::StreamCryptoSession& cryptoSession) { m_cryptoSession = cryptoSession; memcpy(&m_cStructure->m_cryptoSession, m_cryptoSession.GetCStructure(), sizeof(STREAM_CRYPTO_SESSION)); } /// @brief To get with @ref GetCryptoSession changed values. const kodi:...
@@ -902,6 +903,18 @@ class ATTR_DLL_LOCAL InputstreamInfo : public CStructHdl<InputstreamInfo, INPUTS /// @brief Clear content light static Metadata. void ClearContentLightMetadata() { m_cStructure->m_contentLightMetadata = nullptr; } + /// @brief Sets a pre-allocated DVCC metadata pointer. + /// + /// @para...
xbmc/addons/kodi-dev-kit/include/kodi/addon-instance/Inputstream.h
26
C/C++
0.857
suggestion
347
51
51
false
Add dvcc metadata to InputStream interface
27,136
xbmc/xbmc
17,740
C++
CastagnaIT
cscd98
std::vector<CFileItemPtr> fileItems; do { std::wstring itemNameW(findData.cFileName); if (itemNameW == L"." || itemNameW == L".." || itemNameW.empty()) continue; std::string itemName; if (!g_charsetConverter.wToUTF8(itemNameW, itemName, true) || itemName.empty()) { CLog::LogF(LOGE...
Was there a reason to move this down compared with the original?
if (FileTimeToLocalFileTime(reinterpret_cast<FileTime*>(&findData.ftLastWriteTime), &localTime) == TRUE) pItem->SetDateTime(localTime); else { CDateTime dt{pItem->GetDateTime()}; dt.SetValid(false); pItem->SetDateTime(dt); } if (!pItem->IsFolde...
@@ -157,37 +187,28 @@ bool CWin32SMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) continue; } - CFileItemPtr pItem(new CFileItem(itemName)); + bool isDir = (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; + bool isHidden = + (findData.dwFileAttributes & (FILE_A...
xbmc/platform/win32/filesystem/Win32SMBDirectory.cpp
26
C++
0.357
refactor
64
51
51
false
[filesystem] Apply GetDirectory optimizations to SMB filesystems
27,139
xbmc/xbmc
17,740
C++
CrystalP
damienruscoe
{ std::wstring itemNameW(findData.cFileName); if (itemNameW == L"." || itemNameW == L".." || itemNameW.empty()) continue; std::string itemName; if (!g_charsetConverter.wToUTF8(itemNameW, itemName, true) || itemName.empty()) { CLog::LogF(LOGERROR, "Can't convert wide string item name t...
Since you're trying to eliminate copies, I think there is an opportunity here to move the item path. Current signature takes a string_view. there will be at least a copy inside SetPath to go string_view > string.
pItem->SetDateTime(localTime); else { CDateTime dt{pItem->GetDateTime()}; dt.SetValid(false); pItem->SetDateTime(dt); } if (!pItem->IsFolder()) pItem->SetSize((__int64(findData.nFileSizeHigh) << 32) + findData.nFileSizeLow); items.Add(pItem); } while (FindNextFileW(h...
@@ -157,37 +187,28 @@ bool CWin32SMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) continue; } - CFileItemPtr pItem(new CFileItem(itemName)); + bool isDir = (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; + bool isHidden = + (findData.dwFileAttributes & (FILE_A...
xbmc/platform/win32/filesystem/Win32SMBDirectory.cpp
26
C++
0.571
suggestion
212
51
51
false
[filesystem] Apply GetDirectory optimizations to SMB filesystems
27,139
xbmc/xbmc
17,740
C++
CrystalP
damienruscoe
#include "URL.h" #include "utils/CharsetConverter.h" #include "utils/XTimeUtils.h" #include "utils/log.h" #include "platform/win32/CharsetConverter.h" #include "platform/win32/WIN32Util.h" #include "platform/win32/network/WSDiscoveryWin32.h" #include <Windows.h> #include <Winnetwk.h> #pragma comment(lib, "mpr.lib") ...
This method not has much value because only is called from one place and is only one line of code. Maybe remove and use the code in place or keep but convert to to `inline` method (this removes the overload of calling a function).
#include "URL.h" #include "utils/CharsetConverter.h" #include "utils/XTimeUtils.h" #include "utils/log.h" #include "platform/win32/CharsetConverter.h" #include "platform/win32/WIN32Util.h" #include "platform/win32/network/WSDiscoveryWin32.h" #include <Windows.h> #include <Winnetwk.h> #pragma comment(lib, "mpr.lib") ...
@@ -34,6 +34,35 @@ using namespace XFILE; using KODI::PLATFORM::WINDOWS::FromW; +namespace +{ + +uint64_t GetEntrySize(const WIN32_FIND_DATAW& findData)
xbmc/platform/win32/filesystem/Win32SMBDirectory.cpp
26
C++
0.786
suggestion
233
51
51
false
[filesystem] Apply GetDirectory optimizations to SMB filesystems
27,139
xbmc/xbmc
17,740
C++
thexai
damienruscoe
#include <lm.h> #pragma comment(lib, "Netapi32.lib") #include <cassert> using namespace XFILE; using KODI::PLATFORM::WINDOWS::FromW; namespace { uint64_t GetEntrySize(const WIN32_FIND_DATAW& findData) { return (__int64(findData.nFileSizeHigh) << 32) + findData.nFileSizeLow; } KODI::TIME::FileTime GetEntryTime(...
This line seems copy/paste typo because the next line is same code inside if. Remove this line.
#include <lm.h> #pragma comment(lib, "Netapi32.lib") #include <cassert> using namespace XFILE; using KODI::PLATFORM::WINDOWS::FromW; using KODI::TIME::FileTime; // local helper static inline bool worthTryToConnect(const DWORD lastErr) { return lastErr != ERROR_FILE_NOT_FOUND && lastErr != ERROR_BAD_NET_NAME...
@@ -34,6 +34,35 @@ using namespace XFILE; using KODI::PLATFORM::WINDOWS::FromW; +namespace +{ + +uint64_t GetEntrySize(const WIN32_FIND_DATAW& findData) +{ + return (__int64(findData.nFileSizeHigh) << 32) + findData.nFileSizeLow; +} + +KODI::TIME::FileTime GetEntryTime(CFileItemPtr& item, const WIN32_FIND_DATAW& ...
xbmc/platform/win32/filesystem/Win32SMBDirectory.cpp
26
C++
0.357
refactor
95
51
51
false
[filesystem] Apply GetDirectory optimizations to SMB filesystems
27,139
xbmc/xbmc
17,740
C++
thexai
damienruscoe
#include <cassert> using namespace XFILE; using KODI::PLATFORM::WINDOWS::FromW; namespace { uint64_t GetEntrySize(const WIN32_FIND_DATAW& findData) { return (__int64(findData.nFileSizeHigh) << 32) + findData.nFileSizeLow; } KODI::TIME::FileTime GetEntryTime(CFileItemPtr& item, const WIN32_FIND_DATAW& findData) {...
This `else` is redundant because the if condition return (if if is true). Remove `else`.
#include <cassert> using namespace XFILE; using KODI::PLATFORM::WINDOWS::FromW; using KODI::TIME::FileTime; // local helper static inline bool worthTryToConnect(const DWORD lastErr) { return lastErr != ERROR_FILE_NOT_FOUND && lastErr != ERROR_BAD_NET_NAME && lastErr != ERROR_NO_NET_OR_BAD_PATH && l...
@@ -34,6 +34,35 @@ using namespace XFILE; using KODI::PLATFORM::WINDOWS::FromW; +namespace +{ + +uint64_t GetEntrySize(const WIN32_FIND_DATAW& findData) +{ + return (__int64(findData.nFileSizeHigh) << 32) + findData.nFileSizeLow; +} + +KODI::TIME::FileTime GetEntryTime(CFileItemPtr& item, const WIN32_FIND_DATAW& ...
xbmc/platform/win32/filesystem/Win32SMBDirectory.cpp
26
C++
0.571
suggestion
88
51
51
false
[filesystem] Apply GetDirectory optimizations to SMB filesystems
27,139
xbmc/xbmc
17,740
C++
thexai
damienruscoe
std::vector<CFileItemPtr> fileItems; do { std::wstring itemNameW(findData.cFileName); if (itemNameW == L"." || itemNameW == L".." || itemNameW.empty()) continue; std::string itemName; if (!g_charsetConverter.wToUTF8(itemNameW, itemName, true) || itemName.empty()) { CLog::LogF(LOGE...
Use the real type here instead of the typedef.
// calculation of size and date costs a little on win32 // so DIR_FLAG_NO_FILE_INFO flag is ignored FileTime localTime{}; if (FileTimeToLocalFileTime(reinterpret_cast<FileTime*>(&findData.ftLastWriteTime), &localTime) == TRUE) pItem->SetDateTime(localTime); els...
@@ -157,37 +183,28 @@ bool CWin32SMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) continue; } - CFileItemPtr pItem(new CFileItem(itemName)); + const bool isDir = (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; + const bool isHidden = + (findData.dwFileAttribut...
xbmc/platform/win32/filesystem/Win32SMBDirectory.cpp
26
C++
0.571
suggestion
46
51
51
false
[filesystem] Apply GetDirectory optimizations to SMB filesystems
27,139
xbmc/xbmc
17,740
C++
sundermann
damienruscoe
namespace { KODI::TIME::FileTime GetDirEntryTime(const struct stat& st) { int64_t timeDate = 0; // only stat files that can give proper responses if (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode)) { // if modification date is missing, use create date timeDate = (st.st_mtime == 0) ? st.st_ctime : st.st_m...
const please. same for the next one.
namespace { KODI::TIME::FileTime GetDirEntryTime(const struct stat& st) { int64_t timeDate = 0; // only stat files that can give proper responses if (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode)) { // if modification date is missing, use create date timeDate = (st.st_mtime == 0) ? st.st_ctime : st.st_m...
@@ -40,6 +40,44 @@ using namespace XFILE; +namespace +{ + +KODI::TIME::FileTime GetDirEntryTime(const struct stat& st) +{ + int64_t timeDate = 0; + + // only stat files that can give proper responses + if (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode)) + { + // if modification date is missing, use create date ...
xbmc/platform/posix/filesystem/SMBDirectory.cpp
26
C++
0.071
suggestion
36
51
51
false
[filesystem] Apply GetDirectory optimizations to SMB filesystems
27,139
xbmc/xbmc
17,740
C++
CrystalP
damienruscoe
using namespace XFILE; using KODI::PLATFORM::WINDOWS::FromW; namespace { uint64_t GetEntrySize(const WIN32_FIND_DATAW& findData) { return (__int64(findData.nFileSizeHigh) << 32) + findData.nFileSizeLow; } KODI::TIME::FileTime GetEntryTime(CFileItemPtr& item, const WIN32_FIND_DATAW& findData) { KODI::TIME::File...
The original code was a bit weird - but I think this tangles things more. If I followed correctly, in original and here, item is always a brand new item and there is nothing to retrieve and invalidate since the m_dateTime member is initialized with a default CDateTime, which is in "not valid" state. So might as well ...
using namespace XFILE; using KODI::PLATFORM::WINDOWS::FromW; using KODI::TIME::FileTime; // local helper static inline bool worthTryToConnect(const DWORD lastErr) { return lastErr != ERROR_FILE_NOT_FOUND && lastErr != ERROR_BAD_NET_NAME && lastErr != ERROR_NO_NET_OR_BAD_PATH && lastErr != ERROR_NO_...
@@ -34,6 +34,31 @@ using namespace XFILE; using KODI::PLATFORM::WINDOWS::FromW; +namespace +{ + +uint64_t GetEntrySize(const WIN32_FIND_DATAW& findData) +{ + return (__int64(findData.nFileSizeHigh) << 32) + findData.nFileSizeLow; +} + +KODI::TIME::FileTime GetEntryTime(CFileItemPtr& item, const WIN32_FIND_DATAW& ...
xbmc/platform/win32/filesystem/Win32SMBDirectory.cpp
26
C++
0.643
refactor
376
51
51
false
[filesystem] Apply GetDirectory optimizations to SMB filesystems
27,139
xbmc/xbmc
17,740
C++
CrystalP
damienruscoe
if (bufSize > buf.size()) { // buffer is too small buf.resize(bufSize); // discard buffer content and extend the buffer bufSize = buf.size(); result = WNetEnumResourceW(netEnum, &resCount, buf.data(), reinterpret_cast<LPDWORD>(&bufSize)); if (result != NO_ERROR ||...
```suggestion std::shared_ptr<CFileItem> item = std::make_shared<CFileItem>(remoteNameUtf8); item->SetPath(urlPrefixForItems + remoteNameUtf8 + '/'); item->SetFolder(true); items.Add(pItem); ```
if (remoteName.length() > 2 && remoteName.compare(0, 2, L"\\\\", 2) == 0) { std::string remoteNameUtf8; if (g_charsetConverter.wToUTF8(remoteName.substr(2), remoteNameUtf8, true) && !remoteNameUtf8.empty()) { CFileItemPtr pItem(new CFileI...
@@ -469,7 +488,7 @@ static bool localGetNetworkResources(struct _NETRESOURCEW* basePathToScanPtr, co std::string remoteNameUtf8; if (g_charsetConverter.wToUTF8(remoteName.substr(2), remoteNameUtf8, true) && !remoteNameUtf8.empty()) { - CFileItemPtr pItem(new C...
xbmc/platform/win32/filesystem/Win32SMBDirectory.cpp
26
C++
1
suggestion
258
51
51
false
[filesystem] Apply GetDirectory optimizations to SMB filesystems
27,139
xbmc/xbmc
17,740
C++
sundermann
damienruscoe
} else CLog::LogF(LOGERROR, "Skipping server name \"{}\" without '\\' prefix", FromW(remoteName)); } else CLog::LogF(LOGERROR, "Skipping server with empty remote name"); } /* check and collect shares */ ...
Same here, rename + std::make_shared
if (slashPos < serverShareName.length() - 1) // slash must be not on last position { std::string shareNameUtf8; if (g_charsetConverter.wToUTF8(serverShareName.substr(slashPos + 1), shareNameUtf8, true) && !shareNameUtf8.empty()) { ...
@@ -503,7 +522,7 @@ static bool localGetNetworkResources(struct _NETRESOURCEW* basePathToScanPtr, co std::string shareNameUtf8; if (g_charsetConverter.wToUTF8(serverShareName.substr(slashPos + 1), shareNameUtf8, true) && !shareNameUtf8.empty()) { - CFi...
xbmc/platform/win32/filesystem/Win32SMBDirectory.cpp
26
C++
0.286
suggestion
36
51
51
false
[filesystem] Apply GetDirectory optimizations to SMB filesystems
27,139
xbmc/xbmc
17,740
C++
sundermann
damienruscoe
assert(urlPrefixForItems.compare(0, 6, "smb://", 6) == 0); // 'urlPrefixForItems' must be in form 'smb://[user[:pass]@]ServerName/' assert(urlPrefixForItems.length() > 7); assert(urlPrefixForItems.back() == '/'); CFileItemList locItems; // store items locally until last one is successfully loaded NET_API_ST...
Same here, rename + std::make_shared
{ std::string shareNameUtf8; if (curShare.shi1_netname && curShare.shi1_netname[0] && g_charsetConverter.wToUTF8(curShare.shi1_netname, shareNameUtf8, true) && !shareNameUtf8.empty()) { CFileItemPtr pItem(new CFileItem(shareNameUtf8)); pItem->S...
@@ -615,7 +634,7 @@ static bool localGetShares(const std::wstring& serverNameToScan, const std::stri if (curShare.shi1_netname && curShare.shi1_netname[0] && g_charsetConverter.wToUTF8(curShare.shi1_netname, shareNameUtf8, true) && !shareNameUtf8.empty()) { - CFileItemPtr...
xbmc/platform/win32/filesystem/Win32SMBDirectory.cpp
26
C++
0.286
suggestion
36
51
51
false
[filesystem] Apply GetDirectory optimizations to SMB filesystems
27,139
xbmc/xbmc
17,740
C++
sundermann
damienruscoe
bool IsParentFolder() const; bool IsFileFolder(FileFolderType types = FileFolderType::MASK_ALL) const; bool IsRemovable() const; bool IsPVR() const; bool IsLiveTV() const; bool IsRSS() const; bool IsAndroidApp() const; bool HasVideoVersions() const; bool HasVideoExtras() const; void RemoveExtensio...
This needs a header, i think `<utility>`
bool IsParentFolder() const; bool IsFileFolder(FileFolderType types = FileFolderType::MASK_ALL) const; bool IsRemovable() const; bool IsPVR() const; bool IsLiveTV() const; bool IsRSS() const; bool IsAndroidApp() const; bool HasVideoVersions() const; bool HasVideoExtras() const; void RemoveExtensio...
@@ -219,10 +219,10 @@ class CFileItem : public CGUIListItem, public IArchivable, public ISerializable, SourceType GetDriveType() const { return m_iDriveType; } void SetDriveType(SourceType driveType) { m_iDriveType = driveType; } const CDateTime& GetDateTime() const { return m_dateTime; } - void SetDateTime(c...
xbmc/FileItem.h
26
C/C++
0.286
refactor
40
51
51
false
[filesystem] Apply GetDirectory optimizations to SMB filesystems
27,139
xbmc/xbmc
17,740
C++
garbear
damienruscoe
continue; std::string itemName; if (!g_charsetConverter.wToUTF8(itemNameW, itemName, true) || itemName.empty()) { CLog::LogF(LOGERROR, "Can't convert wide string item name to UTF-8"); continue; } const bool isDir = (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; ...
I think you want ```c++ item->SetDateTime(std::move(*entryTime)); ``` maybe?
FileTime localTime{}; if (FileTimeToLocalFileTime(reinterpret_cast<FileTime*>(&findData.ftLastWriteTime), &localTime) == TRUE) pItem->SetDateTime(localTime); else { CDateTime dt{pItem->GetDateTime()}; dt.SetValid(false); pItem->SetDateTime(dt); ...
@@ -157,37 +181,36 @@ bool CWin32SMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) continue; } - CFileItemPtr pItem(new CFileItem(itemName)); - - pItem->SetFolder((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0); - if (pItem->IsFolder()) - pItem->SetPath(pathWithS...
xbmc/platform/win32/filesystem/Win32SMBDirectory.cpp
26
C++
0.857
question
78
51
51
false
[filesystem] Apply GetDirectory optimizations to SMB filesystems
27,139
xbmc/xbmc
17,740
C++
garbear
damienruscoe
return false; } return (searchErr == ERROR_FILE_NOT_FOUND) ? RealExists(url, false) : false; } } std::string pathWithSlash(authUrl.Get()); assert(!pathWithSlash.empty()); if (pathWithSlash.back() != '/') pathWithSlash.push_back('/'); std::vector<std::shared_ptr<CFileItem>> fileI...
For me this needs to go, it accomplishes nothing and complicates this PR. The code before the last refactor was: if (KODI::TIME::FileTimeToLocalFileTime(&fileTime, &localTime) == TRUE) pItem->m_dateTime = localTime; else pItem->m_dateTime.SetValid(false); which already did nothing, since pItem...
} CFileItemPtr pItem(new CFileItem(itemName)); pItem->SetFolder((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0); if (pItem->IsFolder()) pItem->SetPath(pathWithSlash + itemName + '/'); else pItem->SetPath(pathWithSlash + itemName); if ((findData.dwFileAttributes & (FIL...
@@ -158,35 +182,36 @@ bool CWin32SMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) continue; } - CFileItemPtr pItem(new CFileItem(itemName)); - - pItem->SetFolder((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0); - if (pItem->IsFolder()) - pItem->SetPath(pathWithS...
xbmc/platform/win32/filesystem/Win32SMBDirectory.cpp
26
C++
0.643
refactor
421
51
51
false
[filesystem] Apply GetDirectory optimizations to SMB filesystems
27,139
xbmc/xbmc
17,740
C++
CrystalP
damienruscoe
CURL::GetRedacted(strAuth), errno, strerror(errno)); return false; } struct smbc_dirent* dirent; while ((dirent = smbc_readdir(fd))) { if (dirent->smbc_type != SMBC_FILE_SHARE && dirent->smbc_type != SMBC_SERVER) continue; std::string path(strRoot); //...
```suggestion const auto& item = fileItems.emplace_back(std::make_shared<CFileItem>(dirent->name)); ```
CURL::GetRedacted(strAuth), errno, strerror(errno)); return false; } struct smbc_dirent* dirent; while ((dirent = smbc_readdir(fd))) { if (dirent->smbc_type != SMBC_FILE_SHARE && dirent->smbc_type != SMBC_SERVER) continue; std::string path(strRoot); //...
@@ -188,11 +189,13 @@ bool CSMBDirectory::GetDirectory(const CURL& url, CFileItemList &items) } path = URIUtils::AddFileToFolder(path, dirent->name); URIUtils::AddSlashAtEnd(path); + + CFileItemPtr& item = fileItems.emplace_back(std::make_shared<CFileItem>(dirent->name));
xbmc/platform/posix/filesystem/SMBDirectory.cpp
26
C++
1
suggestion
111
51
51
false
[filesystem] Apply GetDirectory optimizations to SMB filesystems
27,139
xbmc/xbmc
17,740
C++
thexai
damienruscoe
const auto notExcluded = exclusions.end(); if (IsAliasShortcut(root, true)) TranslateAliasShortcut(root); if (!URIUtils::HasSlashAtEnd(root)) root += "/"; DIR *dir = opendir(root.c_str()); if (!dir) return false; struct stat buffer; std::vector<CFileItemPtr> fileItems; struct dirent* en...
Can you replace this typedef with the actual type? Also rename the variable to `item`.
if (IsAliasShortcut(root, true)) TranslateAliasShortcut(root); if (!URIUtils::HasSlashAtEnd(root)) root.push_back('/'); DIR* dir = opendir(root.c_str()); if (!dir) return false; struct stat buffer; std::vector<std::shared_ptr<CFileItem>> fileItems; struct dirent* entry; while ((entry = r...
@@ -34,67 +36,67 @@ bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList &items) { std::string root = url.Get(); + constexpr std::array<std::string_view, 3> exclusions = {".", "..", "lost+found"}; + const auto notExcluded = exclusions.end(); + if (IsAliasShortcut(root, true)) TranslateAlias...
xbmc/platform/posix/filesystem/PosixDirectory.cpp
26
C++
0.857
suggestion
86
51
51
false
[filesystem] Apply GetDirectory optimizations to posix filesystem
27,140
xbmc/xbmc
17,740
C++
sundermann
damienruscoe
using namespace XFILE; CPosixDirectory::CPosixDirectory(void) = default; CPosixDirectory::~CPosixDirectory(void) = default; bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList &items) { std::string root = url.Get(); constexpr std::array<std::string_view, 3> exclusions = {".", "..", "lost+found"}; ...
Use the real type instead of the typedef
CPosixDirectory::CPosixDirectory(void) = default; CPosixDirectory::~CPosixDirectory(void) = default; bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList& items) { std::string root = url.Get(); constexpr std::array<std::string_view, 3> exclusions = {".", "..", "lost+found"}; if (IsAliasShortcut(...
@@ -34,67 +36,67 @@ bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList &items) { std::string root = url.Get(); + constexpr std::array<std::string_view, 3> exclusions = {".", "..", "lost+found"}; + const auto notExcluded = exclusions.end(); + if (IsAliasShortcut(root, true)) TranslateAlias...
xbmc/platform/posix/filesystem/PosixDirectory.cpp
26
C++
0.571
suggestion
40
51
51
false
[filesystem] Apply GetDirectory optimizations to posix filesystem
27,140
xbmc/xbmc
17,740
C++
sundermann
damienruscoe
#include "utils/CharsetConverter.h" #include "utils/StringUtils.h" #include "utils/URIUtils.h" #include "utils/XTimeUtils.h" #include "utils/log.h" #include <dirent.h> #ifdef HAVE_GETMNTENT_R #include <mntent.h> #endif #include <algorithm> #include <sys/stat.h> using namespace XFILE; CPosixDirectory::CPosixDirector...
Is this necessary? The `end()` function is constexpr since C++17 so you can just use that in the condition below without a runtime overhead.
#include "utils/CharsetConverter.h" #include "utils/URIUtils.h" #include "utils/XTimeUtils.h" #include "utils/log.h" #include <dirent.h> #ifdef HAVE_GETMNTENT_R #include <mntent.h> #endif #include <algorithm> #include <sys/stat.h> using namespace XFILE; CPosixDirectory::CPosixDirectory(void) = default; CPosixDirec...
@@ -34,67 +36,67 @@ bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList &items) { std::string root = url.Get(); + constexpr std::array<std::string_view, 3> exclusions = {".", "..", "lost+found"}; + const auto notExcluded = exclusions.end();
xbmc/platform/posix/filesystem/PosixDirectory.cpp
26
C++
0.714
question
140
51
51
false
[filesystem] Apply GetDirectory optimizations to posix filesystem
27,140
xbmc/xbmc
17,740
C++
sundermann
damienruscoe
std::string root = url.Get(); constexpr std::array<std::string_view, 3> exclusions = {".", "..", "lost+found"}; const auto notExcluded = exclusions.end(); if (IsAliasShortcut(root, true)) TranslateAliasShortcut(root); if (!URIUtils::HasSlashAtEnd(root)) root += "/"; DIR *dir = opendir(root.c_str...
Is this equivalent to `URIUtils::AddFileToFolder`? Can there be edge cases where a simple concatenation is wrong?
constexpr std::array<std::string_view, 3> exclusions = {".", "..", "lost+found"}; if (IsAliasShortcut(root, true)) TranslateAliasShortcut(root); if (!URIUtils::HasSlashAtEnd(root)) root.push_back('/'); DIR* dir = opendir(root.c_str()); if (!dir) return false; struct stat buffer; std::vec...
@@ -34,67 +36,67 @@ bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList &items) { std::string root = url.Get(); + constexpr std::array<std::string_view, 3> exclusions = {".", "..", "lost+found"}; + const auto notExcluded = exclusions.end(); + if (IsAliasShortcut(root, true)) TranslateAlias...
xbmc/platform/posix/filesystem/PosixDirectory.cpp
26
C++
0.786
bug
113
51
51
false
[filesystem] Apply GetDirectory optimizations to posix filesystem
27,140
xbmc/xbmc
17,740
C++
sundermann
damienruscoe
#include <dirent.h> #ifdef HAVE_GETMNTENT_R #include <mntent.h> #endif #include <algorithm> #include <sys/stat.h> using namespace XFILE; CPosixDirectory::CPosixDirectory(void) = default; CPosixDirectory::~CPosixDirectory(void) = default; bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList& items) { ...
```suggestion root.push_back('/'); ```
#include <dirent.h> #ifdef HAVE_GETMNTENT_R #include <mntent.h> #endif #include <algorithm> #include <sys/stat.h> using namespace XFILE; CPosixDirectory::CPosixDirectory(void) = default; CPosixDirectory::~CPosixDirectory(void) = default; bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList& items) { ...
@@ -30,71 +32,72 @@ CPosixDirectory::CPosixDirectory(void) = default; CPosixDirectory::~CPosixDirectory(void) = default; -bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList &items) +bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList& items) { std::string root = url.Get(); + con...
xbmc/platform/posix/filesystem/PosixDirectory.cpp
26
C++
0.786
suggestion
44
51
51
false
[filesystem] Apply GetDirectory optimizations to posix filesystem
27,140
xbmc/xbmc
17,740
C++
thexai
damienruscoe
constexpr std::array<std::string_view, 3> exclusions = {".", "..", "lost+found"}; if (IsAliasShortcut(root, true)) TranslateAliasShortcut(root); if (!URIUtils::HasSlashAtEnd(root)) root += "/"; DIR* dir = opendir(root.c_str()); if (!dir) return false; struct stat buffer; std::vector<std::...
```suggestion const auto& item = ```
if (IsAliasShortcut(root, true)) TranslateAliasShortcut(root); if (!URIUtils::HasSlashAtEnd(root)) root.push_back('/'); DIR* dir = opendir(root.c_str()); if (!dir) return false; struct stat buffer; std::vector<std::shared_ptr<CFileItem>> fileItems; struct dirent* entry; while ((entry = ...
@@ -30,71 +32,72 @@ CPosixDirectory::CPosixDirectory(void) = default; CPosixDirectory::~CPosixDirectory(void) = default; -bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList &items) +bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList& items) { std::string root = url.Get(); + con...
xbmc/platform/posix/filesystem/PosixDirectory.cpp
26
C++
0.786
suggestion
44
51
51
false
[filesystem] Apply GetDirectory optimizations to posix filesystem
27,140
xbmc/xbmc
17,740
C++
thexai
damienruscoe
fileItems.emplace_back(std::make_shared<CFileItem>(itemLabel)); // Unix-based readdir implementations may return an incorrect dirent.d_ino value that // is not equal to the (correct) stat() obtained one. In this case the file type // could not be determined and the value of dirent.d_type is...
```suggestion itemPath.push_back('/'); ```
// Unix-based readdir implementations may return an incorrect dirent.d_ino value that // is not equal to the (correct) stat() obtained one. In this case the file type // could not be determined and the value of dirent.d_type is set to DT_UNKNOWN. // In order to get a correct value we have to inc...
@@ -30,71 +32,72 @@ CPosixDirectory::CPosixDirectory(void) = default; CPosixDirectory::~CPosixDirectory(void) = default; -bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList &items) +bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList& items) { std::string root = url.Get(); + con...
xbmc/platform/posix/filesystem/PosixDirectory.cpp
26
C++
0.857
suggestion
52
51
51
false
[filesystem] Apply GetDirectory optimizations to posix filesystem
27,140
xbmc/xbmc
17,740
C++
thexai
damienruscoe
// In order to get a correct value we have to incur the cost of calling stat. bool isDir = entry->d_type == DT_DIR; if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK || !(m_flags & DIR_FLAG_NO_FILE_INFO)) { if (stat(itemPath.c_str(), &buffer) == 0) { ...
```suggestion if (name.starts_with('.')) ``` And you can remove `#include "utils/StringUtils.h"`
if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK || !(m_flags & DIR_FLAG_NO_FILE_INFO)) { if (stat(itemPath.c_str(), &buffer) == 0) { isDir = S_ISDIR(buffer.st_mode); KODI::TIME::FileTime fileTime; KODI::TIME::FileTime localTime; K...
@@ -30,71 +32,72 @@ CPosixDirectory::CPosixDirectory(void) = default; CPosixDirectory::~CPosixDirectory(void) = default; -bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList &items) +bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList& items) { std::string root = url.Get(); + con...
xbmc/platform/posix/filesystem/PosixDirectory.cpp
26
C++
1
suggestion
107
51
51
false
[filesystem] Apply GetDirectory optimizations to posix filesystem
27,140
xbmc/xbmc
17,740
C++
thexai
damienruscoe
// In order to get a correct value we have to incur the cost of calling stat. bool isDir = entry->d_type == DT_DIR; if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK || !(m_flags & DIR_FLAG_NO_FILE_INFO)) { if (stat(itemPath.c_str(), &buffer) == 0) { ...
```suggestion if (name.starts_with('.')) ```
// In order to get a correct value we have to incur the cost of calling stat. bool isDir = entry->d_type == DT_DIR; if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK || !(m_flags & DIR_FLAG_NO_FILE_INFO)) { if (stat(itemPath.c_str(), &buffer) == 0) { ...
@@ -30,71 +31,71 @@ CPosixDirectory::CPosixDirectory(void) = default; CPosixDirectory::~CPosixDirectory(void) = default; -bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList &items) +bool CPosixDirectory::GetDirectory(const CURL& url, CFileItemList& items) { std::string root = url.Get(); + con...
xbmc/platform/posix/filesystem/PosixDirectory.cpp
26
C++
0.857
suggestion
52
51
51
false
[filesystem] Apply GetDirectory optimizations to posix filesystem
27,140
xbmc/xbmc
17,740
C++
thexai
damienruscoe
if (!SortUtils::SortFromDataset(sorting, MediaTypeTvShow, *m_pDS, results)) return false; // get data from returned rows items.Reserve(results.size()); const query_data &data = m_pDS->get_result_set().records; for (const auto &i : results) { const auto targetRow = static_cast<unsign...
no! this belongs to the video infotag and must remain valid.
item->Select(true); itemUrl.AppendPath(std::to_string(movie.m_iFileId)); // Adjust item fields // Use asset name as label instead of the movie name item->SetLabel(movie.GetAssetInfo().GetTitle()); } else { itemUrl.AppendPath(std::to...
@@ -9008,10 +9008,8 @@ bool CVideoDatabase::GetMoviesByWhere(const std::string& strBaseDir, const Filte } } - path = itemUrl.ToString(); - - item->SetPath(path); - item->SetDynPath(movie.m_strFileNameAndPath); + item->SetPath(itemUrl.ToString()); + item->SetDynPa...
xbmc/video/VideoDatabase.cpp
26
C++
0.143
suggestion
60
51
51
false
[CURL] SetPath and SetDynPath should accept string by value.
27,143
xbmc/xbmc
17,740
C++
CrystalP
damienruscoe
{ CLog::LogF(LOGERROR, "unable to update unique ids of ({})", mediaType); } return -1; } int CVideoDatabase::AddUniqueIDs(int mediaId, const char *mediaType, const CVideoInfoTag& details) { int uniqueid = -1; try { if (nullptr == m_pDB) return -1; if (nullptr == m_pDS) return -1; ...
Does the job but I think the caller of the scraper should be responsible of the validation the scraper's output. That way all code can only be in contact with "good" uniqueid data. That means a change in the whereabouts of InfoTagVideo::setUniqueID/setUniqueIDs of the Python API or more centrally CVideoInfoTag::SetUni...
{ CLog::LogF(LOGERROR, "unable to update unique ids of ({})", mediaType); } return -1; } int CVideoDatabase::AddUniqueIDs(int mediaId, const char *mediaType, const CVideoInfoTag& details) { int uniqueid = -1; try { if (nullptr == m_pDB) return -1; if (nullptr == m_pDS) return -1; ...
@@ -1841,6 +1841,14 @@ int CVideoDatabase::AddUniqueIDs(int mediaId, const char *mediaType, const CVide for (const auto& [type, value] : details.GetUniqueIDs()) { int id; + + if (value.empty()) + { + CLog::LogF(LOGWARNING, "Skipped insert empty {} uniqueId for {} with mediaId {}", type...
xbmc/video/VideoDatabase.cpp
26
C++
0.643
suggestion
577
51
51
false
[VideoDatabase] Prevents inserting new empty unique ID's and prevents existing ones from being used to match different versions of the same movie
27,148
xbmc/xbmc
17,740
C++
CrystalP
thexai
} catch (...) { CLog::LogF(LOGERROR, "failed for movie {}", idMovie); } return idFile; } void CVideoDatabase::GetSameVideoItems(const CFileItem& item, CFileItemList& items) { if (!m_pDB || !m_pDS) return; std::vector<int> itemIds; int dbId = item.GetVideoInfoTag()->m_iDbId; MediaType media...
If I remember correctly that query caused a lengthy discussion shortly after videoversions merge, and I will need to look closer. Until then it's safer to validate the inputs from scraper and nfo inputs so the case doesn't happen in the first place, and to remove the existing cases from the db (db bump needed)
void CVideoDatabase::GetSameVideoItems(const CFileItem& item, CFileItemList& items) { if (!m_pDB || !m_pDS) return; std::vector<int> itemIds; int dbId = item.GetVideoInfoTag()->m_iDbId; MediaType mediaType = item.GetVideoInfoTag()->m_type; try { // get items with same unique ids (imdb, tmdb, etc...
@@ -4647,12 +4655,13 @@ void CVideoDatabase::GetSameVideoItems(const CFileItem& item, CFileItemList& ite // note 2: for type 'tmdb' the same value may be used for a movie and a tv episode, only // distinguished by media_type. // @todo make the (value,type) pairs truly unique - m_pDS->query(PrepareSQL(...
xbmc/video/VideoDatabase.cpp
26
C++
0.643
suggestion
314
51
51
false
[VideoDatabase] Prevents inserting new empty unique ID's and prevents existing ones from being used to match different versions of the same movie
27,148
xbmc/xbmc
17,740
C++
CrystalP
thexai
void CMediaPipelineWebOS::UpdateGUISounds(const bool playing) { IAE* activeAE = CServiceBroker::GetActiveAE(); const int guiSoundMode = CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt( CSettings::SETTING_AUDIOOUTPUT_GUISOUNDMODE); if (guiSoundMode != AE_SOUND_IDLE) return; if (playing...
```suggestion bool CMediaPipelineWebOS::Supports(const AVCodecID codec, const bool includeSecure) { if (const auto it = ms_codecMap.find(codec); it != ms_codecMap.end()) return includeSecure || !it->second.isSecure; return false; } ```
return; if (playing) activeAE->SetVolume(0.0); else activeAE->SetVolume(1.0); } std::string CMediaPipelineWebOS::GetAudioInfo() { std::scoped_lock lock(m_audioInfoMutex); return m_audioInfo; } std::string CMediaPipelineWebOS::GetVideoInfo() { std::scoped_lock lock(m_videoInfoMutex); return m_...
@@ -267,9 +279,14 @@ std::string CMediaPipelineWebOS::GetVideoInfo() return m_videoInfo; } -bool CMediaPipelineWebOS::Supports(const AVCodecID codec) +bool CMediaPipelineWebOS::Supports(const AVCodecID codec, bool includeSecure) { - return ms_codecMap.contains(codec); + auto it = ms_codecMap.find(codec); + if...
xbmc/cores/VideoPlayer/MediaPipelineWebOS.cpp
26
C++
1
suggestion
243
51
51
false
webOS: passthrough encrypted data to secure decoder
27,157
xbmc/xbmc
17,740
C++
sundermann
cscd98
m_processInfo.SetAudioBitsPerSample(audioHint.bitspersample); if (Supports(audioHint.codec, audioHint.cryptoSession != nullptr)) m_processInfo.SetAudioDecoderName("starfish-" + std::string(ms_codecMap.at(audioHint.codec).name)); else if (m_audioEncoder...
```suggestion if (m_videoHint.uniqueId != hint.uniqueId || (m_videoHint.width == hint.width && m_videoHint.height == hint.height)) { Flush(true); } m_videoHint = hint; ```
m_mediaAPIs = std::make_unique<StarfishMediaAPIs>(); } if (m_audioHint.codec && m_videoHint.codec) return Load(m_videoHint, m_audioHint); return true; } bool CMediaPipelineWebOS::OpenVideoStream(CDVDStreamInfo hint) { if (!Supports(hint.codec)) { CLog::LogF(LOGERROR, "Unsupported codec: {}", hi...
@@ -345,8 +362,17 @@ bool CMediaPipelineWebOS::OpenVideoStream(CDVDStreamInfo hint) { std::scoped_lock lock(m_videoCriticalSection); SetupBitstreamConverter(hint); + bool flush = true; + + // avoid flush if only resolution of adaptive stream changed + if (m_videoHint.uniqueId == hint.u...
xbmc/cores/VideoPlayer/MediaPipelineWebOS.cpp
26
C++
1
suggestion
214
51
51
false
webOS: passthrough encrypted data to secure decoder
27,157
xbmc/xbmc
17,740
C++
sundermann
cscd98
} void CMediaPipelineWebOS::SetSubtitleDelay(const double delay) { m_subtitleDelay = delay; } bool CMediaPipelineWebOS::Load(CDVDStreamInfo videoHint, CDVDStreamInfo audioHint) { std::scoped_lock videoLock(m_videoCriticalSection); std::scoped_lock audioLock(m_audioCriticalSection); CVariant p; if (videoHi...
```suggestion if (videoHint.cryptoSession || audioHint.cryptoSession) { CryptoSessionSystem keySystem = CRYPTO_SESSION_SYSTEM_NONE; const int svpVersion = m_webOSVersion < 6 ? SVP_VERSION_40 : SVP_VERSION_30; if (audioHint.cryptoSession) { keySystem = audioHint.cryptoSession->keySystem; ...
switch (keySystem) { case CRYPTO_SESSION_SYSTEM_NONE: break; case CRYPTO_SESSION_SYSTEM_CLEARKEY: break; case CRYPTO_SESSION_SYSTEM_WIDEVINE: CLog::Log(LOGDEBUG, "Setting drm type to WIDEVINE_MODULAR with svpVersion {}", svpVersion); p["option"]["externalStream...
@@ -520,12 +546,53 @@ bool CMediaPipelineWebOS::Load(CDVDStreamInfo videoHint, CDVDStreamInfo audioHin std::scoped_lock audioLock(m_audioCriticalSection); CVariant p; - CVariant payloadArgs; if (videoHint.cryptoSession || audioHint.cryptoSession) { - CLog::LogF(LOGERROR, "CryptoSessions unsupported"...
xbmc/cores/VideoPlayer/MediaPipelineWebOS.cpp
26
C++
1
bug
1,540
51
51
false
webOS: passthrough encrypted data to secure decoder
27,157
xbmc/xbmc
17,740
C++
sundermann
cscd98
if (!videoHint.width || !videoHint.height) { CLog::LogF(LOGERROR, "{}", "null size, cannot handle"); return false; } CLog::LogF(LOGDEBUG, "hints: Width {} x Height {}, Fpsrate {} / Fpsscale {}, " "CodecID {}, Level {}, Profile {}, PTS_invalid {}, Tag {}, Extradata-Size: {}", ...
```suggestion contents["DolbyHdrInfo"]["encryptionType"] = videoHint.cryptoSession ? "all" : "clear"; ```
} else { auto buffer = static_cast<CStarfishVideoBuffer*>(m_picture.videoBuffer); const std::unique_ptr<AcbHandle>& acb = buffer->CreateAcbHandle(); if (acb->Id()) { if (!AcbAPI_initialize(acb->Id(), PLAYER_TYPE_MSE, getenv("APPID"), &AcbCallback)) { buffer->ResetAcbHandle(); ...
@@ -551,7 +618,8 @@ bool CMediaPipelineWebOS::Load(CDVDStreamInfo videoHint, CDVDStreamInfo audioHin CVariant& contents = p["option"]["externalStreamingInfo"]["contents"]; if (videoHint.hdrType == StreamHdrType::HDR_TYPE_DOLBYVISION) { - contents["DolbyHdrInfo"]["encryptionType"] = "clear"; //"clear", "bl",...
xbmc/cores/VideoPlayer/MediaPipelineWebOS.cpp
26
C++
1
suggestion
109
51
51
false
webOS: passthrough encrypted data to secure decoder
27,157
xbmc/xbmc
17,740
C++
sundermann
cscd98
videoHint.cryptoSession ? "all" : "clear"; //"bl", "el", "all" contents["DolbyHdrInfo"]["profileId"] = videoHint.dovi.dv_profile; contents["DolbyHdrInfo"]["trackType"] = videoHint.dovi.el_present_flag ? "dual" : "single"; } using namespace KODI::WINDOWING::WAYLAND; const auto winSystem = dynamic_...
```suggestion contents["codec"]["video"] = std::string(ms_codecMap.at(videoHint.codec).name); ```
else { contents["codec"]["audio"] = SetupAudio(audioHint, contents); } if (audioHint.codec == AV_CODEC_ID_EAC3 && audioHint.profile == AV_PROFILE_EAC3_DDP_ATMOS) contents["immersive"] = "ATMOS"; contents["format"] = "RAW"; p["mediaTransportType"] = "BUFFERSTREAM"; contents["provider"] = CCompile...
@@ -576,7 +644,7 @@ bool CMediaPipelineWebOS::Load(CDVDStreamInfo videoHint, CDVDStreamInfo audioHin } p["option"]["appId"] = CCompileInfo::GetPackage(); - contents["codec"]["video"] = ms_codecMap.at(videoHint.codec).data(); + contents["codec"]["video"] = ms_codecMap.at(videoHint.codec).name.data();
xbmc/cores/VideoPlayer/MediaPipelineWebOS.cpp
26
C++
0.857
suggestion
99
51
51
false
webOS: passthrough encrypted data to secure decoder
27,157
xbmc/xbmc
17,740
C++
sundermann
cscd98
m_messageQueueParent.Put(std::make_shared<CDVDMsg>(CDVDMsg::PLAYER_ABORT)); return false; } m_droppedFrames = 0; std::string formatName = fmt::format( "starfish-{}{}", videoHint.hdrType == StreamHdrType::HDR_TYPE_DOLBYVISION ? "d" : "", StringUtils::ToLower(ms_codecMap.at(videoHint.codec).nam...
```suggestion ms_codecMap.at(audioHint.codec).name); ```
{ CThread::StopThread(true); if (m_audioThread.joinable()) m_audioThread.join(); if (!m_mediaAPIs->Unload()) CLog::LogF(LOGERROR, "Unload failed"); const auto buffer = static_cast<CStarfishVideoBuffer*>(m_picture.videoBuffer); buffer->ResetAcbHandle(); if (sync) { // wait until m_loaded is ...
@@ -707,9 +776,9 @@ bool CMediaPipelineWebOS::Load(CDVDStreamInfo videoHint, CDVDStreamInfo audioHin m_processInfo.SetAudioChannels(CAEUtil::GuessChLayout(audioHint.channels)); m_processInfo.SetAudioSampleRate(audioHint.samplerate); m_processInfo.SetAudioBitsPerSample(audioHint.bitspersample); - if ...
xbmc/cores/VideoPlayer/MediaPipelineWebOS.cpp
26
C++
0.857
suggestion
96
51
51
false
webOS: passthrough encrypted data to secure decoder
27,157
xbmc/xbmc
17,740
C++
sundermann
cscd98
std::unique_lock lock(m_eventMutex); if (!m_eventCondition.wait_for(lock, 1s, [this] { return !m_loaded; })) { CLog::LogF(LOGERROR, "Timeout waiting for m_loaded to be false"); } } } std::string CMediaPipelineWebOS::SetupAudio(CDVDStreamInfo& audioHint, CVariant& optInfo) { m_audioCodec = nul...
```suggestion codecName = ms_codecMap.at(audioHint.codec).name; ```
} if (audioHint.codec == AV_CODEC_ID_AC4) { optInfo["ac4Info"]["channels"] = audioHint.channels; optInfo["ac4Info"]["frequency"] = audioHint.samplerate / 1000.0; } else if (audioHint.codec == AV_CODEC_ID_DTS) { optInfo["dtsInfo"]["channels"] = audioHint.channels; optInfo["dtsInfo"]["frequenc...
@@ -758,7 +827,7 @@ std::string CMediaPipelineWebOS::SetupAudio(CDVDStreamInfo& audioHint, CVariant& return codecName; } - codecName = ms_codecMap.at(audioHint.codec); + codecName = ms_codecMap.at(audioHint.codec).name.data();
xbmc/cores/VideoPlayer/MediaPipelineWebOS.cpp
26
C++
0.857
suggestion
69
51
51
false
webOS: passthrough encrypted data to secure decoder
27,157
xbmc/xbmc
17,740
C++
sundermann
cscd98
optInfo["dtsInfo"]["frequency"] = audioHint.samplerate / 1000.0; if (audioHint.profile == AV_PROFILE_DTS_ES) codecName = "DTSE"; if (audioHint.profile == AV_PROFILE_DTS_HD_MA_X || audioHint.profile == AV_PROFILE_DTS_HD_MA_X_IMAX) codecName = "DTSX"; } else if (audioHint.codec == AV_...
```suggestion optInfo["aacInfo"]["format"] = audioHint.extradata ? "MP4" : "adts"; ```
allowedHdrFormatsSetting, CSettings::VIDEOPLAYER_ALLOWED_HDR_TYPE_DOLBY_VISION); if (hint.codec == AV_CODEC_ID_AVS || hint.codec == AV_CODEC_ID_CAVS || hint.codec == AV_CODEC_ID_H264 || hint.codec == AV_CODEC_ID_HEVC) { if (hint.extradata && !hint.cryptoSession) { m_bitstream = std::make_...
@@ -793,7 +862,17 @@ std::string CMediaPipelineWebOS::SetupAudio(CDVDStreamInfo& audioHint, CVariant& Base64::Encode(reinterpret_cast<const char*>(audioHint.extradata.GetData()), audioHint.extradata.GetSize()); } + else if (audioHint.codec == AV_CODEC_ID_AAC || audioHint.codec == AV...
xbmc/cores/VideoPlayer/MediaPipelineWebOS.cpp
26
C++
0.857
suggestion
89
51
51
false
webOS: passthrough encrypted data to secure decoder
27,157
xbmc/xbmc
17,740
C++
sundermann
cscd98
{ return m_subtitle; } double CMediaPipelineWebOS::GetSubtitleDelay() const { return m_subtitleDelay; } void CMediaPipelineWebOS::SetSubtitleDelay(const double delay) { m_subtitleDelay = delay; } bool CMediaPipelineWebOS::Load(CDVDStreamInfo videoHint, CDVDStreamInfo audioHint) { std::scoped_lock videoLock(m...
Sorry, I think I made a mistake here when making the suggestion. This should be reversed and I think webOS 5 can use version 40 too.
{ return m_subtitleDelay; } void CMediaPipelineWebOS::SetSubtitleDelay(const double delay) { m_subtitleDelay = delay; } bool CMediaPipelineWebOS::Load(CDVDStreamInfo videoHint, CDVDStreamInfo audioHint) { std::scoped_lock videoLock(m_videoCriticalSection); std::scoped_lock audioLock(m_audioCriticalSection); ...
@@ -520,12 +530,48 @@ bool CMediaPipelineWebOS::Load(CDVDStreamInfo videoHint, CDVDStreamInfo audioHin std::scoped_lock audioLock(m_audioCriticalSection); CVariant p; - CVariant payloadArgs; if (videoHint.cryptoSession || audioHint.cryptoSession) { - CLog::LogF(LOGERROR, "CryptoSessions unsupported"...
xbmc/cores/VideoPlayer/MediaPipelineWebOS.cpp
26
C++
0.5
suggestion
132
51
51
false
webOS: passthrough encrypted data to secure decoder
27,157
xbmc/xbmc
17,740
C++
sundermann
cscd98
m_mediaAPIs = std::make_unique<StarfishMediaAPIs>(); } if (m_audioHint.codec && m_videoHint.codec) return Load(m_videoHint, m_audioHint); return true; } bool CMediaPipelineWebOS::OpenVideoStream(CDVDStreamInfo hint) { if (!Supports(hint.codec)) { CLog::LogF(LOGERROR, "Unsupported codec: {}", hin...
I am failing to understand this condition. Adaptive streaming means that we can change bitrate, resolution and framerate dynamically. So why this check for the same resolution and the uniqueId? Instead, can we remove flushing here completely then change the condition above like this: ```c++ if (m_videoHint.codec =...
m_mediaAPIs = std::make_unique<StarfishMediaAPIs>(); } if (m_audioHint.codec && m_videoHint.codec) return Load(m_videoHint, m_audioHint); return true; } bool CMediaPipelineWebOS::OpenVideoStream(CDVDStreamInfo hint) { if (!Supports(hint.codec)) { CLog::LogF(LOGERROR, "Unsupported codec: {}", hin...
@@ -345,8 +351,12 @@ bool CMediaPipelineWebOS::OpenVideoStream(CDVDStreamInfo hint) { std::scoped_lock lock(m_videoCriticalSection); SetupBitstreamConverter(hint); + if (m_videoHint.uniqueId != hint.uniqueId || + (m_videoHint.width == hint.width && m_videoHint.height == hint.height)) + ...
xbmc/cores/VideoPlayer/MediaPipelineWebOS.cpp
26
C++
1
bug
377
51
51
false
webOS: passthrough encrypted data to secure decoder
27,157
xbmc/xbmc
17,740
C++
sundermann
cscd98