Skip to content
Browse files

udf: use hostname to open iso image instead of .iso in path

  • Loading branch information...
1 parent 3f90626 commit d93fc55eaaf435d4901d1130580348b6ee56277e @elupus committed
Showing with 26 additions and 54 deletions.
  1. +17 −6 xbmc/filesystem/UDFDirectory.cpp
  2. +4 −17 xbmc/filesystem/UDFFile.cpp
  3. +3 −29 xbmc/filesystem/udf25.cpp
  4. +2 −2 xbmc/filesystem/udf25.h
View
23 xbmc/filesystem/UDFDirectory.cpp
@@ -38,15 +38,26 @@ CUDFDirectory::~CUDFDirectory(void)
bool CUDFDirectory::GetDirectory(const CStdString& strPath,
CFileItemList &items)
{
- CStdString strRoot = strPath;
- URIUtils::AddSlashAtEnd(strRoot);
-
- CURL url(strPath);
+ CStdString strRoot, strSub;
+ CURL url;
+ if(strPath.Left(6) == "udf://")
+ {
+ url.Parse(strPath);
+ CURL url(strPath);
+ }
+ else
+ {
+ url.SetProtocol("udf");
+ url.SetHostName(strPath);
+ }
+ strRoot = url.Get();
+ strSub = url.GetFileName();
- CStdString strDirectory = url.GetHostName();
+ URIUtils::AddSlashAtEnd(strRoot);
+ URIUtils::AddSlashAtEnd(strSub);
udf25 udfIsoReader;
- udf_dir_t *dirp = udfIsoReader.OpenDir(strDirectory);
+ udf_dir_t *dirp = udfIsoReader.OpenDir(url.GetHostName(), strSub);
if (dirp == NULL)
return false;
View
21 xbmc/filesystem/UDFFile.cpp
@@ -48,9 +48,7 @@ CUDFFile::~CUDFFile()
//*********************************************************************************************
bool CUDFFile::Open(const CURL& url)
{
- CStdString strFName = url.GetHostName();
-
- m_hFile = m_udfIsoReaderLocal.OpenFile((char*)strFName.c_str());
+ m_hFile = m_udfIsoReaderLocal.OpenFile(url.GetHostName(), url.GetFileName());
if (m_hFile == INVALID_HANDLE_VALUE)
{
m_bOpened = false;
@@ -104,29 +102,18 @@ int64_t CUDFFile::GetPosition()
bool CUDFFile::Exists(const CURL& url)
{
- string strFName = "\\";
- strFName += url.GetFileName();
- for (int i = 0; i < (int)strFName.size(); ++i )
- {
- if (strFName[i] == '/') strFName[i] = '\\';
- }
- m_hFile = m_udfIsoReaderLocal.OpenFile((char*)strFName.c_str());
+ m_hFile = m_udfIsoReaderLocal.OpenFile(url.GetHostName(), url.GetFileName());
if (m_hFile == INVALID_HANDLE_VALUE)
return false;
m_udfIsoReaderLocal.CloseFile(m_hFile);
+ m_hFile = INVALID_HANDLE_VALUE;
return true;
}
int CUDFFile::Stat(const CURL& url, struct __stat64* buffer)
{
- string strFName = "\\";
- strFName += url.GetFileName();
- for (int i = 0; i < (int)strFName.size(); ++i )
- {
- if (strFName[i] == '/') strFName[i] = '\\';
- }
- m_hFile = m_udfIsoReaderLocal.OpenFile((char*)strFName.c_str());
+ m_hFile = m_udfIsoReaderLocal.OpenFile(url.GetHostName(), url.GetFileName());
if (m_hFile != INVALID_HANDLE_VALUE)
{
buffer->st_size = m_udfIsoReaderLocal.GetFileSize(m_hFile);
View
32 xbmc/filesystem/udf25.cpp
@@ -464,28 +464,6 @@ uint64_t DVDFileSeekForce(BD_FILE bdfile, uint64_t offset, int64_t force_size)
return offset;
}
-int UDFSplitIsoFile(const char *fullFilename, char* iso, char* file)
-{
- const char* filename = strcasestr(fullFilename, ".iso");
- if(!filename)
- return -1;
-
- filename += strlen(".iso");
- if(*filename != '/')
- return -1;
-
- size_t size = strlen(filename);
- memcpy(file, filename, size);
- file[size] = 0;
-
- size = filename - fullFilename;
- memcpy(iso, fullFilename, filename - fullFilename);
- iso[size] = 0;
-
- return 0;
-}
-
-
int udf25::UDFScanDirX( udf_dir_t *dirp )
{
char filename[ MAX_UDF_FILE_NAME_LEN ];
@@ -1190,15 +1168,11 @@ UDF_FILE udf25::UDFFindFile( const char* filename, uint64_t *filesize )
return result;
}
-HANDLE udf25::OpenFile( const char* fullFilename )
+HANDLE udf25::OpenFile( const char* isoname, const char* filename )
{
uint64_t filesize;
UDF_FILE file = NULL;
BD_FILE bdfile = NULL;
- char isoname[256], filename[256];
-
- if(UDFSplitIsoFile(fullFilename, isoname, filename) !=0 )
- return INVALID_HANDLE_VALUE;
m_fp = file_open(isoname);
if(m_fp)
@@ -1338,12 +1312,12 @@ int64_t udf25::GetFilePosition(HANDLE hFile)
return bdfile->seek_pos;
}
-udf_dir_t *udf25::OpenDir( const char *subdir )
+udf_dir_t *udf25::OpenDir( const char *isofile, const char *subdir )
{
udf_dir_t *result;
BD_FILE bd_file;
- bd_file = (BD_FILE)OpenFile(subdir);
+ bd_file = (BD_FILE)OpenFile(isofile, subdir);
if (bd_file == (BD_FILE)INVALID_HANDLE_VALUE)
{
View
4 xbmc/filesystem/udf25.h
@@ -183,11 +183,11 @@ class udf25
int64_t GetFileSize(HANDLE hFile);
int64_t GetFilePosition(HANDLE hFile);
int64_t Seek(HANDLE hFile, int64_t lOffset, int whence);
- HANDLE OpenFile( const char* filename );
+ HANDLE OpenFile( const char *isofile, const char* filename );
long ReadFile(HANDLE fd, unsigned char *pBuffer, long lSize);
void CloseFile(HANDLE hFile);
- udf_dir_t *OpenDir( const char *subdir );
+ udf_dir_t *OpenDir( const char *isofile, const char *subdir );
udf_dirent_t *ReadDir( udf_dir_t *dirp );
int CloseDir( udf_dir_t *dirp );

0 comments on commit d93fc55

Please sign in to comment.
Something went wrong with that request. Please try again.