<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.14.1">
</HEAD>
<BODY>
<PRE>
---
<!--+GtkHTML:<DATA class="ClueFlow" key="orig" value="0">--> dlls/shell32/tests/Makefile.in&nbsp; |&nbsp;&nbsp;&nbsp; 1 +
 dlls/shell32/tests/shpathprep.c |&nbsp; 147 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 148 insertions(+), 0 deletions(-)
 create mode 100644 dlls/shell32/tests/shpathprep.c

diff --git a/dlls/shell32/tests/Makefile.in b/dlls/shell32/tests/Makefile.in
index f66b34d..335940e 100644
--- a/dlls/shell32/tests/Makefile.in
+++ b/dlls/shell32/tests/Makefile.in
@@ -13,6 +13,7 @@ CTESTS = \
         shlexec.c \
         shlfileop.c \
         shlfolder.c \
+        shpathprep.c \
         string.c \
         systray.c
 
diff --git a/dlls/shell32/tests/shpathprep.c b/dlls/shell32/tests/shpathprep.c
new file mode 100644
index 0000000..4e018b0
--- /dev/null
+++ b/dlls/shell32/tests/shpathprep.c
@@ -0,0 +1,147 @@
+/*
+ * Unit test of the SHPathPrepareForWrite functions.
+ *
+ * Copyright 2007 Vincent Povirk
+ *
+ * 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.&nbsp; 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
+ */
+
+#include &lt;wine/test.h&gt;
+#include &lt;winbase.h&gt;
+
+#include &quot;shlobj.h&quot;
+
+/* creates a file with the specified name for tests */
+static void CreateTestFile(const CHAR *name)
+{
+&nbsp;&nbsp;&nbsp; HANDLE file;
+&nbsp;&nbsp;&nbsp; DWORD written;
+
+&nbsp;&nbsp;&nbsp; file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
+&nbsp;&nbsp;&nbsp; if (file != INVALID_HANDLE_VALUE)
+&nbsp;&nbsp;&nbsp; {
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WriteFile(file, name, strlen(name), &amp;written, NULL);
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WriteFile(file, &quot;\n&quot;, strlen(&quot;\n&quot;), &amp;written, NULL);
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CloseHandle(file);
+&nbsp;&nbsp;&nbsp; }
+}
+
+
+/* initializes the tests */
+static void CreateFilesFolders(void)
+{
+&nbsp;&nbsp;&nbsp; CreateDirectoryA(&quot;c:\\testdir&quot;, NULL);
+&nbsp;&nbsp;&nbsp; CreateTestFile&nbsp; (&quot;c:\\testdir\\test1.txt &quot;);
+&nbsp;&nbsp;&nbsp; CreateDirectoryA(&quot;.\\testdir&quot;, NULL);
+}
+
+/* cleans after tests */
+static void Cleanup(void)
+{
+&nbsp;&nbsp;&nbsp; DeleteFileA(&quot;c:\\testdir\\test1.txt&quot;);
+&nbsp;&nbsp;&nbsp; RemoveDirectoryA(&quot;c:\\testdir\\createdir\\subdir\\somefile&quot;);
+&nbsp;&nbsp;&nbsp; RemoveDirectoryA(&quot;c:\\testdir\\createdir\\subdir&quot;);
+&nbsp;&nbsp;&nbsp; RemoveDirectoryA(&quot;c:\\testdir\\createdir&quot;);
+&nbsp;&nbsp;&nbsp; RemoveDirectoryA(&quot;c:\\testdir\\createdir2\\subdir&quot;);
+&nbsp;&nbsp;&nbsp; RemoveDirectoryA(&quot;c:\\testdir\\createdir2&quot;);
+&nbsp;&nbsp;&nbsp; RemoveDirectoryA(&quot;c:\\testdir\\nonexistent\\somefile&quot;);
+&nbsp;&nbsp;&nbsp; RemoveDirectoryA(&quot;c:\\testdir\\nonexistent&quot;);
+&nbsp;&nbsp;&nbsp; RemoveDirectoryA(&quot;c:\\testdir&quot;);
+&nbsp;&nbsp;&nbsp; RemoveDirectoryA(&quot;.\\testdir\\nonexistent&quot;);
+&nbsp;&nbsp;&nbsp; RemoveDirectoryA(&quot;.\\testdir&quot;);
+}
+
+/* checks if a path exists */
+static int Exists(const CHAR *name)
+{
+&nbsp;&nbsp;&nbsp; DWORD res;
+&nbsp;&nbsp;&nbsp; res = GetFileAttributesA(name);
+&nbsp;&nbsp;&nbsp; return (res != INVALID_FILE_ATTRIBUTES) &amp;&amp; (res &amp; FILE_ATTRIBUTE_DIRECTORY);
+}
+
+START_TEST(shpathprep)
+{
+&nbsp;&nbsp;&nbsp; HRESULT res;
+&nbsp;&nbsp;&nbsp; int ex;
+
+&nbsp;&nbsp;&nbsp; CreateFilesFolders();
+
+&nbsp;&nbsp;&nbsp; res = SHPathPrepareForWriteA(0, 0, &quot;c:\\testdir&quot;, SHPPFW_NONE);
+&nbsp;&nbsp;&nbsp; ok(res == S_OK, &quot;res == 0x%08x\n&quot;, res);
+
+&nbsp;&nbsp;&nbsp; res = SHPathPrepareForWriteA(0, 0, &quot;c:\\testdir\\nonexistent&quot;, SHPPFW_NONE);
+&nbsp;&nbsp;&nbsp; todo_wine ok(res == 0x80070003, &quot;res == 0x%08x\n&quot;, res);
+
+&nbsp;&nbsp;&nbsp; res = SHPathPrepareForWriteA(0, 0, &quot;c:\\testdir\\test1.txt&quot;, SHPPFW_NONE);
+&nbsp;&nbsp;&nbsp; todo_wine ok(res == 0x8007010b, &quot;res == 0x%08x\n&quot;, res);
+
+&nbsp;&nbsp;&nbsp; res = SHPathPrepareForWriteA(0, 0, &quot;c:\\testdir\\test1.txt&quot;, SHPPFW_DIRCREATE);
+&nbsp;&nbsp;&nbsp; todo_wine ok(res == 0x8007010b, &quot;res == 0x%08x\n&quot;, res);
+
+&nbsp;&nbsp;&nbsp; res = SHPathPrepareForWriteA(0, 0, &quot;c:\\testdir\\test1.txt\\&quot;, SHPPFW_NONE);
+&nbsp;&nbsp;&nbsp; todo_wine ok(res == 0x8007010b, &quot;res == 0x%08x\n&quot;, res);
+
+&nbsp;&nbsp;&nbsp; res = SHPathPrepareForWriteA(0, 0, &quot;c:\\testdir\\nonexistent&quot;, SHPPFW_IGNOREFILENAME);
+&nbsp;&nbsp;&nbsp; ok(res == S_OK, &quot;res == 0x%08x\n&quot;, res);
+
+&nbsp;&nbsp;&nbsp; res = SHPathPrepareForWriteA(0, 0, &quot;c:\\testdir\\nonexistent\\&quot;, SHPPFW_IGNOREFILENAME);
+&nbsp;&nbsp;&nbsp; todo_wine ok(res == 0x80070003, &quot;res == 0x%08x\n&quot;, res);
+&nbsp;&nbsp;&nbsp; ex = Exists(&quot;c:\\testdir\\nonexistent\\&quot;);
+&nbsp;&nbsp;&nbsp; ok(!ex, &quot;c:\\testdir\\nonexistent\\ exists but shouldn't\n&quot;);
+
+&nbsp;&nbsp;&nbsp; res = SHPathPrepareForWriteA(0, 0, &quot;c:\\testdir\\nonexistent\\somefile&quot;, SHPPFW_IGNOREFILENAME);
+&nbsp;&nbsp;&nbsp; todo_wine ok(res == 0x80070003, &quot;res == 0x%08x\n&quot;, res);
+&nbsp;&nbsp;&nbsp; ex = Exists(&quot;c:\\testdir\\nonexistent\\&quot;);
+&nbsp;&nbsp;&nbsp; ok(!ex, &quot;c:\\testdir\\nonexistent\\ exists but shouldn't\n&quot;);
+
+&nbsp;&nbsp;&nbsp; res = SHPathPrepareForWriteA(0, 0, &quot;c:\\testdir&quot;, SHPPFW_DIRCREATE);
+&nbsp;&nbsp;&nbsp; ok(res == S_OK, &quot;res == 0x%08x\n&quot;, res);
+
+&nbsp;&nbsp;&nbsp; res = SHPathPrepareForWriteA(0, 0, &quot;c:\\testdir\\nonexistent&quot;, SHPPFW_IGNOREFILENAME|SHPPFW_DIRCREATE);
+&nbsp;&nbsp;&nbsp; ok(res == S_OK, &quot;res == 0x%08x\n&quot;, res);
+&nbsp;&nbsp;&nbsp; ex = Exists(&quot;c:\\testdir\\nonexistent\\&quot;);
+&nbsp;&nbsp;&nbsp; ok(!ex, &quot;c:\\testdir\\nonexistent\\ exists but shouldn't\n&quot;);
+
+&nbsp;&nbsp;&nbsp; /* using a relative path on Windows tests for access but does not create the directory */
+&nbsp;&nbsp;&nbsp; res = SHPathPrepareForWriteA(0, 0, &quot;.\\testdir&quot;, SHPPFW_DIRCREATE);
+&nbsp;&nbsp;&nbsp; ok(res == S_OK, &quot;res == 0x%08x\n&quot;, res);
+
+&nbsp;&nbsp;&nbsp; res = SHPathPrepareForWriteA(0, 0, &quot;.\\testdir\\nonexistent&quot;, SHPPFW_DIRCREATE);
+&nbsp;&nbsp;&nbsp; todo_wine ok(res == 0x80070003, &quot;res == 0x%08x\n&quot;, res);
+&nbsp;&nbsp;&nbsp; ex = Exists(&quot;.\\testdir\\nonexistent\\&quot;);
+&nbsp;&nbsp;&nbsp; ok(!ex, &quot;.\\testdir\\nonexistent\\ exists but shouldn't\n&quot;);
+
+&nbsp;&nbsp;&nbsp; res = SHPathPrepareForWriteA(0, 0, &quot;c:\\testdir\\createdir&quot;, SHPPFW_DIRCREATE);
+&nbsp;&nbsp;&nbsp; ok(res == S_OK, &quot;res == 0x%08x\n&quot;, res);
+&nbsp;&nbsp;&nbsp; ex = Exists(&quot;c:\\testdir\\createdir\\&quot;);
+&nbsp;&nbsp;&nbsp; todo_wine ok(ex, &quot;c:\\testdir\\createdir\\ doesn't exist but should\n&quot;);
+
+&nbsp;&nbsp;&nbsp; res = SHPathPrepareForWriteA(0, 0, &quot;c:\\testdir\\createdir\\subdir\\somefile&quot;, SHPPFW_IGNOREFILENAME|SHPPFW_DIRCREATE);
+&nbsp;&nbsp;&nbsp; ok(res == S_OK, &quot;res == 0x%08x\n&quot;, res);
+&nbsp;&nbsp;&nbsp; ex = Exists(&quot;c:\\testdir\\createdir\\subdir&quot;);
+&nbsp;&nbsp;&nbsp; todo_wine ok(ex, &quot;c:\\testdir\\createdir\\subdir doesn't exist but should\n&quot;);
+&nbsp;&nbsp;&nbsp; ex = Exists(&quot;c:\\testdir\\createdir\\subdir\\somefile&quot;);
+&nbsp;&nbsp;&nbsp; ok(!ex, &quot;c:\\testdir\\createdir\\subdir\\somefile exists but shouldn't\n&quot;);
+
+&nbsp;&nbsp;&nbsp; res = SHPathPrepareForWriteA(0, 0, &quot;c:\\testdir\\createdir2\\subdir\\&quot;, SHPPFW_IGNOREFILENAME|SHPPFW_DIRCREATE);
+&nbsp;&nbsp;&nbsp; ok(res == S_OK, &quot;res == 0x%08x\n&quot;, res);
+&nbsp;&nbsp;&nbsp; ex = Exists(&quot;c:\\testdir\\createdir2\\subdir&quot;);
+&nbsp;&nbsp;&nbsp; todo_wine ok(ex, &quot;c:\\testdir\\createdir2\\subdir doesn't exist but should\n&quot;);
+
+&nbsp;&nbsp;&nbsp; /* SHPPFW_ASKDIRCREATE, SHPPFW_NOWRITECHECK, and SHPPFW_MEDIACHECKONLY are untested */
+
+&nbsp;&nbsp;&nbsp; Cleanup();
+}
+
-- 
1.5.2.5

</PRE>
</BODY>
</HTML>