Skip to content
This repository
Browse code

[WIN] fixed #13581: XBMCVFS.Exists() not working correctly. wstat doe…

…s only work on directories inside a share and not on the share itself. Even though the same should be true for GetFileAttributesW (according to the M$ docs) it works for the tested environments.
  • Loading branch information...
commit 1d956fdee1f61a0d0dfdedd437e631efee22e66f 1 parent 4bf192d
wsoltys authored November 21, 2012
16  xbmc/filesystem/windows/WINFileSMB.cpp
@@ -97,24 +97,28 @@ bool CWINFileSMB::Open(const CURL& url)
97 97
 
98 98
 bool CWINFileSMB::Exists(const CURL& url)
99 99
 {
100  
-  struct __stat64 buffer;
101  
-  if(url.GetFileName() == url.GetShareName())
102  
-    return false;
103 100
   CStdString strFile = GetLocal(url);
104 101
   URIUtils::RemoveSlashAtEnd(strFile);
105 102
   CStdStringW strWFile;
106 103
   g_charsetConverter.utf8ToW(strFile, strWFile, false);
107  
-  if(_wstat64(strWFile.c_str(), &buffer) == 0)
  104
+  DWORD attributes = GetFileAttributesW(strWFile.c_str());
  105
+  if(attributes != INVALID_FILE_ATTRIBUTES)
108 106
     return true;
109 107
 
110  
-  if(errno == ENOENT)
  108
+  DWORD err = GetLastError();
  109
+  if(err != ERROR_ACCESS_DENIED)
111 110
     return false;
112 111
 
113 112
   XFILE::CWINSMBDirectory smb;
114 113
   if(smb.ConnectToShare(url) == false)
115 114
     return false;
116 115
 
117  
-  return (_wstat64(strWFile.c_str(), &buffer) == 0);
  116
+  attributes = GetFileAttributesW(strWFile.c_str());
  117
+
  118
+  if(attributes == INVALID_FILE_ATTRIBUTES)
  119
+    return false;
  120
+
  121
+  return true;
118 122
 }
119 123
 
120 124
 int CWINFileSMB::Stat(struct __stat64* buffer)
1  xbmc/filesystem/windows/WINSMBDirectory.cpp
@@ -199,7 +199,6 @@ bool CWINSMBDirectory::Exists(const char* strPath)
199 199
   CStdString strReplaced=GetLocal(strPath);
200 200
   CStdStringW strWReplaced;
201 201
   g_charsetConverter.utf8ToW(strReplaced, strWReplaced, false);
202  
-  // this will fail on shares, needs a subdirectory inside a share
203 202
   DWORD attributes = GetFileAttributesW(strWReplaced);
204 203
   if(attributes == INVALID_FILE_ATTRIBUTES)
205 204
     return false;

1 note on commit 1d956fd

robweber

This was done super fast - thanks!

Please sign in to comment.
Something went wrong with that request. Please try again.