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 WIN32)
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 "LibraryDirectory.h"
37 #include "AddonsDirectory.h"
38 #include "SourcesDirectory.h"
39 #include "LastFMDirectory.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"
48 #ifdef HAS_FILESYSTEM_SMB
50 #include "windows/WINSMBDirectory.h"
52 #include "SMBDirectory.h"
55 #ifdef HAS_FILESYSTEM_CDDA
56 #include "CDDADirectory.h"
58 #include "PluginDirectory.h"
60 #include "ISO9660Directory.h"
61 #ifdef HAS_FILESYSTEM_RTV
62 #include "RTVDirectory.h"
64 #ifdef HAS_FILESYSTEM_DAAP
65 #include "DAAPDirectory.h"
69 #include "UPnPDirectory.h"
71 #ifdef HAS_FILESYSTEM_SAP
72 #include "SAPDirectory.h"
74 #ifdef HAS_FILESYSTEM_VTP
75 #include "VTPDirectory.h"
77 #ifdef HAS_FILESYSTEM_HTSP
78 #include "HTSPDirectory.h"
81 #include "PVRDirectory.h"
83 #if defined(TARGET_ANDROID)
84 #include "APKDirectory.h"
86 #include "ZipDirectory.h"
87 #ifdef HAS_FILESYSTEM_RAR
88 #include "RarDirectory.h"
90 #include "TuxBoxDirectory.h"
91 #include "HDHomeRunDirectory.h"
92 #include "SlingboxDirectory.h"
93 #include "MythDirectory.h"
96 #include "RSSDirectory.h"
98 #include "ZeroconfDirectory.h"
100 #ifdef HAS_FILESYSTEM_SFTP
101 #include "SFTPDirectory.h"
103 #ifdef HAS_FILESYSTEM_NFS
104 #include "NFSDirectory.h"
106 #ifdef HAS_FILESYSTEM_AFP
107 #include "AFPDirectory.h"
109 #ifdef HAVE_LIBBLURAY
110 #include "BlurayDirectory.h"
112 #if defined(TARGET_ANDROID)
113 #include "AndroidAppDirectory.h"
116 using namespace XFILE;
119 \brief Create a IDirectory object of the share type specified in \e strPath .
120 \param strPath Specifies the share type to access, can be a share or share with path.
121 \return IDirectory object to access the directories on the share.
124 IDirectory* CDirectoryFactory::Create(const CStdString& strPath)
128 CFileItem item(strPath, false);
129 IFileDirectory* pDir=CFileDirectoryFactory::Create(strPath, &item);
133 CStdString strProtocol = url.GetProtocol();
135 if (strProtocol.size() == 0 || strProtocol == "file") return new CHDDirectory();
136 if (strProtocol == "special") return new CSpecialProtocolDirectory();
137 if (strProtocol == "sources") return new CSourcesDirectory();
138 if (strProtocol == "addons") return new CAddonsDirectory();
139 #if defined(HAS_FILESYSTEM_CDDA) && defined(HAS_DVD_DRIVE)
140 if (strProtocol == "cdda") return new CCDDADirectory();
142 #ifdef HAS_FILESYSTEM
143 if (strProtocol == "iso9660") return new CISO9660Directory();
145 if (strProtocol == "udf") return new CUDFDirectory();
146 if (strProtocol == "plugin") return new CPluginDirectory();
147 #if defined(TARGET_ANDROID)
148 if (strProtocol == "apk") return new CAPKDirectory();
150 if (strProtocol == "zip") return new CZipDirectory();
151 if (strProtocol == "rar")
153 #ifdef HAS_FILESYSTEM_RAR
154 return new CRarDirectory();
156 CLog::Log(LOGWARNING, "%s - Compiled without non-free, rar support is disabled", __FUNCTION__);
159 if (strProtocol == "multipath") return new CMultiPathDirectory();
160 if (strProtocol == "stack") return new CStackDirectory();
161 if (strProtocol == "playlistmusic") return new CPlaylistDirectory();
162 if (strProtocol == "playlistvideo") return new CPlaylistDirectory();
163 if (strProtocol == "musicdb") return new CMusicDatabaseDirectory();
164 if (strProtocol == "musicsearch") return new CMusicSearchDirectory();
165 if (strProtocol == "videodb") return new CVideoDatabaseDirectory();
166 if (strProtocol == "library") return new CLibraryDirectory();
167 if (strProtocol == "filereader")
168 return CDirectoryFactory::Create(url.GetFileName());
170 if( g_application.getNetwork().IsAvailable(true) ) // true to wait for the network (if possible)
172 if (strProtocol == "lastfm") return new CLastFMDirectory();
173 if (strProtocol == "tuxbox") return new CTuxBoxDirectory();
174 if (strProtocol == "ftp" || strProtocol == "ftps") return new CFTPDirectory();
175 if (strProtocol == "http" || strProtocol == "https") return new CHTTPDirectory();
176 if (strProtocol == "dav" || strProtocol == "davs") return new CDAVDirectory();
177 #ifdef HAS_FILESYSTEM_SFTP
178 if (strProtocol == "sftp" || strProtocol == "ssh") return new CSFTPDirectory();
180 #ifdef HAS_FILESYSTEM_SMB
182 if (strProtocol == "smb") return new CWINSMBDirectory();
184 if (strProtocol == "smb") return new CSMBDirectory();
187 #ifdef HAS_FILESYSTEM
188 #ifdef HAS_FILESYSTEM_DAAP
189 if (strProtocol == "daap") return new CDAAPDirectory();
191 #ifdef HAS_FILESYSTEM_RTV
192 if (strProtocol == "rtv") return new CRTVDirectory();
196 if (strProtocol == "upnp") return new CUPnPDirectory();
198 if (strProtocol == "hdhomerun") return new CHomeRunDirectory();
199 if (strProtocol == "sling") return new CSlingboxDirectory();
200 if (strProtocol == "myth") return new CMythDirectory();
201 if (strProtocol == "cmyth") return new CMythDirectory();
202 if (strProtocol == "rss") return new CRSSDirectory();
203 #ifdef HAS_FILESYSTEM_SAP
204 if (strProtocol == "sap") return new CSAPDirectory();
206 #ifdef HAS_FILESYSTEM_VTP
207 if (strProtocol == "vtp") return new CVTPDirectory();
209 #ifdef HAS_FILESYSTEM_HTSP
210 if (strProtocol == "htsp") return new CHTSPDirectory();
212 #ifdef HAS_PVRCLIENTS
213 if (strProtocol == "pvr") return new CPVRDirectory();
216 if (strProtocol == "zeroconf") return new CZeroconfDirectory();
218 #ifdef HAS_FILESYSTEM_NFS
219 if (strProtocol == "nfs") return new CNFSDirectory();
221 #ifdef HAS_FILESYSTEM_AFP
222 if (strProtocol == "afp") return new CAFPDirectory();
224 #ifdef HAVE_LIBBLURAY
225 if (strProtocol == "bluray") return new CBlurayDirectory();
227 #if defined(TARGET_ANDROID)
228 if (strProtocol == "androidapp") return new CAndroidAppDirectory();
232 CLog::Log(LOGWARNING, "%s - Unsupported protocol(%s) in %s", __FUNCTION__, strProtocol.c_str(), url.Get().c_str() );