2012-03-22 06:24:24 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright 2012 Alistair Leslie-Hughes
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "windows.h"
|
|
|
|
#include "ole2.h"
|
2012-11-04 22:59:00 +01:00
|
|
|
#include "olectl.h"
|
2012-07-12 00:00:42 +02:00
|
|
|
#include "oleauto.h"
|
2012-03-22 06:24:24 +01:00
|
|
|
#include "dispex.h"
|
|
|
|
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
#include "initguid.h"
|
|
|
|
#include "scrrun.h"
|
|
|
|
|
2012-04-20 08:40:00 +02:00
|
|
|
static void test_interfaces(void)
|
2012-03-22 06:24:24 +01:00
|
|
|
{
|
2012-07-30 01:02:39 +02:00
|
|
|
static const WCHAR nonexistent_dirW[] = {
|
|
|
|
'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', 0};
|
2012-11-04 22:59:00 +01:00
|
|
|
static const WCHAR pathW[] = {'p','a','t','h',0};
|
2012-07-30 01:02:39 +02:00
|
|
|
static const WCHAR file_kernel32W[] = {
|
|
|
|
'\\', 'k', 'e', 'r', 'n', 'e', 'l', '3', '2', '.', 'd', 'l', 'l', 0};
|
2012-03-22 06:24:24 +01:00
|
|
|
HRESULT hr;
|
|
|
|
IDispatch *disp;
|
|
|
|
IDispatchEx *dispex;
|
|
|
|
IFileSystem3 *fs3;
|
|
|
|
IObjectWithSite *site;
|
2012-07-12 00:00:42 +02:00
|
|
|
VARIANT_BOOL b;
|
|
|
|
BSTR path;
|
2012-07-30 01:02:39 +02:00
|
|
|
WCHAR windows_path[MAX_PATH];
|
|
|
|
WCHAR file_path[MAX_PATH];
|
2012-03-22 06:24:24 +01:00
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_FileSystemObject, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
|
|
|
&IID_IDispatch, (void**)&disp);
|
|
|
|
if(FAILED(hr)) {
|
|
|
|
win_skip("Could not create FileSystem object: %08x\n", hr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-07-30 01:02:39 +02:00
|
|
|
GetSystemDirectoryW(windows_path, MAX_PATH);
|
|
|
|
lstrcpyW(file_path, windows_path);
|
|
|
|
lstrcatW(file_path, file_kernel32W);
|
|
|
|
|
2012-03-22 06:24:24 +01:00
|
|
|
hr = IDispatch_QueryInterface(disp, &IID_IFileSystem3, (void**)&fs3);
|
|
|
|
ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
|
|
|
|
|
|
|
|
hr = IDispatch_QueryInterface(disp, &IID_IObjectWithSite, (void**)&site);
|
|
|
|
ok(hr == E_NOINTERFACE, "got 0x%08x, expected 0x%08x\n", hr, E_NOINTERFACE);
|
|
|
|
|
|
|
|
hr = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
|
|
|
|
ok(hr == E_NOINTERFACE, "got 0x%08x, expected 0x%08x\n", hr, E_NOINTERFACE);
|
|
|
|
|
2012-07-12 00:00:42 +02:00
|
|
|
b = VARIANT_TRUE;
|
|
|
|
hr = IFileSystem3_FileExists(fs3, NULL, &b);
|
|
|
|
ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
|
|
|
|
ok(b == VARIANT_FALSE, "got %x\n", b);
|
|
|
|
|
|
|
|
hr = IFileSystem3_FileExists(fs3, NULL, NULL);
|
|
|
|
ok(hr == E_POINTER, "got 0x%08x, expected 0x%08x\n", hr, E_POINTER);
|
|
|
|
|
|
|
|
path = SysAllocString(pathW);
|
|
|
|
b = VARIANT_TRUE;
|
|
|
|
hr = IFileSystem3_FileExists(fs3, path, &b);
|
|
|
|
ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
|
|
|
|
ok(b == VARIANT_FALSE, "got %x\n", b);
|
|
|
|
SysFreeString(path);
|
2012-08-06 00:38:17 +02:00
|
|
|
|
|
|
|
path = SysAllocString(file_path);
|
|
|
|
b = VARIANT_FALSE;
|
|
|
|
hr = IFileSystem3_FileExists(fs3, path, &b);
|
|
|
|
ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
|
|
|
|
ok(b == VARIANT_TRUE, "got %x\n", b);
|
|
|
|
SysFreeString(path);
|
|
|
|
|
|
|
|
path = SysAllocString(windows_path);
|
|
|
|
b = VARIANT_TRUE;
|
|
|
|
hr = IFileSystem3_FileExists(fs3, path, &b);
|
|
|
|
ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
|
|
|
|
ok(b == VARIANT_FALSE, "got %x\n", b);
|
|
|
|
SysFreeString(path);
|
2012-07-12 00:00:42 +02:00
|
|
|
|
2012-07-30 01:02:39 +02:00
|
|
|
/* Folder Exists */
|
|
|
|
hr = IFileSystem3_FolderExists(fs3, NULL, NULL);
|
|
|
|
ok(hr == E_POINTER, "got 0x%08x, expected 0x%08x\n", hr, E_POINTER);
|
|
|
|
|
|
|
|
path = SysAllocString(windows_path);
|
|
|
|
hr = IFileSystem3_FolderExists(fs3, path, &b);
|
|
|
|
ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
|
|
|
|
ok(b == VARIANT_TRUE, "Folder doesn't exists\n");
|
|
|
|
SysFreeString(path);
|
|
|
|
|
|
|
|
path = SysAllocString(nonexistent_dirW);
|
|
|
|
hr = IFileSystem3_FolderExists(fs3, path, &b);
|
|
|
|
ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
|
|
|
|
ok(b == VARIANT_FALSE, "Folder exists\n");
|
|
|
|
SysFreeString(path);
|
|
|
|
|
|
|
|
path = SysAllocString(file_path);
|
|
|
|
hr = IFileSystem3_FolderExists(fs3, path, &b);
|
|
|
|
ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
|
|
|
|
ok(b == VARIANT_FALSE, "Folder exists\n");
|
|
|
|
SysFreeString(path);
|
|
|
|
|
2012-07-12 00:00:42 +02:00
|
|
|
IFileSystem3_Release(fs3);
|
2012-03-22 06:24:24 +01:00
|
|
|
IDispatch_Release(disp);
|
|
|
|
}
|
|
|
|
|
2012-11-04 22:59:00 +01:00
|
|
|
static void test_createfolder(void)
|
|
|
|
{
|
|
|
|
IFileSystem3 *fs3;
|
|
|
|
HRESULT hr;
|
|
|
|
WCHAR pathW[MAX_PATH];
|
|
|
|
BSTR path;
|
|
|
|
IFolder *folder;
|
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_FileSystemObject, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
|
|
|
|
&IID_IFileSystem3, (void**)&fs3);
|
|
|
|
if(FAILED(hr)) {
|
|
|
|
win_skip("Could not create FileSystem object: %08x\n", hr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create existing directory */
|
|
|
|
GetCurrentDirectoryW(sizeof(pathW)/sizeof(WCHAR), pathW);
|
|
|
|
path = SysAllocString(pathW);
|
|
|
|
folder = (void*)0xdeabeef;
|
|
|
|
hr = IFileSystem3_CreateFolder(fs3, path, &folder);
|
|
|
|
ok(hr == CTL_E_FILEALREADYEXISTS, "got 0x%08x\n", hr);
|
|
|
|
ok(folder == NULL, "got %p\n", folder);
|
|
|
|
SysFreeString(path);
|
|
|
|
|
|
|
|
IFileSystem3_Release(fs3);
|
|
|
|
}
|
|
|
|
|
2012-03-22 06:24:24 +01:00
|
|
|
START_TEST(filesystem)
|
|
|
|
{
|
|
|
|
CoInitialize(NULL);
|
|
|
|
|
|
|
|
test_interfaces();
|
2012-11-04 22:59:00 +01:00
|
|
|
test_createfolder();
|
2012-03-22 06:24:24 +01:00
|
|
|
|
|
|
|
CoUninitialize();
|
|
|
|
}
|