Dmitry Timoshkov : taskschd: Implement ITaskFolder::get_Path.

Alexandre Julliard julliard at winehq.org
Fri Jan 17 11:55:33 CST 2014


Module: wine
Branch: master
Commit: 663444ccb70899887537697f08d9f024a6ee885f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=663444ccb70899887537697f08d9f024a6ee885f

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Fri Jan 17 18:00:08 2014 +0900

taskschd: Implement ITaskFolder::get_Path.

---

 dlls/taskschd/folder.c          |   51 ++++++++++++++++++++++++++++++++++++---
 dlls/taskschd/tests/scheduler.c |    5 ----
 2 files changed, 48 insertions(+), 8 deletions(-)

diff --git a/dlls/taskschd/folder.c b/dlls/taskschd/folder.c
index ef69cfe..c19aa4e 100644
--- a/dlls/taskschd/folder.c
+++ b/dlls/taskschd/folder.c
@@ -35,6 +35,7 @@ typedef struct
 {
     ITaskFolder ITaskFolder_iface;
     LONG ref;
+    WCHAR *path;
 } TaskFolder;
 
 static inline TaskFolder *impl_from_ITaskFolder(ITaskFolder *iface)
@@ -56,6 +57,7 @@ static ULONG WINAPI TaskFolder_Release(ITaskFolder *iface)
     if (!ref)
     {
         TRACE("destroying %p\n", iface);
+        HeapFree(GetProcessHeap(), 0, folder->path);
         HeapFree(GetProcessHeap(), 0, folder);
     }
 
@@ -116,8 +118,16 @@ static HRESULT WINAPI TaskFolder_get_Name(ITaskFolder *iface, BSTR *name)
 
 static HRESULT WINAPI TaskFolder_get_Path(ITaskFolder *iface, BSTR *path)
 {
-    FIXME("%p,%p: stub\n", iface, path);
-    return E_NOTIMPL;
+    TaskFolder *folder = impl_from_ITaskFolder(iface);
+
+    TRACE("%p,%p\n", iface, path);
+
+    if (!path) return E_POINTER;
+
+    *path = SysAllocString(folder->path);
+    if (!*path) return E_OUTOFMEMORY;
+
+    return S_OK;
 }
 
 static HRESULT WINAPI TaskFolder_GetFolder(ITaskFolder *iface, BSTR path, ITaskFolder **folder)
@@ -218,13 +228,48 @@ static const ITaskFolderVtbl TaskFolder_vtbl =
 
 HRESULT TaskFolder_create(const WCHAR *parent, const WCHAR *path, ITaskFolder **obj)
 {
+    static const WCHAR bslash[] = { '\\', 0 };
     TaskFolder *folder;
+    WCHAR *folder_path;
+    int len = 0;
+
+    if (path)
+    {
+        len = strlenW(path);
+        if (len && path[len - 1] == '\\') return ERROR_INVALID_NAME;
+    }
+
+    if (parent) len += strlenW(parent);
+
+    /* +1 if parent is not '\' terminated */
+    folder_path = HeapAlloc(GetProcessHeap(), 0, (len + 2) * sizeof(WCHAR));
+    if (!folder_path) return E_OUTOFMEMORY;
+
+    folder_path[0] = 0;
+
+    if (parent)
+        strcpyW(folder_path, parent);
+
+    len = strlenW(folder_path);
+    if (!len || folder_path[len - 1] != '\\')
+        strcatW(folder_path, bslash);
+
+    if (path)
+    {
+        while (*path == '\\') path++;
+        strcatW(folder_path, path);
+    }
 
     folder = HeapAlloc(GetProcessHeap(), 0, sizeof(*folder));
-    if (!folder) return E_OUTOFMEMORY;
+    if (!folder)
+    {
+        HeapFree(GetProcessHeap(), 0, folder_path);
+        return E_OUTOFMEMORY;
+    }
 
     folder->ITaskFolder_iface.lpVtbl = &TaskFolder_vtbl;
     folder->ref = 1;
+    folder->path = folder_path;
     *obj = &folder->ITaskFolder_iface;
 
     TRACE("created %p\n", *obj);
diff --git a/dlls/taskschd/tests/scheduler.c b/dlls/taskschd/tests/scheduler.c
index 74ae95f..38d60a4 100644
--- a/dlls/taskschd/tests/scheduler.c
+++ b/dlls/taskschd/tests/scheduler.c
@@ -182,17 +182,12 @@ if (hr == S_OK)
 }
 
     hr = ITaskFolder_get_Path(folder, NULL);
-todo_wine
     ok(hr == E_POINTER, "expected E_POINTER, got %#x\n", hr);
 
     hr = ITaskFolder_get_Path(folder, &bstr);
-todo_wine
     ok(hr == S_OK, "get_Path error %#x\n", hr);
-if (hr == S_OK)
-{
     ok(!lstrcmpW(bstr, bslash), "expected '\\', got %s\n", wine_dbgstr_w(bstr));
     SysFreeString(bstr);
-}
 
     hr = ITaskFolder_CreateFolder(folder, NULL, v_null, &subfolder);
 todo_wine




More information about the wine-cvs mailing list