2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #if (defined HAVE_CONFIG_H) && (!defined TARGET_WINDOWS)
24 #include "network/Network.h"
26 #include "DirectoryFactory.h"
27 #include "HDDirectory.h"
28 #include "SpecialProtocolDirectory.h"
29 #include "MultiPathDirectory.h"
30 #include "StackDirectory.h"
31 #include "FileDirectoryFactory.h"
32 #include "PlaylistDirectory.h"
33 #include "MusicDatabaseDirectory.h"
34 #include "MusicSearchDirectory.h"
35 #include "VideoDatabaseDirectory.h"
36 #include "FavouritesDirectory.h"
37 #include "LibraryDirectory.h"
38 #include "AddonsDirectory.h"
39 #include "SourcesDirectory.h"
40 #include "FTPDirectory.h"
41 #include "HTTPDirectory.h"
42 #include "DAVDirectory.h"
43 #include "UDFDirectory.h"
44 #include "Application.h"
45 #include "addons/Addon.h"
46 #include "utils/log.h"
47 #include "network/WakeOnAccess.h"
49 #ifdef HAS_FILESYSTEM_SMB
51 #include "windows/WINSMBDirectory.h"
53 #include "SMBDirectory.h"
56 #ifdef HAS_FILESYSTEM_CDDA
57 #include "CDDADirectory.h"
59 #include "PluginDirectory.h"
61 #include "ISO9660Directory.h"
62 #ifdef HAS_FILESYSTEM_RTV
63 #include "RTVDirectory.h"
65 #ifdef HAS_FILESYSTEM_DAAP
66 #include "DAAPDirectory.h"
70 #include "UPnPDirectory.h"
72 #ifdef HAS_FILESYSTEM_SAP
73 #include "SAPDirectory.h"
75 #ifdef HAS_FILESYSTEM_VTP
76 #include "VTPDirectory.h"
78 #ifdef HAS_FILESYSTEM_HTSP
79 #include "HTSPDirectory.h"
82 #include "PVRDirectory.h"
84 #if defined(TARGET_ANDROID)
85 #include "APKDirectory.h"
87 #include "ZipDirectory.h"
88 #ifdef HAS_FILESYSTEM_RAR
89 #include "RarDirectory.h"
91 #include "TuxBoxDirectory.h"
92 #include "HDHomeRunDirectory.h"
93 #include "SlingboxDirectory.h"
94 #include "MythDirectory.h"
97 #include "RSSDirectory.h"
99 #include "ZeroconfDirectory.h"
101 #ifdef HAS_FILESYSTEM_SFTP
102 #include "SFTPDirectory.h"
104 #ifdef HAS_FILESYSTEM_NFS
105 #include "NFSDirectory.h"
107 #ifdef HAS_FILESYSTEM_AFP
108 #include "AFPDirectory.h"
110 #ifdef HAVE_LIBBLURAY
111 #include "BlurayDirectory.h"
113 #if defined(TARGET_ANDROID)
114 #include "AndroidAppDirectory.h"
117 using namespace XFILE;
120 \brief Create a IDirectory object of the share type specified in \e strPath .
121 \param strPath Specifies the share type to access, can be a share or share with path.
122 \return IDirectory object to access the directories on the share.
125 IDirectory* CDirectoryFactory::Create(const CStdString& strPath)
128 if (!CWakeOnAccess::Get().WakeUpHost(url))
131 CFileItem item(strPath, false);
132 IFileDirectory* pDir=CFileDirectoryFactory::Create(strPath, &item);
136 CStdString strProtocol = url.GetProtocol();
138 if (strProtocol.size() == 0 || strProtocol == "file") return new CHDDirectory();
139 if (strProtocol == "special") return new CSpecialProtocolDirectory();
140 if (strProtocol == "sources") return new CSourcesDirectory();
141 if (strProtocol == "addons") return new CAddonsDirectory();
142 #if defined(HAS_FILESYSTEM_CDDA) && defined(HAS_DVD_DRIVE)
143 if (strProtocol == "cdda") return new CCDDADirectory();
145 #ifdef HAS_FILESYSTEM
146 if (strProtocol == "iso9660") return new CISO9660Directory();
148 if (strProtocol == "udf") return new CUDFDirectory();
149 if (strProtocol == "plugin") return new CPluginDirectory();
150 #if defined(TARGET_ANDROID)
151 if (strProtocol == "apk") return new CAPKDirectory();
153 if (strProtocol == "zip") return new CZipDirectory();
154 if (strProtocol == "rar")
156 #ifdef HAS_FILESYSTEM_RAR
157 return new CRarDirectory();
159 CLog::Log(LOGWARNING, "%s - Compiled without non-free, rar support is disabled", __FUNCTION__);
162 if (strProtocol == "multipath") return new CMultiPathDirectory();
163 if (strProtocol == "stack") return new CStackDirectory();
164 if (strProtocol == "playlistmusic") return new CPlaylistDirectory();
165 if (strProtocol == "playlistvideo") return new CPlaylistDirectory();
166 if (strProtocol == "musicdb") return new CMusicDatabaseDirectory();
167 if (strProtocol == "musicsearch") return new CMusicSearchDirectory();
168 if (strProtocol == "videodb") return new CVideoDatabaseDirectory();
169 if (strProtocol == "library") return new CLibraryDirectory();
170 if (strProtocol == "favourites") return new CFavouritesDirectory();
171 if (strProtocol == "filereader")
172 return CDirectoryFactory::Create(url.GetFileName());
173 #if defined(TARGET_ANDROID)
174 if (strProtocol == "androidapp") return new CAndroidAppDirectory();
177 if( g_application.getNetwork().IsAvailable(true) ) // true to wait for the network (if possible)
179 if (strProtocol == "tuxbox") return new CTuxBoxDirectory();
180 if (strProtocol == "ftp" || strProtocol == "ftps") return new CFTPDirectory();
181 if (strProtocol == "http" || strProtocol == "https") return new CHTTPDirectory();
182 if (strProtocol == "dav" || strProtocol == "davs") return new CDAVDirectory();
183 #ifdef HAS_FILESYSTEM_SFTP
184 if (strProtocol == "sftp" || strProtocol == "ssh") return new CSFTPDirectory();
186 #ifdef HAS_FILESYSTEM_SMB
187 #ifdef TARGET_WINDOWS
188 if (strProtocol == "smb") return new CWINSMBDirectory();
190 if (strProtocol == "smb") return new CSMBDirectory();
193 #ifdef HAS_FILESYSTEM
194 #ifdef HAS_FILESYSTEM_DAAP
195 if (strProtocol == "daap") return new CDAAPDirectory();
197 #ifdef HAS_FILESYSTEM_RTV
198 if (strProtocol == "rtv") return new CRTVDirectory();
202 if (strProtocol == "upnp") return new CUPnPDirectory();
204 if (strProtocol == "hdhomerun") return new CHomeRunDirectory();
205 if (strProtocol == "sling") return new CSlingboxDirectory();
206 if (strProtocol == "myth") return new CMythDirectory();
207 if (strProtocol == "cmyth") return new CMythDirectory();
208 if (strProtocol == "rss") return new CRSSDirectory();
209 #ifdef HAS_FILESYSTEM_SAP
210 if (strProtocol == "sap") return new CSAPDirectory();
212 #ifdef HAS_FILESYSTEM_VTP
213 if (strProtocol == "vtp") return new CVTPDirectory();
215 #ifdef HAS_FILESYSTEM_HTSP
216 if (strProtocol == "htsp") return new CHTSPDirectory();
218 #ifdef HAS_PVRCLIENTS
219 if (strProtocol == "pvr") return new CPVRDirectory();
222 if (strProtocol == "zeroconf") return new CZeroconfDirectory();
224 #ifdef HAS_FILESYSTEM_NFS
225 if (strProtocol == "nfs") return new CNFSDirectory();
227 #ifdef HAS_FILESYSTEM_AFP
228 if (strProtocol == "afp") return new CAFPDirectory();
230 #ifdef HAVE_LIBBLURAY
231 if (strProtocol == "bluray") return new CBlurayDirectory();
235 CLog::Log(LOGWARNING, "%s - Unsupported protocol(%s) in %s", __FUNCTION__, strProtocol.c_str(), url.Get().c_str() );