1 /* 2 * PROJECT: ReactOS api tests 3 * LICENSE: GPL - See COPYING in the top level directory 4 * PURPOSE: Test for _splitpath 5 * PROGRAMMER: Timo Kreuzer 6 */ 7 8 #include <apitest.h> 9 10 #include <stdio.h> 11 #include <stdlib.h> 12 #include <strings.h> 13 #include <stdarg.h> 14 15 START_TEST(splitpath) 16 { 17 char drive[5]; 18 char dir[64]; 19 char fname[32]; 20 char ext[10]; 21 DWORD Major; 22 23 Major = (DWORD)(LOBYTE(LOWORD(GetVersion()))); 24 25 drive[2] = 0xFF; 26 _splitpath("c:\\dir1\\dir2\\file.ext", drive, dir, fname, ext); 27 ok_str(drive, "c:"); 28 ok_str(dir, "\\dir1\\dir2\\"); 29 ok_str(fname, "file"); 30 ok_str(ext, ".ext"); 31 ok_int(drive[2], 0); 32 33 *_errno() = 0; 34 _splitpath("c:\\dir1\\dir2\\file.ext", 0, 0, 0, 0); 35 ok_int(*_errno(), 0); 36 37 if (Major >= 6) 38 { 39 *_errno() = 0; 40 _splitpath(0, drive, dir, fname, ext); 41 ok_int(*_errno(), EINVAL); 42 ok_str(drive, ""); 43 ok_str(dir, ""); 44 ok_str(fname, ""); 45 ok_str(ext, ""); 46 } 47 else 48 { 49 win_skip("This test only succeed on NT6+\n"); 50 } 51 52 _splitpath("\\\\?\\c:\\dir1\\dir2\\file.ext", drive, dir, fname, ext); 53 if (Major >= 6) 54 { 55 ok_str(drive, "c:"); 56 ok_str(dir, "\\dir1\\dir2\\"); 57 } 58 else 59 { 60 ok_str(drive, ""); 61 ok_str(dir, "\\\\?\\c:\\dir1\\dir2\\"); 62 } 63 ok_str(fname, "file"); 64 ok_str(ext, ".ext"); 65 66 _splitpath("ab:\\dir1\\..\\file", drive, dir, fname, ext); 67 ok_str(drive, ""); 68 ok_str(dir, "ab:\\dir1\\..\\"); 69 ok_str(fname, "file"); 70 ok_str(ext, ""); 71 72 _splitpath("//?/c:/dir1/dir2/file.ext", drive, dir, fname, ext); 73 ok_str(drive, ""); 74 ok_str(dir, "//?/c:/dir1/dir2/"); 75 ok_str(fname, "file"); 76 ok_str(ext, ".ext"); 77 78 _splitpath("\\\\?\\0:/dir1\\dir2/file.", drive, dir, fname, ext); 79 if (Major >= 6) 80 { 81 ok_str(drive, "0:"); 82 ok_str(dir, "/dir1\\dir2/"); 83 } 84 else 85 { 86 ok_str(drive, ""); 87 ok_str(dir, "\\\\?\\0:/dir1\\dir2/"); 88 } 89 ok_str(fname, "file"); 90 ok_str(ext, "."); 91 92 _splitpath("\\\\.\\c:\\dir1\\dir2\\.ext.ext2", drive, dir, fname, ext); 93 ok_str(drive, ""); 94 ok_str(dir, "\\\\.\\c:\\dir1\\dir2\\"); 95 ok_str(fname, ".ext"); 96 ok_str(ext, ".ext2"); 97 98 _splitpath("\\??\\c:\\dir1\\dir2\\file. ~ ", drive, dir, fname, ext); 99 ok_str(drive, ""); 100 ok_str(dir, "\\??\\c:\\dir1\\dir2\\"); 101 ok_str(fname, "file"); 102 ok_str(ext, ". ~ "); 103 104 _splitpath("x: dir1\\/dir2 \\.blub", drive, dir, fname, ext); 105 ok_str(drive, "x:"); 106 ok_str(dir, " dir1\\/dir2 \\"); 107 ok_str(fname, ""); 108 ok_str(ext, ".blub"); 109 110 _splitpath("/:\\dir1\\dir2\\file.ext", drive, dir, fname, ext); 111 ok_str(drive, "/:"); 112 ok_str(dir, "\\dir1\\dir2\\"); 113 ok_str(fname, "file"); 114 ok_str(ext, ".ext"); 115 116 } 117 118