Permalink
Browse files

ADD: Implement File copy operation on videodb sources

  • Loading branch information...
1 parent 054a227 commit b481a54c9f699423fdc5a0a0db7f74d6a2686670 @koying committed Oct 9, 2012
View
2 project/VS2010Express/XBMC.vcxproj
@@ -567,6 +567,7 @@
<ClCompile Include="..\..\xbmc\filesystem\VideoDatabaseDirectory.cpp" />
<ClCompile Include="..\..\xbmc\FileSystem\VideoDatabaseDirectory\DirectoryNodeCountry.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\VideoDatabaseDirectory\DirectoryNodeTags.cpp" />
+ <ClCompile Include="..\..\xbmc\filesystem\VideoDatabaseFile.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\windows\WINFileSMB.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\windows\WINSMBDirectory.cpp" />
<ClCompile Include="..\..\xbmc\filesystem\VirtualDirectory.cpp" />
@@ -1017,6 +1018,7 @@
<ClInclude Include="..\..\xbmc\DbUrl.h" />
<ClInclude Include="..\..\xbmc\filesystem\ImageFile.h" />
<ClInclude Include="..\..\xbmc\filesystem\VideoDatabaseDirectory\DirectoryNodeTags.h" />
+ <ClInclude Include="..\..\xbmc\filesystem\VideoDatabaseFile.h" />
<ClInclude Include="..\..\xbmc\filesystem\windows\WINFileSMB.h" />
<ClInclude Include="..\..\xbmc\filesystem\windows\WINSMBDirectory.h" />
<ClInclude Include="..\..\xbmc\guilib\GUIKeyboard.h" />
View
6 project/VS2010Express/XBMC.vcxproj.filters
@@ -2933,6 +2933,9 @@
<ClCompile Include="..\..\xbmc\cores\dvdplayer\DVDDemuxers\DVDDemuxBXA.cpp">
<Filter>cores\dvdplayer\DVDDemuxers</Filter>
</ClCompile>
+ <ClCompile Include="..\..\xbmc\filesystem\VideoDatabaseFile.cpp">
+ <Filter>filesystem</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\xbmc\win32\pch.h">
@@ -5734,6 +5737,9 @@
<ClInclude Include="..\..\xbmc\utils\Screenshot.h">
<Filter>utils</Filter>
</ClInclude>
+ <ClInclude Include="..\..\xbmc\filesystem\VideoDatabaseFile.h">
+ <Filter>filesystem</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\xbmc\win32\XBMC_PC.rc">
View
3 xbmc/filesystem/FileFactory.cpp
@@ -82,6 +82,7 @@
#include "PipesManager.h"
#include "PipeFile.h"
#include "MusicDatabaseFile.h"
+#include "VideoDatabaseFile.h"
#include "SpecialProtocolFile.h"
#include "MultiPathFile.h"
#include "TuxBoxFile.h"
@@ -128,7 +129,7 @@ IFile* CFileFactory::CreateLoader(const CURL& url)
#endif
}
else if (strProtocol == "musicdb") return new CMusicDatabaseFile();
- else if (strProtocol == "videodb") return NULL;
+ else if (strProtocol == "videodb") return new CVideoDatabaseFile();
else if (strProtocol == "special") return new CSpecialProtocolFile();
else if (strProtocol == "multipath") return new CMultiPathFile();
else if (strProtocol == "image") return new CImageFile();
View
1 xbmc/filesystem/Makefile.in
@@ -82,6 +82,7 @@ SRCS += udf25.cpp
SRCS += UDFDirectory.cpp
SRCS += UDFFile.cpp
SRCS += VideoDatabaseDirectory.cpp
+SRCS += VideoDatabaseFile.cpp
SRCS += VirtualDirectory.cpp
SRCS += VTPDirectory.cpp
SRCS += VTPFile.cpp
View
121 xbmc/filesystem/VideoDatabaseFile.cpp
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2005-2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "VideoDatabaseFile.h"
+#include "video/VideoDatabase.h"
+#include "URL.h"
+#include "utils/StringUtils.h"
+#include "utils/URIUtils.h"
+
+#include <sys/stat.h>
+
+using namespace XFILE;
+
+CVideoDatabaseFile::CVideoDatabaseFile(void)
+{
+}
+
+CVideoDatabaseFile::~CVideoDatabaseFile(void)
+{
+ Close();
+}
+
+CStdString CVideoDatabaseFile::TranslateUrl(const CURL& url)
+{
+ CVideoDatabase videoDatabase;
+ if (!videoDatabase.Open())
+ return "";
+
+ CStdString strPath;
+ URIUtils::GetDirectory(url.Get(), strPath);
+ CStdString strFileName=URIUtils::GetFileName(url.Get());
+ CStdString strExtension;
+ URIUtils::GetExtension(strFileName, strExtension);
+ URIUtils::RemoveExtension(strFileName);
+
+ if (!StringUtils::IsNaturalNumber(strFileName))
+ return "";
+ long idFile=atol(strFileName.c_str());
+
+ CStdStringArray pathElem;
+ StringUtils::SplitString(strPath, "/", pathElem);
+ if (pathElem.size() == 0)
+ return "";
+ if (!StringUtils::IsNaturalNumber(pathElem.at(2)))
+ return "";
+ long type=atol(pathElem.at(2).c_str());
+ switch (type) {
+ case 4:
+ type = 1;
+ break;
+ case 5:
+ type = 4;
+ break;
+ case 6:
+ type = 3;
+ break;
+ }
+
+ CStdString realFilename;
+ videoDatabase.GetFilePathById(idFile, realFilename, (VIDEODB_CONTENT_TYPE)type);
+
+ return realFilename;
+}
+
+bool CVideoDatabaseFile::Open(const CURL& url)
+{
+ return m_file.Open(TranslateUrl(url));
+}
+
+bool CVideoDatabaseFile::Exists(const CURL& url)
+{
+ return !TranslateUrl(url).IsEmpty();
+}
+
+int CVideoDatabaseFile::Stat(const CURL& url, struct __stat64* buffer)
+{
+ return m_file.Stat(TranslateUrl(url), buffer);
+}
+
+unsigned int CVideoDatabaseFile::Read(void* lpBuf, int64_t uiBufSize)
+{
+ return m_file.Read(lpBuf, uiBufSize);
+}
+
+int64_t CVideoDatabaseFile::Seek(int64_t iFilePosition, int iWhence /*=SEEK_SET*/)
+{
+ return m_file.Seek(iFilePosition, iWhence);
+}
+
+void CVideoDatabaseFile::Close()
+{
+ m_file.Close();
+}
+
+int64_t CVideoDatabaseFile::GetPosition()
+{
+ return m_file.GetPosition();
+}
+
+int64_t CVideoDatabaseFile::GetLength()
+{
+ return m_file.GetLength();
+}
+
View
46 xbmc/filesystem/VideoDatabaseFile.h
@@ -0,0 +1,46 @@
+#pragma once
+/*
+ * Copyright (C) 2005-2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "IFile.h"
+#include "File.h"
+
+namespace XFILE
+{
+class CVideoDatabaseFile : public IFile
+{
+public:
+ CVideoDatabaseFile(void);
+ virtual ~CVideoDatabaseFile(void);
+ virtual bool Open(const CURL& url);
+ virtual bool Exists(const CURL& url);
+ virtual int Stat(const CURL& url, struct __stat64* buffer);
+
+ virtual unsigned int Read(void* lpBuf, int64_t uiBufSize);
+ virtual int64_t Seek(int64_t iFilePosition, int iWhence = SEEK_SET);
+ virtual void Close();
+ virtual int64_t GetPosition();
+ virtual int64_t GetLength();
+
+ static CStdString TranslateUrl(const CURL& url);
+protected:
+ CFile m_file;
+};
+}

0 comments on commit b481a54

Please sign in to comment.