Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[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
View
16 xbmc/filesystem/windows/WINFileSMB.cpp
@@ -97,24 +97,28 @@ bool CWINFileSMB::Open(const CURL& url)
bool CWINFileSMB::Exists(const CURL& url)
{
- struct __stat64 buffer;
- if(url.GetFileName() == url.GetShareName())
- return false;
CStdString strFile = GetLocal(url);
URIUtils::RemoveSlashAtEnd(strFile);
CStdStringW strWFile;
g_charsetConverter.utf8ToW(strFile, strWFile, false);
- if(_wstat64(strWFile.c_str(), &buffer) == 0)
+ DWORD attributes = GetFileAttributesW(strWFile.c_str());
+ if(attributes != INVALID_FILE_ATTRIBUTES)
return true;
- if(errno == ENOENT)
+ DWORD err = GetLastError();
+ if(err != ERROR_ACCESS_DENIED)
return false;
XFILE::CWINSMBDirectory smb;
if(smb.ConnectToShare(url) == false)
return false;
- return (_wstat64(strWFile.c_str(), &buffer) == 0);
+ attributes = GetFileAttributesW(strWFile.c_str());
+
+ if(attributes == INVALID_FILE_ATTRIBUTES)
+ return false;
+
+ return true;
}
int CWINFileSMB::Stat(struct __stat64* buffer)
View
1  xbmc/filesystem/windows/WINSMBDirectory.cpp
@@ -199,7 +199,6 @@ bool CWINSMBDirectory::Exists(const char* strPath)
CStdString strReplaced=GetLocal(strPath);
CStdStringW strWReplaced;
g_charsetConverter.utf8ToW(strReplaced, strWReplaced, false);
- // this will fail on shares, needs a subdirectory inside a share
DWORD attributes = GetFileAttributesW(strWReplaced);
if(attributes == INVALID_FILE_ATTRIBUTES)
return false;

1 comment on commit 1d956fd

@robweber

This was done super fast - thanks!

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