Test .. in path name for various file functions
Mike McCormack
mike at codeweavers.com
Tue Jan 27 19:30:44 CST 2004
This doesn't pass in Wine yet, but it works on Win2000.
Mike
ChangeLog:
* Test .. in path name for various file functions
-------------- next part --------------
Index: dlls/kernel/tests/file.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/tests/file.c,v
retrieving revision 1.29
diff -u -r1.29 file.c
--- dlls/kernel/tests/file.c 27 Jan 2004 20:13:03 -0000 1.29
+++ dlls/kernel/tests/file.c 28 Jan 2004 00:26:50 -0000
@@ -979,6 +979,60 @@
ok( DeleteFileA( filename ), "DeleteFile failed after map\n" );
}
+static void test_Dots()
+{
+ DWORD r;
+ HANDLE hFile;
+
+ //GetCurrentDirectory( sizeof buffer, buffer);
+ DeleteFile("a.exe");
+
+ hFile = CreateFile("a.exe", GENERIC_READ|GENERIC_WRITE, 0, NULL,
+ CREATE_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, 0);
+ ok( hFile != INVALID_HANDLE_VALUE, "Failed to create file");
+ ok( CloseHandle( hFile ), "CloseHandle failed");
+
+ r = GetFileAttributes("some_non_dir\\..\\a.exe");
+ ok(r == FILE_ATTRIBUTE_ARCHIVE, "GetFileAttributes failed");
+
+ // try query a file
+ hFile = CreateFile("blah\\..\\a.exe", GENERIC_READ,
+ FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
+
+ ok( hFile != INVALID_HANDLE_VALUE, "RO open failed");
+ ok(CloseHandle(hFile), "couldn't close\n");
+
+ ok( DeleteFile("bogus_dir\\..\\a.exe"), "failed to delete file");
+
+ // make sure we're at least one directory up
+ // then create a file in our directory
+ ok( CreateDirectory("abcdef\\..\\testdir1",NULL), "createdir failed");
+ //ok( CreateDirectory("testdir1",NULL), "createdir failed");
+
+ // now change into that directory
+ ok( SetCurrentDirectory("abcdef\\..\\testdir1"), "set cwd failed");
+
+ // create a file in it
+ hFile = CreateFile("..\\testdir1\\xyz.txt",
+ GENERIC_READ |GENERIC_WRITE,
+ 0, NULL, CREATE_ALWAYS, 0, NULL);
+ ok( hFile != INVALID_HANDLE_VALUE, "couldn't create xyz.txt");
+ ok(CloseHandle(hFile), "couldn't close\n");
+
+ // go down one directory
+ ok( SetCurrentDirectory("blah\\..\\.."), "set cwd failed");
+
+ // try delete the directory
+ // should fail... there's a file in there
+ ok( !RemoveDirectory("abcdef\\..\\testdir1"),"remove worked");
+
+ // delete the file
+ ok( DeleteFile("blah123\\..\\boohoo\\..\\testdir1\\xyz.txt"), "del failed");
+
+ // now it's empty, the delete should work properly
+ ok( RemoveDirectory("abcdef\\..\\testdir1"),"remove failed");
+}
+
START_TEST(file)
{
test__hread( );
@@ -1003,4 +1057,5 @@
test_LockFile();
test_offset_in_overlapped_structure();
test_MapFile();
+ test_Dots();
}
More information about the wine-patches
mailing list