2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "ISO9660Directory.h"
24 #include "utils/URIUtils.h"
28 using namespace XFILE;
30 CISO9660Directory::CISO9660Directory(void)
33 CISO9660Directory::~CISO9660Directory(void)
36 bool CISO9660Directory::GetDirectory(const CStdString& strPath, CFileItemList &items)
38 CStdString strRoot = strPath;
39 URIUtils::AddSlashAtEnd(strRoot);
41 // Scan active disc if not done before
42 if (!m_isoReader.IsScanned())
50 memset(&wfd, 0, sizeof(wfd));
52 CStdString strSearchMask;
53 CStdString strDirectory = url.GetFileName();
54 if (strDirectory != "")
56 strSearchMask.Format("\\%s", strDirectory.c_str());
62 for (int i = 0; i < (int)strSearchMask.size(); ++i )
64 if (strSearchMask[i] == '/') strSearchMask[i] = '\\';
67 hFind = m_isoReader.FindFirstFile((char*)strSearchMask.c_str(), &wfd);
73 if (wfd.cFileName[0] != 0)
75 if ( (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
77 CStdString strDir = wfd.cFileName;
78 if (strDir != "." && strDir != "..")
80 CFileItemPtr pItem(new CFileItem(wfd.cFileName));
81 CStdString path = strRoot + wfd.cFileName;
82 URIUtils::AddSlashAtEnd(path);
84 pItem->m_bIsFolder = true;
86 FileTimeToLocalFileTime(&wfd.ftLastWriteTime, &localTime);
87 pItem->m_dateTime=localTime;
93 CFileItemPtr pItem(new CFileItem(wfd.cFileName));
94 pItem->SetPath(strRoot + wfd.cFileName);
95 pItem->m_bIsFolder = false;
96 pItem->m_dwSize = CUtil::ToInt64(wfd.nFileSizeHigh, wfd.nFileSizeLow);
98 FileTimeToLocalFileTime(&wfd.ftLastWriteTime, &localTime);
99 pItem->m_dateTime=localTime;
104 while (m_isoReader.FindNextFile(hFind, &wfd));
105 m_isoReader.FindClose(hFind);
110 bool CISO9660Directory::Exists(const char* strPath)
113 if (GetDirectory(strPath,items))