From b7649266181ff86f33149276c68c002af4cbc7ab Mon Sep 17 00:00:00 2001 From: ulion Date: Tue, 2 Apr 2013 12:43:45 +0800 Subject: [Fix] xbmcvfs.exists to support check dir existence. fix #13789 --- xbmc/interfaces/legacy/ModuleXbmcvfs.cpp | 2 ++ xbmc/interfaces/legacy/ModuleXbmcvfs.h | 2 +- xbmc/utils/URIUtils.cpp | 8 +++++++- xbmc/utils/URIUtils.h | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/xbmc/interfaces/legacy/ModuleXbmcvfs.cpp b/xbmc/interfaces/legacy/ModuleXbmcvfs.cpp index c614d283a1..1eb2862bc8 100644 --- a/xbmc/interfaces/legacy/ModuleXbmcvfs.cpp +++ b/xbmc/interfaces/legacy/ModuleXbmcvfs.cpp @@ -56,6 +56,8 @@ namespace XBMCAddon bool exists(const String& path) { DelayedCallGuard dg; + if (URIUtils::HasSlashAtEnd(path, true)) + return XFILE::CDirectory::Exists(path); return XFILE::CFile::Exists(path, false); } diff --git a/xbmc/interfaces/legacy/ModuleXbmcvfs.h b/xbmc/interfaces/legacy/ModuleXbmcvfs.h index 69166658bf..f5965e10ab 100644 --- a/xbmc/interfaces/legacy/ModuleXbmcvfs.h +++ b/xbmc/interfaces/legacy/ModuleXbmcvfs.h @@ -67,7 +67,7 @@ namespace XBMCAddon /** * exists(path) * - * path : file or fold + * path : file or folder (folder must end with slash or backslash) * * example: * success = xbmcvfs.exists(path) diff --git a/xbmc/utils/URIUtils.cpp b/xbmc/utils/URIUtils.cpp index cfb9de81c5..cd45b0ff33 100644 --- a/xbmc/utils/URIUtils.cpp +++ b/xbmc/utils/URIUtils.cpp @@ -886,9 +886,15 @@ void URIUtils::AddSlashAtEnd(CStdString& strFolder) } } -bool URIUtils::HasSlashAtEnd(const CStdString& strFile) +bool URIUtils::HasSlashAtEnd(const CStdString& strFile, bool checkURL /* = false */) { if (strFile.size() == 0) return false; + if (checkURL && IsURL(strFile)) + { + CURL url(strFile); + CStdString file = url.GetFileName(); + return file.IsEmpty() || HasSlashAtEnd(file, false); + } char kar = strFile.c_str()[strFile.size() - 1]; if (kar == '/' || kar == '\\') diff --git a/xbmc/utils/URIUtils.h b/xbmc/utils/URIUtils.h index 826489d0f7..9cd7a4afe6 100644 --- a/xbmc/utils/URIUtils.h +++ b/xbmc/utils/URIUtils.h @@ -97,7 +97,7 @@ public: static bool IsAndroidApp(const CStdString& strFile); static void AddSlashAtEnd(CStdString& strFolder); - static bool HasSlashAtEnd(const CStdString& strFile); + static bool HasSlashAtEnd(const CStdString& strFile, bool checkURL = false); static void RemoveSlashAtEnd(CStdString& strFolder); static bool CompareWithoutSlashAtEnd(const CStdString& strPath1, const CStdString& strPath2); -- cgit v1.2.3