Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 8.07 KB | None | 0 0
  1. diff --git a/xbmc/FileSystem/File.cpp b/xbmc/FileSystem/File.cpp
  2. index c7d57ba..d2cf706 100644
  3. --- a/xbmc/FileSystem/File.cpp
  4. +++ b/xbmc/FileSystem/File.cpp
  5. @@ -23,7 +23,6 @@
  6.  #include "Application.h"
  7.  #include "Util.h"
  8.  #include "DirectoryCache.h"
  9. -#include "Directory.h"
  10.  #include "FileCache.h"
  11.  #include "utils/log.h"
  12.  
  13. @@ -48,7 +47,6 @@ CFile::CFile()
  14.    m_pFile = NULL;
  15.    m_pBuffer = NULL;
  16.    m_flags = 0;
  17. -  m_bitStreamStats = NULL;
  18.  }
  19.  
  20.  //*********************************************************************************************
  21. @@ -58,8 +56,6 @@ CFile::~CFile()
  22.      SAFE_DELETE(m_pFile);
  23.    if (m_pBuffer)
  24.      SAFE_DELETE(m_pBuffer);
  25. -  if (m_bitStreamStats)
  26. -    SAFE_DELETE(m_bitStreamStats);
  27.  }
  28.  
  29.  //*********************************************************************************************
  30. @@ -70,7 +66,7 @@ class CAutoBuffer
  31.  public:
  32.    explicit CAutoBuffer(size_t s) { p = (char*)malloc(s); }
  33.    ~CAutoBuffer() { free(p); }
  34. -  char* get() { return p; }
  35. +char* get() { return p; }
  36.  };
  37.  
  38.  // This *looks* like a copy function, therefor the name "Cache" is misleading
  39. @@ -221,10 +217,10 @@ bool CFile::Open(const CStdString& strFileName, unsigned int flags)
  40.          return false;
  41.      }
  42.  
  43. -    CURL url(CDirectory::Translate(strFileName));
  44. -    if ( (flags & READ_NO_CACHE) == 0 && CUtil::IsInternetStream(url) && !CUtil::IsPicture(strFileName) )
  45. +    if ( (flags & READ_NO_CACHE) == 0 && CUtil::IsInternetStream(strFileName) && !CUtil::IsPicture(strFileName) )
  46.        m_flags |= READ_CACHED;
  47.  
  48. +    CURL url(strFileName);
  49.      if (m_flags & READ_CACHED)
  50.      {
  51.        m_pFile = new CFileCache();
  52. @@ -269,18 +265,16 @@ bool CFile::Open(const CStdString& strFileName, unsigned int flags)
  53.        return false;
  54.      }
  55.  
  56. -    if (m_pFile->GetChunkSize() && !(m_flags & READ_CHUNKED))
  57. +    if (m_flags & READ_BUFFERED)
  58.      {
  59. -      m_pBuffer = new CFileStreamBuffer(0);
  60. -      m_pBuffer->Attach(m_pFile);
  61. -    }
  62. -
  63. -    if (m_flags & READ_BITRATE)
  64. -    {
  65. -      m_bitStreamStats = new BitstreamStats();
  66. -      m_bitStreamStats->Start();
  67. +      if (m_pFile->GetChunkSize())
  68. +      {
  69. +        m_pBuffer = new CFileStreamBuffer(0);
  70. +        m_pBuffer->Attach(m_pFile);
  71. +      }
  72.      }
  73.  
  74. +    m_bitStreamStats.Start();
  75.      return true;
  76.    }
  77.  #ifndef _LINUX
  78. @@ -301,7 +295,7 @@ bool CFile::OpenForWrite(const CStdString& strFileName, bool bOverWrite)
  79.  {
  80.    try
  81.    {
  82. -    CURL url(CDirectory::Translate(strFileName));
  83. +    CURL url(strFileName);
  84.  
  85.      m_pFile = CFileFactory::CreateLoader(url);
  86.      if (m_pFile && m_pFile->OpenForWrite(url, bOverWrite))
  87. @@ -330,8 +324,7 @@ bool CFile::Exists(const CStdString& strFileName, bool bUseCache /* = true */)
  88.  {
  89.    try
  90.    {
  91. -    if (strFileName.IsEmpty())
  92. -      return false;
  93. +    if (strFileName.IsEmpty()) return false;
  94.  
  95.      if (bUseCache)
  96.      {
  97. @@ -342,11 +335,10 @@ bool CFile::Exists(const CStdString& strFileName, bool bUseCache /* = true */)
  98.          return false;
  99.      }
  100.  
  101. -    CURL url(CDirectory::Translate(strFileName));
  102. +    CURL url(strFileName);
  103.  
  104.      auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
  105. -    if (!pFile.get())
  106. -      return false;
  107. +    if (!pFile.get()) return false;
  108.  
  109.      return pFile->Exists(url);
  110.    }
  111. @@ -373,11 +365,10 @@ int CFile::Stat(const CStdString& strFileName, struct __stat64* buffer)
  112.  {
  113.    try
  114.    {
  115. -    CURL url(CDirectory::Translate(strFileName));
  116. +    CURL url(strFileName);
  117.  
  118.      auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
  119. -    if (!pFile.get())
  120. -      return false;
  121. +    if (!pFile.get()) return false;
  122.  
  123.      return pFile->Stat(url, buffer);
  124.    }
  125. @@ -407,15 +398,15 @@ unsigned int CFile::Read(void *lpBuf, int64_t uiBufSize)
  126.        unsigned int nBytes = m_pBuffer->sgetn(
  127.          (char *)lpBuf, min<streamsize>((streamsize)uiBufSize,
  128.                                                    m_pBuffer->in_avail()));
  129. -      if (m_bitStreamStats && nBytes>0)
  130. -        m_bitStreamStats->AddSampleBytes(nBytes);
  131. +      if (nBytes>0)
  132. +        m_bitStreamStats.AddSampleBytes(nBytes);
  133.        return nBytes;
  134.      }
  135.      else
  136.      {
  137.        unsigned int nBytes = m_pBuffer->sgetn((char*)lpBuf, uiBufSize);
  138. -      if (m_bitStreamStats && nBytes>0)
  139. -        m_bitStreamStats->AddSampleBytes(nBytes);
  140. +      if (nBytes>0)
  141. +        m_bitStreamStats.AddSampleBytes(nBytes);
  142.        return nBytes;
  143.      }
  144.    }
  145. @@ -425,8 +416,8 @@ unsigned int CFile::Read(void *lpBuf, int64_t uiBufSize)
  146.      if(m_flags & READ_TRUNCATED)
  147.      {
  148.        unsigned int nBytes = m_pFile->Read(lpBuf, uiBufSize);
  149. -      if (m_bitStreamStats && nBytes>0)
  150. -        m_bitStreamStats->AddSampleBytes(nBytes);
  151. +      if (nBytes>0)
  152. +        m_bitStreamStats.AddSampleBytes(nBytes);
  153.        return nBytes;
  154.      }
  155.      else
  156. @@ -440,8 +431,8 @@ unsigned int CFile::Read(void *lpBuf, int64_t uiBufSize)
  157.  
  158.          done+=curr;
  159.        }
  160. -      if (m_bitStreamStats && done > 0)
  161. -        m_bitStreamStats->AddSampleBytes(done);
  162. +      if (done > 0)
  163. +        m_bitStreamStats.AddSampleBytes(done);
  164.        return done;
  165.      }
  166.    }
  167. @@ -463,8 +454,11 @@ void CFile::Close()
  168.  {
  169.    try
  170.    {
  171. -    SAFE_DELETE(m_pBuffer);
  172. -    SAFE_DELETE(m_pFile);
  173. +    if (m_pBuffer)
  174. +      SAFE_DELETE(m_pBuffer);
  175. +
  176. +    if (m_pFile)
  177. +      SAFE_DELETE(m_pFile);
  178.    }
  179.  #ifndef _LINUX
  180.    catch (const win32_exception &e)
  181. @@ -483,8 +477,7 @@ void CFile::Flush()
  182.  {
  183.    try
  184.    {
  185. -    if (m_pFile)
  186. -      m_pFile->Flush();
  187. +    if (m_pFile) m_pFile->Flush();
  188.    }
  189.  #ifndef _LINUX
  190.    catch (const win32_exception &e)
  191. @@ -551,8 +544,7 @@ int64_t CFile::GetLength()
  192.  {
  193.    try
  194.    {
  195. -    if (m_pFile)
  196. -      return m_pFile->GetLength();
  197. +    if (m_pFile) return m_pFile->GetLength();
  198.      return 0;
  199.    }
  200.  #ifndef _LINUX
  201. @@ -684,11 +676,10 @@ bool CFile::Delete(const CStdString& strFileName)
  202.  {
  203.    try
  204.    {
  205. -    CURL url(CDirectory::Translate(strFileName));
  206. +    CURL url(strFileName);
  207.  
  208.      auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
  209. -    if (!pFile.get())
  210. -      return false;
  211. +    if (!pFile.get()) return false;
  212.  
  213.      if(pFile->Delete(url))
  214.      {
  215. @@ -719,12 +710,11 @@ bool CFile::Rename(const CStdString& strFileName, const CStdString& strNewFileNa
  216.  {
  217.    try
  218.    {
  219. -    CURL url(CDirectory::Translate(strFileName));
  220. -    CURL urlnew(CDirectory::Translate(strNewFileName));
  221. +    CURL url(strFileName);
  222. +    CURL urlnew(strNewFileName);
  223.  
  224.      auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
  225. -    if (!pFile.get())
  226. -      return false;
  227. +    if (!pFile.get()) return false;
  228.  
  229.      if(pFile->Rename(url, urlnew))
  230.      {
  231. @@ -751,11 +741,10 @@ bool CFile::SetHidden(const CStdString& fileName, bool hidden)
  232.  {
  233.    try
  234.    {
  235. -    CURL url(CDirectory::Translate(fileName));
  236. +    CURL url(fileName);
  237.  
  238.      auto_ptr<IFile> pFile(CFileFactory::CreateLoader(url));
  239. -    if (!pFile.get())
  240. -      return false;
  241. +    if (!pFile.get()) return false;
  242.  
  243.      return pFile->SetHidden(url, hidden);
  244.    }
  245. @@ -781,14 +770,15 @@ CFileStreamBuffer::CFileStreamBuffer(int backsize)
  246.    , m_buffer(NULL)
  247.    , m_backsize(backsize)
  248.    , m_frontsize(0)
  249. -{
  250. -}
  251. +{}
  252.  
  253.  void CFileStreamBuffer::Attach(IFile *file)
  254.  {
  255.    m_file = file;
  256.  
  257. -  m_frontsize = CFile::GetChunkSize(m_file->GetChunkSize(), 64*1024);
  258. +  m_frontsize = m_file->GetChunkSize();
  259. +  if(!m_frontsize)
  260. +    m_frontsize = 1024;
  261.  
  262.    m_buffer = new char[m_frontsize+m_backsize];
  263.    setg(0,0,0);
  264. @@ -927,9 +917,6 @@ bool CFileStream::Open(const CURL& filename)
  265.  {
  266.    Close();
  267.  
  268. -  // NOTE: This is currently not translated - reason is that all entry points into CFileStream::Open currently
  269. -  //       go from the CStdString version below.  We may have to change this in future, but I prefer not decoding
  270. -  //       the URL and re-encoding, or applying the translation twice.
  271.    m_file = CFileFactory::CreateLoader(filename);
  272.    if(m_file && m_file->Open(filename))
  273.    {
  274. @@ -957,7 +944,7 @@ void CFileStream::Close()
  275.  
  276.  bool CFileStream::Open(const CStdString& filename)
  277.  {
  278. -  return Open(CURL(CDirectory::Translate(filename)));
  279. +  return Open(CURL(filename));
  280.  }
  281.  
  282.  #ifdef _ARMEL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement