Module: wine Branch: master Commit: dd26d1f9811c9c9c4c81801718a80caf77cf075f URL: http://source.winehq.org/git/wine.git/?a=commit;h=dd26d1f9811c9c9c4c81801718...
Author: Jacek Caban jacek@codeweavers.com Date: Fri Jun 12 15:46:36 2015 +0200
scrrun: Added IFile::put_Attributes imeplementation.
---
dlls/scrrun/filesystem.c | 6 ++++-- dlls/scrrun/tests/filesystem.c | 28 ++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c index 8b771c7..d490d93 100644 --- a/dlls/scrrun/filesystem.c +++ b/dlls/scrrun/filesystem.c @@ -2645,8 +2645,10 @@ static HRESULT WINAPI file_get_Attributes(IFile *iface, FileAttribute *pfa) static HRESULT WINAPI file_put_Attributes(IFile *iface, FileAttribute pfa) { struct file *This = impl_from_IFile(iface); - FIXME("(%p)->(%x)\n", This, pfa); - return E_NOTIMPL; + + TRACE("(%p)->(%x)\n", This, pfa); + + return SetFileAttributesW(This->path, pfa) ? S_OK : create_error(GetLastError()); }
static HRESULT WINAPI file_get_DateCreated(IFile *iface, DATE *pdate) diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c index db7c338..b22e006 100644 --- a/dlls/scrrun/tests/filesystem.c +++ b/dlls/scrrun/tests/filesystem.c @@ -542,7 +542,7 @@ static void test_GetFile(void) WCHAR pathW[MAX_PATH]; FileAttribute fa; VARIANT size; - DWORD gfa; + DWORD gfa, new_gfa; IFile *file; HRESULT hr; HANDLE hf; @@ -580,10 +580,30 @@ static void test_GetFile(void) ok(!lstrcmpW(str, pathW), "got %s\n", wine_dbgstr_w(str)); SysFreeString(str);
+#define FILE_ATTR_MASK (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | \ + FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_ARCHIVE | \ + FILE_ATTRIBUTE_REPARSE_POINT | FILE_ATTRIBUTE_COMPRESSED) + + hr = IFile_get_Attributes(file, &fa); + gfa = GetFileAttributesW(pathW) & FILE_ATTR_MASK; + ok(hr == S_OK, "get_Attributes returned %x, expected S_OK\n", hr); + ok(fa == gfa, "fa = %x, expected %x\n", fa, gfa); + + hr = IFile_put_Attributes(file, gfa | FILE_ATTRIBUTE_READONLY); + ok(hr == S_OK, "put_Attributes failed: %08x\n", hr); + new_gfa = GetFileAttributesW(pathW) & FILE_ATTR_MASK; + ok(new_gfa == (gfa|FILE_ATTRIBUTE_READONLY), "new_gfa = %x, expected %x\n", new_gfa, gfa|FILE_ATTRIBUTE_READONLY); + + hr = IFile_get_Attributes(file, &fa); + ok(hr == S_OK, "get_Attributes returned %x, expected S_OK\n", hr); + ok(fa == new_gfa, "fa = %x, expected %x\n", fa, new_gfa); + + hr = IFile_put_Attributes(file, gfa); + ok(hr == S_OK, "put_Attributes failed: %08x\n", hr); + new_gfa = GetFileAttributesW(pathW) & FILE_ATTR_MASK; + ok(new_gfa == gfa, "new_gfa = %x, expected %x\n", new_gfa, gfa); + hr = IFile_get_Attributes(file, &fa); - gfa = GetFileAttributesW(pathW) & (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | - FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_ARCHIVE | - FILE_ATTRIBUTE_REPARSE_POINT | FILE_ATTRIBUTE_COMPRESSED); ok(hr == S_OK, "get_Attributes returned %x, expected S_OK\n", hr); ok(fa == gfa, "fa = %x, expected %x\n", fa, gfa);