Commit 663444cc authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

taskschd: Implement ITaskFolder::get_Path.

parent fe55cb10
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment