bool CGUIWindowMusicBase::GetDirectory(const CStdString &strDirectory, CFileItemList &items) { items.SetThumbnailImage(""); bool bResult = CGUIMediaWindow::GetDirectory(strDirectory,items); if (bResult) items.SetMusicThumb(); // add in the "New Playlist" item if we're in the playlists folder if ((items.GetPath() == "special://musicplaylists/") && !items.Contains("newplaylist://")) { CFileItemPtr newPlaylist(new CFileItem(g_settings.GetUserDataItem("PartyMode.xsp"),false)); newPlaylist->SetLabel(g_localizeStrings.Get(16035)); newPlaylist->SetLabelPreformated(true); newPlaylist->m_bIsFolder = true; items.Add(newPlaylist); newPlaylist.reset(new CFileItem("newplaylist://", false)); newPlaylist->SetLabel(g_localizeStrings.Get(525)); newPlaylist->SetLabelPreformated(true); newPlaylist->SetSpecialSort(SORT_ON_BOTTOM); newPlaylist->SetCanQueue(false); items.Add(newPlaylist); newPlaylist.reset(new CFileItem("newsmartplaylist://music", false)); newPlaylist->SetLabel(g_localizeStrings.Get(21437)); newPlaylist->SetLabelPreformated(true); newPlaylist->SetSpecialSort(SORT_ON_BOTTOM); newPlaylist->SetCanQueue(false); items.Add(newPlaylist); } return bResult; }
bool CMusicInfoScanner::DoScan(const CStdString& strDirectory) { if (m_pObserver) m_pObserver->OnDirectoryChanged(strDirectory); /* * remove this path from the list we're processing. This must be done prior to * the check for file or folder exclusion to prevent an infinite while loop * in Process(). */ set<CStdString>::iterator it = m_pathsToScan.find(strDirectory); if (it != m_pathsToScan.end()) m_pathsToScan.erase(it); // Discard all excluded files defined by m_musicExcludeRegExps CStdStringArray regexps = g_advancedSettings.m_audioExcludeFromScanRegExps; if (CUtil::ExcludeFileOrFolder(strDirectory, regexps)) return true; // load subfolder CFileItemList items; CDirectory::GetDirectory(strDirectory, items, g_settings.m_musicExtensions + "|.jpg|.tbn|.lrc|.cdg"); // sort and get the path hash. Note that we don't filter .cue sheet items here as we want // to detect changes in the .cue sheet as well. The .cue sheet items only need filtering // if we have a changed hash. items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC); CStdString hash; GetPathHash(items, hash); // get the folder's thumb (this will cache the album thumb). items.SetMusicThumb(true); // true forces it to get a remote thumb // check whether we need to rescan or not CStdString dbHash; if (!m_musicDatabase.GetPathHash(strDirectory, dbHash) || dbHash != hash) { // path has changed - rescan if (dbHash.IsEmpty()) CLog::Log(LOGDEBUG, "%s Scanning dir '%s' as not in the database", __FUNCTION__, strDirectory.c_str()); else CLog::Log(LOGDEBUG, "%s Rescanning dir '%s' due to change", __FUNCTION__, strDirectory.c_str()); // filter items in the sub dir (for .cue sheet support) items.FilterCueItems(); items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC); // and then scan in the new information if (RetrieveMusicInfo(items, strDirectory) > 0) { if (m_pObserver) m_pObserver->OnDirectoryScanned(strDirectory); } // save information about this folder m_musicDatabase.SetPathHash(strDirectory, hash); } else { // path is the same - no need to rescan CLog::Log(LOGDEBUG, "%s Skipping dir '%s' due to no change", __FUNCTION__, strDirectory.c_str()); m_currentItem += CountFiles(items, false); // false for non-recursive // notify our observer of our progress if (m_pObserver) { if (m_itemCount>0) m_pObserver->OnSetProgress(m_currentItem, m_itemCount); m_pObserver->OnDirectoryScanned(strDirectory); } } // now scan the subfolders for (int i = 0; i < items.Size(); ++i) { CFileItemPtr pItem = items[i]; if (m_bStop) break; // if we have a directory item (non-playlist) we then recurse into that folder if (pItem->m_bIsFolder && !pItem->IsParentFolder() && !pItem->IsPlayList()) { CStdString strPath=pItem->GetPath(); if (!DoScan(strPath)) { m_bStop = true; } } } return !m_bStop; }