2 * Copyright (C) 2010 Team Boxee
5 * Copyright (C) 2010-2013 Team XBMC
8 * This Program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
13 * This Program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with XBMC; see the file COPYING. If not, see
20 * <http://www.gnu.org/licenses/>.
23 #include "UDFDirectory.h"
28 #include "utils/URIUtils.h"
30 using namespace XFILE
;
32 CUDFDirectory::CUDFDirectory(void)
36 CUDFDirectory::~CUDFDirectory(void)
40 bool CUDFDirectory::GetDirectory(const CStdString
& strPath
,
43 CStdString strRoot
, strSub
;
45 if(StringUtils::StartsWith(strPath
, "udf://"))
52 url
.SetProtocol("udf");
53 url
.SetHostName(strPath
);
56 strSub
= url
.GetFileName();
58 URIUtils::AddSlashAtEnd(strRoot
);
59 URIUtils::AddSlashAtEnd(strSub
);
62 if(!udfIsoReader
.Open(url
.GetHostName()))
65 udf_dir_t
*dirp
= udfIsoReader
.OpenDir(strSub
);
70 udf_dirent_t
*dp
= NULL
;
71 while ((dp
= udfIsoReader
.ReadDir(dirp
)) != NULL
)
73 if (dp
->d_type
== DVD_DT_DIR
)
75 CStdString strDir
= (char*)dp
->d_name
;
76 if (strDir
!= "." && strDir
!= "..")
78 CFileItemPtr
pItem(new CFileItem((char*)dp
->d_name
));
79 strDir
= strRoot
+ (char*)dp
->d_name
;
80 URIUtils::AddSlashAtEnd(strDir
);
81 pItem
->SetPath(strDir
);
82 pItem
->m_bIsFolder
= true;
89 CFileItemPtr
pItem(new CFileItem((char*)dp
->d_name
));
90 pItem
->SetPath(strRoot
+ (char*)dp
->d_name
);
91 pItem
->m_bIsFolder
= false;
92 pItem
->m_dwSize
= dp
->d_filesize
;
98 udfIsoReader
.CloseDir(dirp
);
103 bool CUDFDirectory::Exists(const char* strPath
)
106 if (GetDirectory(strPath
,items
))