Example #1
0
void CMediaMonitor::Scan(DIRECTORY::IDirectory& directory, CStdString& aPath, MOVIELIST& movies)
{
  // dispatch any pending commands first before scanning this directory!
  DispatchNextCommand();

  CFileItemList items;
  if (!directory.GetDirectory(aPath, items))
  {
    return ;
  }

  for (int i = 0; i < (int)items.Size(); ++i)
  {
    CFileItem* pItem = items[i];

    if (pItem->m_bIsFolder)
    {
      Scan(directory, pItem->m_strPath, movies);
    }
    else
    {
      char* szFilename = (char*) pItem->GetLabel().c_str();
      char* szExtension = strrchr(szFilename, '.');
      char* szExpected = szFilename + (strlen(szFilename) - 4);

      // ensure file has a 3 letter extension that isn't .nfo
      if ((szExtension != NULL) && (szExpected == szExtension) && (strcmp(szExtension, ".nfo") != 0) )
      {
        Movie aMovie;
        aMovie.strFilepath = pItem->m_strPath;
        aMovie.dwDate = (( (pItem->m_dateTime.GetYear()) << 16 ) |
                         ( (pItem->m_dateTime.GetMonth() & 0x00FF) << 8 ) |
                         (pItem->m_dateTime.GetDay() & 0x00FF) );
        aMovie.wTime = (( (pItem->m_dateTime.GetHour() & 0x00FF) << 8 ) |
                        (pItem->m_dateTime.GetMinute() & 0x00FF) );

        movies.push_back(aMovie);

        //OutputDebugString(pItem->GetLabel().c_str());
        //OutputDebugString("\n");
      }
    }
  }
}