[SCRRUN]
authorAmine Khaldi <amine.khaldi@reactos.org>
Wed, 8 Oct 2014 18:03:53 +0000 (18:03 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Wed, 8 Oct 2014 18:03:53 +0000 (18:03 +0000)
* Sync with Wine 1.7.27.
CORE-8540

svn path=/trunk/; revision=64601

reactos/dll/win32/scrrun/filesystem.c
reactos/media/doc/README.WINE

index d22bb1f..26a0a4b 100644 (file)
@@ -875,6 +875,24 @@ static HRESULT WINAPI drive_get_RootFolder(IDrive *iface, IFolder **folder)
     return E_NOTIMPL;
 }
 
+static HRESULT variant_from_largeint(const ULARGE_INTEGER *src, VARIANT *v)
+{
+    HRESULT hr = S_OK;
+
+    if (src->u.HighPart || src->u.LowPart > INT_MAX)
+    {
+        V_VT(v) = VT_R8;
+        hr = VarR8FromUI8(src->QuadPart, &V_R8(v));
+    }
+    else
+    {
+        V_VT(v) = VT_I4;
+        V_I4(v) = src->u.LowPart;
+    }
+
+    return hr;
+}
+
 static HRESULT WINAPI drive_get_AvailableSpace(IDrive *iface, VARIANT *v)
 {
     struct drive *This = impl_from_IDrive(iface);
@@ -888,8 +906,7 @@ static HRESULT WINAPI drive_get_AvailableSpace(IDrive *iface, VARIANT *v)
     if (!GetDiskFreeSpaceExW(This->root, &avail, NULL, NULL))
         return E_FAIL;
 
-    V_VT(v) = VT_R8;
-    return VarR8FromUI8(avail.QuadPart, &V_R8(v));
+    return variant_from_largeint(&avail, v);
 }
 
 static HRESULT WINAPI drive_get_FreeSpace(IDrive *iface, VARIANT *v)
@@ -905,8 +922,7 @@ static HRESULT WINAPI drive_get_FreeSpace(IDrive *iface, VARIANT *v)
     if (!GetDiskFreeSpaceExW(This->root, &freespace, NULL, NULL))
         return E_FAIL;
 
-    V_VT(v) = VT_R8;
-    return VarR8FromUI8(freespace.QuadPart, &V_R8(v));
+    return variant_from_largeint(&freespace, v);
 }
 
 static HRESULT WINAPI drive_get_TotalSize(IDrive *iface, VARIANT *v)
@@ -922,15 +938,25 @@ static HRESULT WINAPI drive_get_TotalSize(IDrive *iface, VARIANT *v)
     if (!GetDiskFreeSpaceExW(This->root, NULL, &total, NULL))
         return E_FAIL;
 
-    V_VT(v) = VT_R8;
-    return VarR8FromUI8(total.QuadPart, &V_R8(v));
+    return variant_from_largeint(&total, v);
 }
 
 static HRESULT WINAPI drive_get_VolumeName(IDrive *iface, BSTR *name)
 {
     struct drive *This = impl_from_IDrive(iface);
-    FIXME("(%p)->(%p): stub\n", This, name);
-    return E_NOTIMPL;
+    WCHAR nameW[MAX_PATH+1];
+    BOOL ret;
+
+    TRACE("(%p)->(%p)\n", This, name);
+
+    if (!name)
+        return E_POINTER;
+
+    *name = NULL;
+    ret = GetVolumeInformationW(This->root, nameW, sizeof(nameW)/sizeof(WCHAR), NULL, NULL, NULL, NULL, 0);
+    if (ret)
+        *name = SysAllocString(nameW);
+    return ret ? S_OK : E_FAIL;
 }
 
 static HRESULT WINAPI drive_put_VolumeName(IDrive *iface, BSTR name)
@@ -943,15 +969,33 @@ static HRESULT WINAPI drive_put_VolumeName(IDrive *iface, BSTR name)
 static HRESULT WINAPI drive_get_FileSystem(IDrive *iface, BSTR *fs)
 {
     struct drive *This = impl_from_IDrive(iface);
-    FIXME("(%p)->(%p): stub\n", This, fs);
-    return E_NOTIMPL;
+    WCHAR nameW[MAX_PATH+1];
+    BOOL ret;
+
+    TRACE("(%p)->(%p)\n", This, fs);
+
+    if (!fs)
+        return E_POINTER;
+
+    *fs = NULL;
+    ret = GetVolumeInformationW(This->root, NULL, 0, NULL, NULL, NULL, nameW, sizeof(nameW)/sizeof(WCHAR));
+    if (ret)
+        *fs = SysAllocString(nameW);
+    return ret ? S_OK : E_FAIL;
 }
 
 static HRESULT WINAPI drive_get_SerialNumber(IDrive *iface, LONG *serial)
 {
     struct drive *This = impl_from_IDrive(iface);
-    FIXME("(%p)->(%p): stub\n", This, serial);
-    return E_NOTIMPL;
+    BOOL ret;
+
+    TRACE("(%p)->(%p)\n", This, serial);
+
+    if (!serial)
+        return E_POINTER;
+
+    ret = GetVolumeInformationW(This->root, NULL, 0, (DWORD*)serial, NULL, NULL, NULL, 0);
+    return ret ? S_OK : E_FAIL;
 }
 
 static HRESULT WINAPI drive_get_IsReady(IDrive *iface, VARIANT_BOOL *ready)
@@ -1073,7 +1117,7 @@ static HANDLE start_enumeration(const WCHAR *path, WIN32_FIND_DATAW *data, BOOL
 
     strcpyW(pathW, path);
     len = strlenW(pathW);
-    if (pathW[len-1] != '\\')
+    if (len && pathW[len-1] != '\\')
         strcatW(pathW, bsW);
     strcatW(pathW, allW);
     handle = FindFirstFileW(pathW, data);
@@ -1818,8 +1862,32 @@ static HRESULT WINAPI filecoll_get__NewEnum(IFileCollection *iface, IUnknown **p
 static HRESULT WINAPI filecoll_get_Count(IFileCollection *iface, LONG *count)
 {
     struct filecollection *This = impl_from_IFileCollection(iface);
-    FIXME("(%p)->(%p)\n", This, count);
-    return E_NOTIMPL;
+    static const WCHAR allW[] = {'\\','*',0};
+    WIN32_FIND_DATAW data;
+    WCHAR pathW[MAX_PATH];
+    HANDLE handle;
+
+    TRACE("(%p)->(%p)\n", This, count);
+
+    if(!count)
+        return E_POINTER;
+
+    *count = 0;
+
+    strcpyW(pathW, This->path);
+    strcatW(pathW, allW);
+    handle = FindFirstFileW(pathW, &data);
+    if (handle == INVALID_HANDLE_VALUE)
+        return HRESULT_FROM_WIN32(GetLastError());
+
+    do
+    {
+        if (is_file_data(&data))
+            *count += 1;
+    } while (FindNextFileW(handle, &data));
+    FindClose(handle);
+
+    return S_OK;
 }
 
 static const IFileCollectionVtbl filecollectionvtbl = {
@@ -2583,6 +2651,7 @@ static HRESULT WINAPI file_get_DateLastAccessed(IFile *iface, DATE *pdate)
 static HRESULT WINAPI file_get_Size(IFile *iface, VARIANT *pvarSize)
 {
     struct file *This = impl_from_IFile(iface);
+    ULARGE_INTEGER size;
     WIN32_FIND_DATAW fd;
     HANDLE f;
 
@@ -2596,14 +2665,10 @@ static HRESULT WINAPI file_get_Size(IFile *iface, VARIANT *pvarSize)
         return create_error(GetLastError());
     FindClose(f);
 
-    if(fd.nFileSizeHigh || fd.nFileSizeLow>INT_MAX) {
-        V_VT(pvarSize) = VT_R8;
-        V_R8(pvarSize) = ((ULONGLONG)fd.nFileSizeHigh<<32) + fd.nFileSizeLow;
-    }else {
-        V_VT(pvarSize) = VT_I4;
-        V_I4(pvarSize) = fd.nFileSizeLow;
-    }
-    return S_OK;
+    size.u.LowPart = fd.nFileSizeLow;
+    size.u.HighPart = fd.nFileSizeHigh;
+
+    return variant_from_largeint(&size, pvarSize);
 }
 
 static HRESULT WINAPI file_get_Type(IFile *iface, BSTR *pbstrType)
@@ -2708,9 +2773,6 @@ static HRESULT create_file(BSTR path, IFile **file)
         return E_FAIL;
     }
 
-    if(path[len-1]=='/' || path[len-1]=='\\')
-        path[len-1] = 0;
-
     attrs = GetFileAttributesW(f->path);
     if(attrs==INVALID_FILE_ATTRIBUTES ||
             (attrs&(FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_DEVICE))) {
@@ -2891,12 +2953,19 @@ static HRESULT WINAPI filesys_BuildPath(IFileSystem3 *iface, BSTR Path,
     return S_OK;
 }
 
-static HRESULT WINAPI filesys_GetDriveName(IFileSystem3 *iface, BSTR Path,
-                                            BSTR *pbstrResult)
+static HRESULT WINAPI filesys_GetDriveName(IFileSystem3 *iface, BSTR path, BSTR *drive)
 {
-    FIXME("%p %s %p\n", iface, debugstr_w(Path), pbstrResult);
+    TRACE("(%p)->(%s %p)\n", iface, debugstr_w(path), drive);
 
-    return E_NOTIMPL;
+    if (!drive)
+        return E_POINTER;
+
+    *drive = NULL;
+
+    if (path && strlenW(path) > 1 && path[1] == ':')
+        *drive = SysAllocStringLen(path, 2);
+
+    return S_OK;
 }
 
 static inline DWORD get_parent_folder_name(const WCHAR *path, DWORD len)
@@ -3644,11 +3713,15 @@ static HRESULT WINAPI filesys_GetFileVersion(IFileSystem3 *iface, BSTR name, BST
     }
 
     ret = VerQueryValueW(ptr, rootW, (void**)&info, &len);
-    heap_free(ptr);
     if (!ret)
+    {
+        heap_free(ptr);
         return HRESULT_FROM_WIN32(GetLastError());
+    }
 
     get_versionstring(info, ver);
+    heap_free(ptr);
+
     *version = SysAllocString(ver);
     TRACE("version=%s\n", debugstr_w(ver));
 
index 8761993..0d2e1e2 100644 (file)
@@ -176,7 +176,7 @@ reactos/dll/win32/rsabase             # Synced to Wine-1.7.17
 reactos/dll/win32/rsaenh              # Synced to Wine-1.7.27
 reactos/dll/win32/sccbase             # Synced to Wine-1.7.17
 reactos/dll/win32/schannel            # Synced to Wine-1.7.27
-reactos/dll/win32/scrrun              # Synced to Wine-1.7.17
+reactos/dll/win32/scrrun              # Synced to Wine-1.7.27
 reactos/dll/win32/secur32             # Forked
 reactos/dll/win32/security            # Forked (different .spec)
 reactos/dll/win32/sensapi             # Synced to Wine-1.7.17