Permalink
Browse files

iso/img: consider iso/img files containing udf filesystem, folders

  • Loading branch information...
1 parent d93fc55 commit 03f1aec9077f7c904045f741753d19369078dc66 @elupus committed Nov 11, 2012
@@ -38,22 +38,6 @@
using namespace std;
using namespace XFILE;
-static bool is_udf_iso_path(const char* filename)
-{
- bool bResult = false;
-
- const char* ptr = strcasestr(filename, ".iso");
- if(ptr)
- {
- ptr += strlen(".iso");
- if(*ptr == '/' && strlen(++ptr) > 0)
- {
- bResult = true;
- }
- }
- return bResult;
-}
-
void DllLibbluray::file_close(BD_FILE_H *file)
{
if (file)
@@ -98,8 +82,9 @@ BD_FILE_H * DllLibbluray::file_open(const char* filename, const char *mode)
BD_FILE_H *file = new BD_FILE_H;
CStdString strFilename(filename);
-
- if(is_udf_iso_path(filename))
+ CStdString strExtension(URIUtils::GetExtension(filename));
+ if(strExtension == ".iso"
+ || strExtension == ".img")
{
CURL::Encode(strFilename);
strFilename.Format("udf://%s", strFilename);
@@ -173,12 +158,6 @@ BD_DIR_H *DllLibbluray::dir_open(const char* dirname)
SDirState *st = new SDirState();
CStdString strDirname(dirname);
- if(is_udf_iso_path(dirname))
- {
- CURL::Encode(strDirname);
- strDirname.Format("udf://%s", strDirname);
- CLog::Log(LOGDEBUG, "CDVDInputStreamBluray - Opening udf dir %s...", strDirname.c_str());
- }
if(!CDirectory::GetDirectory(strDirname, st->list))
{
@@ -27,6 +27,7 @@
#include "utils/log.h"
#include "guilib/Geometry.h"
#include "URIUtils.h"
+#include "URL.h"
#if defined(TARGET_DARWIN)
#include "CocoaInterface.h"
#endif
@@ -85,6 +86,14 @@ bool CDVDInputStreamNavigator::Open(const char* strFile, const std::string& cont
if(URIUtils::GetFileName(path) == "VIDEO_TS")
path = URIUtils::GetParentPath(path);
URIUtils::RemoveSlashAtEnd(path);
+ CURL url(path);
+
+ // if this is the root of a udf path, we want the image file
+ // so that libdvdnav can parse the udf itself
+ if(url.GetProtocol() == "udf"
+ && url.GetFileName() == "")
+ path = url.GetHostName();
+
#if defined(TARGET_DARWIN_OSX)
// if physical DVDs, libdvdnav wants "/dev/rdiskN" device name for OSX,
@@ -47,6 +47,8 @@
#include "ZipManager.h"
#include "settings/AdvancedSettings.h"
#include "FileItem.h"
+#include "URL.h"
+#include "UDFDirectory.h"
using namespace XFILE;
using namespace PLAYLIST;
@@ -224,6 +226,15 @@ IFileDirectory* CFileDirectoryFactory::Create(const CStdString& strPath, CFileIt
IFileDirectory* pDir=new CSmartPlaylistDirectory;
return pDir; // treat as directory
}
+ if (strExtension.Equals(".iso")
+ || strExtension.Equals(".img"))
+ {
+ IFileDirectory* pDir=new CUDFDirectory();
+ if (pDir->ContainsFiles(strPath))
+ return pDir;
+ delete pDir;
+ return NULL;
+ }
if (g_advancedSettings.m_playlistAsFolders && CPlayListFactory::IsPlaylist(strPath))
{ // Playlist file
// currently we only return the directory if it contains
@@ -35,6 +35,17 @@ CUDFDirectory::~CUDFDirectory(void)
{
}
+bool CUDFDirectory::ContainsFiles(const CStdString &strPath)
+{
+ udf25 udf;
+ udf_dir_t *dirp = udf.OpenDir(strPath, "/");
+
+ if (dirp == NULL)
+ return false;
+ udf.CloseDir(dirp);
+ return true;
+}
+
bool CUDFDirectory::GetDirectory(const CStdString& strPath,
CFileItemList &items)
{
@@ -22,17 +22,19 @@
*/
#include "IDirectory.h"
+#include "IFileDirectory.h"
namespace XFILE
{
class CUDFDirectory :
- public IDirectory
+ public IFileDirectory
{
public:
CUDFDirectory(void);
virtual ~CUDFDirectory(void);
virtual bool GetDirectory(const CStdString& strPath, CFileItemList &items);
virtual bool Exists(const char* strPath);
+ virtual bool ContainsFiles(const CStdString& strPath);
};
}

0 comments on commit 03f1aec

Please sign in to comment.