aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorulion <ulion2002@gmail.com>2013-04-02 12:43:45 +0800
committerulion <ulion2002@gmail.com>2013-04-02 13:21:02 +0800
commitb7649266181ff86f33149276c68c002af4cbc7ab (patch)
tree05e843a9ec47ea8e07b9a110746f521fdba9bb3f
parent0482c221315607f81fc077814e0eb4855f200aa7 (diff)
[Fix] xbmcvfs.exists to support check dir existence. fix #13789
-rw-r--r--xbmc/interfaces/legacy/ModuleXbmcvfs.cpp2
-rw-r--r--xbmc/interfaces/legacy/ModuleXbmcvfs.h2
-rw-r--r--xbmc/utils/URIUtils.cpp8
-rw-r--r--xbmc/utils/URIUtils.h2
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);