Nikolay Sivov : scrrun: Implement GetExtensionName().
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Mar 3 09:42:10 CST 2015
Module: wine
Branch: master
Commit: 3814e0229dc8248e0df915eb84dacf092f58da6f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3814e0229dc8248e0df915eb84dacf092f58da6f
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Fri Feb 27 21:06:37 2015 +0300
scrrun: Implement GetExtensionName().
---
dlls/scrrun/filesystem.c | 22 ++++++++++++++++++----
dlls/scrrun/tests/filesystem.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index f6f7703..74e5432 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -3103,12 +3103,26 @@ static HRESULT WINAPI filesys_GetBaseName(IFileSystem3 *iface, BSTR Path,
return S_OK;
}
-static HRESULT WINAPI filesys_GetExtensionName(IFileSystem3 *iface, BSTR Path,
- BSTR *pbstrResult)
+static HRESULT WINAPI filesys_GetExtensionName(IFileSystem3 *iface, BSTR path,
+ BSTR *ext)
{
- FIXME("%p %s %p\n", iface, debugstr_w(Path), pbstrResult);
+ INT len;
- return E_NOTIMPL;
+ TRACE("%p %s %p\n", iface, debugstr_w(path), ext);
+
+ *ext = NULL;
+ len = SysStringLen(path);
+ while (len) {
+ if (path[len-1] == '.') {
+ *ext = SysAllocString(&path[len]);
+ if (!*ext)
+ return E_OUTOFMEMORY;
+ break;
+ }
+ len--;
+ }
+
+ return S_OK;
}
static HRESULT WINAPI filesys_GetAbsolutePathName(IFileSystem3 *iface, BSTR Path,
diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c
index b3f3bee..210b90c 100644
--- a/dlls/scrrun/tests/filesystem.c
+++ b/dlls/scrrun/tests/filesystem.c
@@ -1865,6 +1865,40 @@ static void test_SerialNumber(void)
IEnumVARIANT_Release(iter);
}
+static const struct extension_test {
+ WCHAR path[20];
+ WCHAR ext[10];
+} extension_tests[] = {
+ { {'n','o','e','x','t',0}, {0} },
+ { {'n','.','o','.','e','x','t',0}, {'e','x','t',0} },
+ { {'n','.','o','.','e','X','t',0}, {'e','X','t',0} },
+ { { 0 } }
+};
+
+static void test_GetExtensionName(void)
+{
+ BSTR path, ext;
+ HRESULT hr;
+ int i;
+
+ for (i = 0; i < sizeof(extension_tests)/sizeof(extension_tests[0]); i++) {
+
+ path = SysAllocString(extension_tests[i].path);
+ ext = NULL;
+ hr = IFileSystem3_GetExtensionName(fs3, path, &ext);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ if (*extension_tests[i].ext)
+ ok(!lstrcmpW(ext, extension_tests[i].ext), "%d: path %s, got %s, expected %s\n", i,
+ wine_dbgstr_w(path), wine_dbgstr_w(ext), wine_dbgstr_w(extension_tests[i].ext));
+ else
+ ok(ext == NULL, "%d: path %s, got %s, expected %s\n", i,
+ wine_dbgstr_w(path), wine_dbgstr_w(ext), wine_dbgstr_w(extension_tests[i].ext));
+
+ SysFreeString(path);
+ SysFreeString(ext);
+ }
+}
+
START_TEST(filesystem)
{
HRESULT hr;
@@ -1899,6 +1933,7 @@ START_TEST(filesystem)
test_Read();
test_GetDriveName();
test_SerialNumber();
+ test_GetExtensionName();
IFileSystem3_Release(fs3);
More information about the wine-cvs
mailing list