Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/xbmc/FileSystem/File.cpp b/xbmc/FileSystem/File.cpp
- index c7d57ba..d2cf706 100644
- --- a/xbmc/FileSystem/File.cpp
- +++ b/xbmc/FileSystem/File.cpp
- @@ -23,7 +23,6 @@
- #include "Application.h"
- #include "Util.h"
- #include "DirectoryCache.h"
- -#include "Directory.h"
- #include "FileCache.h"
- #include "utils/log.h"
- @@ -48,7 +47,6 @@ CFile::CFile()
- m_pFile = NULL;
- m_pBuffer = NULL;
- m_flags = 0;
- - m_bitStreamStats = NULL;
- }
- //*********************************************************************************************
- @@ -58,8 +56,6 @@ CFile::~CFile()
- SAFE_DELETE(m_pFile);
- if (m_pBuffer)
- SAFE_DELETE(m_pBuffer);
- - if (m_bitStreamStats)
- - SAFE_DELETE(m_bitStreamStats);
- }
- //*********************************************************************************************
- @@ -70,7 +66,7 @@ class CAutoBuffer
- public:
- explicit CAutoBuffer(size_t s) { p = (char*)malloc(s); }
- ~CAutoBuffer() { free(p); }
- - char* get() { return p; }
- +char* get() { return p; }
- };
- // This *looks* like a copy function, therefor the name "Cache" is misleading
- @@ -221,10 +217,10 @@ bool CFile::Open(const CStdString& strFileName, unsigned int flags)
- return false;
- }
- - CURL url(CDirectory::Translate(strFileName));
- - if ( (flags & READ_NO_CACHE) == 0 && CUtil::IsInternetStream(url) && !CUtil::IsPicture(strFileName) )
- + if ( (flags & READ_NO_CACHE) == 0 && CUtil::IsInternetStream(strFileName) && !CUtil::IsPicture(strFileName) )
- m_flags |= READ_CACHED;
- + CURL url(strFileName);
- if (m_flags & READ_CACHED)
- {
- m_pFile = new CFileCache();
- @@ -269,18 +265,16 @@ bool CFile::Open(const CStdString& strFileName, unsigned int flags)
- return false;
- }
- - if (m_pFile->GetChunkSize() && !(m_flags & READ_CHUNKED))
- + if (m_flags & READ_BUFFERED)
- {
- - m_pBuffer = new CFileStreamBuffer(0);
- - m_pBuffer->Attach(m_pFile);
- - }
- -
- - if (m_flags & READ_BITRATE)
- - {
- - m_bitStreamStats = new BitstreamStats();
- - m_bitStreamStats->Start();
- + if (m_pFile->GetChunkSize())
- + {
- + m_pBuffer = new CFileStreamBuffer(0);
- + m_pBuffer->Attach(m_pFile);
- + }
- }
- + m_bitStreamStats.Start();
- return true;
- }
- #ifndef _LINUX
- @@ -301,7 +295,7 @@ bool CFile::OpenForWrite(const CStdString& strFileName, bool bOverWrite)
- {
- try
- {
- - CURL url(CDirectory::Translate(strFileName));
- + CURL url(strFileName);
- m_pFile = CFileFactory::CreateLoader(url);
- if (m_pFile && m_pFile->OpenForWrite(url, bOverWrite))
- @@ -330,8 +324,7 @@ bool CFile::Exists(const CStdString& strFileName, bool bUseCache /* = true */)
- {
- try
- {
- - if (strFileName.IsEmpty())
- - return false;
- + if (strFileName.IsEmpty()) return false;
- if (bUseCache)
- {
- @@ -342,11 +335,10 @@ bool CFile::Exists(const CStdString& strFileName, bool bUseCache /* = true */)
- return false;
- }
- - CURL url(CDirectory::Translate(strFileName));
- + CURL url(strFileName);
- auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
- - if (!pFile.get())
- - return false;
- + if (!pFile.get()) return false;
- return pFile->Exists(url);
- }
- @@ -373,11 +365,10 @@ int CFile::Stat(const CStdString& strFileName, struct __stat64* buffer)
- {
- try
- {
- - CURL url(CDirectory::Translate(strFileName));
- + CURL url(strFileName);
- auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
- - if (!pFile.get())
- - return false;
- + if (!pFile.get()) return false;
- return pFile->Stat(url, buffer);
- }
- @@ -407,15 +398,15 @@ unsigned int CFile::Read(void *lpBuf, int64_t uiBufSize)
- unsigned int nBytes = m_pBuffer->sgetn(
- (char *)lpBuf, min<streamsize>((streamsize)uiBufSize,
- m_pBuffer->in_avail()));
- - if (m_bitStreamStats && nBytes>0)
- - m_bitStreamStats->AddSampleBytes(nBytes);
- + if (nBytes>0)
- + m_bitStreamStats.AddSampleBytes(nBytes);
- return nBytes;
- }
- else
- {
- unsigned int nBytes = m_pBuffer->sgetn((char*)lpBuf, uiBufSize);
- - if (m_bitStreamStats && nBytes>0)
- - m_bitStreamStats->AddSampleBytes(nBytes);
- + if (nBytes>0)
- + m_bitStreamStats.AddSampleBytes(nBytes);
- return nBytes;
- }
- }
- @@ -425,8 +416,8 @@ unsigned int CFile::Read(void *lpBuf, int64_t uiBufSize)
- if(m_flags & READ_TRUNCATED)
- {
- unsigned int nBytes = m_pFile->Read(lpBuf, uiBufSize);
- - if (m_bitStreamStats && nBytes>0)
- - m_bitStreamStats->AddSampleBytes(nBytes);
- + if (nBytes>0)
- + m_bitStreamStats.AddSampleBytes(nBytes);
- return nBytes;
- }
- else
- @@ -440,8 +431,8 @@ unsigned int CFile::Read(void *lpBuf, int64_t uiBufSize)
- done+=curr;
- }
- - if (m_bitStreamStats && done > 0)
- - m_bitStreamStats->AddSampleBytes(done);
- + if (done > 0)
- + m_bitStreamStats.AddSampleBytes(done);
- return done;
- }
- }
- @@ -463,8 +454,11 @@ void CFile::Close()
- {
- try
- {
- - SAFE_DELETE(m_pBuffer);
- - SAFE_DELETE(m_pFile);
- + if (m_pBuffer)
- + SAFE_DELETE(m_pBuffer);
- +
- + if (m_pFile)
- + SAFE_DELETE(m_pFile);
- }
- #ifndef _LINUX
- catch (const win32_exception &e)
- @@ -483,8 +477,7 @@ void CFile::Flush()
- {
- try
- {
- - if (m_pFile)
- - m_pFile->Flush();
- + if (m_pFile) m_pFile->Flush();
- }
- #ifndef _LINUX
- catch (const win32_exception &e)
- @@ -551,8 +544,7 @@ int64_t CFile::GetLength()
- {
- try
- {
- - if (m_pFile)
- - return m_pFile->GetLength();
- + if (m_pFile) return m_pFile->GetLength();
- return 0;
- }
- #ifndef _LINUX
- @@ -684,11 +676,10 @@ bool CFile::Delete(const CStdString& strFileName)
- {
- try
- {
- - CURL url(CDirectory::Translate(strFileName));
- + CURL url(strFileName);
- auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
- - if (!pFile.get())
- - return false;
- + if (!pFile.get()) return false;
- if(pFile->Delete(url))
- {
- @@ -719,12 +710,11 @@ bool CFile::Rename(const CStdString& strFileName, const CStdString& strNewFileNa
- {
- try
- {
- - CURL url(CDirectory::Translate(strFileName));
- - CURL urlnew(CDirectory::Translate(strNewFileName));
- + CURL url(strFileName);
- + CURL urlnew(strNewFileName);
- auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
- - if (!pFile.get())
- - return false;
- + if (!pFile.get()) return false;
- if(pFile->Rename(url, urlnew))
- {
- @@ -751,11 +741,10 @@ bool CFile::SetHidden(const CStdString& fileName, bool hidden)
- {
- try
- {
- - CURL url(CDirectory::Translate(fileName));
- + CURL url(fileName);
- auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
- - if (!pFile.get())
- - return false;
- + if (!pFile.get()) return false;
- return pFile->SetHidden(url, hidden);
- }
- @@ -781,14 +770,15 @@ CFileStreamBuffer::CFileStreamBuffer(int backsize)
- , m_buffer(NULL)
- , m_backsize(backsize)
- , m_frontsize(0)
- -{
- -}
- +{}
- void CFileStreamBuffer::Attach(IFile *file)
- {
- m_file = file;
- - m_frontsize = CFile::GetChunkSize(m_file->GetChunkSize(), 64*1024);
- + m_frontsize = m_file->GetChunkSize();
- + if(!m_frontsize)
- + m_frontsize = 1024;
- m_buffer = new char[m_frontsize+m_backsize];
- setg(0,0,0);
- @@ -927,9 +917,6 @@ bool CFileStream::Open(const CURL& filename)
- {
- Close();
- - // NOTE: This is currently not translated - reason is that all entry points into CFileStream::Open currently
- - // go from the CStdString version below. We may have to change this in future, but I prefer not decoding
- - // the URL and re-encoding, or applying the translation twice.
- m_file = CFileFactory::CreateLoader(filename);
- if(m_file && m_file->Open(filename))
- {
- @@ -957,7 +944,7 @@ void CFileStream::Close()
- bool CFileStream::Open(const CStdString& filename)
- {
- - return Open(CURL(CDirectory::Translate(filename)));
- + return Open(CURL(filename));
- }
- #ifdef _ARMEL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement