Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 1 | /* |
| 2 | * DOS directories functions |
| 3 | * |
| 4 | * Copyright 1995 Alexandre Julliard |
| 5 | */ |
| 6 | |
Patrik Stridvall | 9633632 | 1999-10-24 22:13:47 +0000 | [diff] [blame] | 7 | #include "config.h" |
| 8 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 9 | #include <ctype.h> |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 10 | #include <stdlib.h> |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 11 | #include <stdio.h> |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 12 | #include <string.h> |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 13 | #include <sys/types.h> |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 14 | #include <sys/stat.h> |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 15 | #include <unistd.h> |
Alexandre Julliard | 139a4b1 | 1996-11-02 14:24:07 +0000 | [diff] [blame] | 16 | #include <errno.h> |
Howard Abrams | 1327748 | 1999-07-10 13:16:29 +0000 | [diff] [blame] | 17 | #ifdef HAVE_SYS_ERRNO_H |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 18 | #include <sys/errno.h> |
Howard Abrams | 1327748 | 1999-07-10 13:16:29 +0000 | [diff] [blame] | 19 | #endif |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 20 | |
Marcus Meissner | 04c3e1d | 1999-02-19 10:37:02 +0000 | [diff] [blame] | 21 | #include "winbase.h" |
| 22 | #include "wine/winbase16.h" |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 23 | #include "windef.h" |
| 24 | #include "wingdi.h" |
Patrik Stridvall | 1ed4ecf | 1999-06-26 14:58:24 +0000 | [diff] [blame] | 25 | #include "wine/winuser16.h" |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 26 | #include "winerror.h" |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 27 | #include "drive.h" |
| 28 | #include "file.h" |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 29 | #include "heap.h" |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 30 | #include "msdos.h" |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 31 | #include "options.h" |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 32 | #include "debugtools.h" |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 33 | |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 34 | DEFAULT_DEBUG_CHANNEL(dosfs); |
| 35 | DECLARE_DEBUG_CHANNEL(file); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 36 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 37 | static DOS_FULL_NAME DIR_Windows; |
| 38 | static DOS_FULL_NAME DIR_System; |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 39 | |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 40 | |
| 41 | /*********************************************************************** |
| 42 | * DIR_GetPath |
| 43 | * |
| 44 | * Get a path name from the wine.ini file and make sure it is valid. |
| 45 | */ |
| 46 | static int DIR_GetPath( const char *keyname, const char *defval, |
Gerard Patel | d52e1c4 | 2001-02-16 19:05:42 +0000 | [diff] [blame] | 47 | DOS_FULL_NAME *full_name, BOOL warn ) |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 48 | { |
| 49 | char path[MAX_PATHNAME_LEN]; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 50 | BY_HANDLE_FILE_INFORMATION info; |
Lawson Whitney | 0348212 | 2000-12-14 20:30:13 +0000 | [diff] [blame] | 51 | const char *mess = "does not exist"; |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 52 | |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 53 | PROFILE_GetWineIniString( "wine", keyname, defval, path, sizeof(path) ); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 54 | if (!DOSFS_GetFullName( path, TRUE, full_name ) || |
Lawson Whitney | 0348212 | 2000-12-14 20:30:13 +0000 | [diff] [blame] | 55 | (!FILE_Stat( full_name->long_name, &info ) && (mess=strerror(errno)))|| |
| 56 | (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (mess="not a directory"))) |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 57 | { |
Gerard Patel | d52e1c4 | 2001-02-16 19:05:42 +0000 | [diff] [blame] | 58 | if (warn) |
| 59 | MESSAGE("Invalid path '%s' for %s directory: %s\n", path, keyname, mess); |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 60 | return 0; |
| 61 | } |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 62 | return 1; |
| 63 | } |
| 64 | |
| 65 | |
| 66 | /*********************************************************************** |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 67 | * DIR_Init |
| 68 | */ |
| 69 | int DIR_Init(void) |
| 70 | { |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 71 | char path[MAX_PATHNAME_LEN]; |
Juergen Schmied | 8573cc7 | 2000-01-30 03:03:23 +0000 | [diff] [blame] | 72 | DOS_FULL_NAME tmp_dir, profile_dir; |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 73 | int drive; |
| 74 | const char *cwd; |
| 75 | |
| 76 | if (!getcwd( path, MAX_PATHNAME_LEN )) |
| 77 | { |
| 78 | perror( "Could not get current directory" ); |
| 79 | return 0; |
| 80 | } |
| 81 | cwd = path; |
| 82 | if ((drive = DRIVE_FindDriveRoot( &cwd )) == -1) |
| 83 | { |
Chris Morgan | e405550 | 2001-01-12 19:55:19 +0000 | [diff] [blame] | 84 | MESSAGE("Warning: could not find wine config [Drive x] entry " |
Andreas Mohr | df8cdfd | 1999-02-28 16:56:48 +0000 | [diff] [blame] | 85 | "for current working directory %s; " |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 86 | "starting in windows directory.\n", cwd ); |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 87 | } |
| 88 | else |
| 89 | { |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 90 | DRIVE_SetCurrentDrive( drive ); |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 91 | DRIVE_Chdir( drive, cwd ); |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 92 | } |
| 93 | |
Gerard Patel | d52e1c4 | 2001-02-16 19:05:42 +0000 | [diff] [blame] | 94 | if (!(DIR_GetPath( "windows", "c:\\windows", &DIR_Windows, TRUE )) || |
| 95 | !(DIR_GetPath( "system", "c:\\windows\\system", &DIR_System, TRUE )) || |
| 96 | !(DIR_GetPath( "temp", "c:\\windows", &tmp_dir, TRUE ))) |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 97 | { |
| 98 | PROFILE_UsageWineIni(); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 99 | return 0; |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 100 | } |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 101 | if (-1 == access( tmp_dir.long_name, W_OK )) |
| 102 | { |
Alexandre Julliard | 8bbf818 | 1996-09-13 16:50:47 +0000 | [diff] [blame] | 103 | if (errno==EACCES) |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 104 | { |
Andreas Mohr | a6d83eb | 2000-12-27 04:02:46 +0000 | [diff] [blame] | 105 | MESSAGE("Warning: the temporary directory '%s' (specified in wine configuration file) is not writeable.\n", tmp_dir.long_name); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 106 | PROFILE_UsageWineIni(); |
| 107 | } |
Alexandre Julliard | 8bbf818 | 1996-09-13 16:50:47 +0000 | [diff] [blame] | 108 | else |
Andreas Mohr | a6d83eb | 2000-12-27 04:02:46 +0000 | [diff] [blame] | 109 | MESSAGE("Warning: access to temporary directory '%s' failed (%s).\n", |
| 110 | tmp_dir.long_name, strerror(errno)); |
Alexandre Julliard | 8bbf818 | 1996-09-13 16:50:47 +0000 | [diff] [blame] | 111 | } |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 112 | |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 113 | if (drive == -1) |
| 114 | { |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 115 | drive = DIR_Windows.drive; |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 116 | DRIVE_SetCurrentDrive( drive ); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 117 | DRIVE_Chdir( drive, DIR_Windows.short_name + 2 ); |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 118 | } |
| 119 | |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 120 | PROFILE_GetWineIniString("wine", "path", "c:\\windows;c:\\windows\\system", |
| 121 | path, sizeof(path) ); |
Andreas Mohr | 0b16006 | 2000-01-26 02:04:09 +0000 | [diff] [blame] | 122 | if (strchr(path, '/')) |
| 123 | { |
Chris Morgan | e405550 | 2001-01-12 19:55:19 +0000 | [diff] [blame] | 124 | MESSAGE("No '/' allowed in [wine] 'Path=' statement of wine config!\n"); |
Andreas Mohr | 0b16006 | 2000-01-26 02:04:09 +0000 | [diff] [blame] | 125 | PROFILE_UsageWineIni(); |
| 126 | ExitProcess(1); |
| 127 | } |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 128 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 129 | /* Set the environment variables */ |
| 130 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 131 | SetEnvironmentVariableA( "PATH", path ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 132 | SetEnvironmentVariableA( "TEMP", tmp_dir.short_name ); |
Dmitry Timoshkov | b6ac770 | 2000-12-24 20:01:12 +0000 | [diff] [blame] | 133 | SetEnvironmentVariableA( "TMP", tmp_dir.short_name ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 134 | SetEnvironmentVariableA( "windir", DIR_Windows.short_name ); |
| 135 | SetEnvironmentVariableA( "winsysdir", DIR_System.short_name ); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 136 | |
Alexandre Julliard | 2e9f786 | 2000-08-01 23:34:01 +0000 | [diff] [blame] | 137 | /* set COMSPEC only if it doesn't exist already */ |
| 138 | if (!GetEnvironmentVariableA( "COMSPEC", NULL, 0 )) |
| 139 | SetEnvironmentVariableA( "COMSPEC", "c:\\command.com" ); |
| 140 | |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 141 | TRACE("WindowsDir = %s (%s)\n", |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 142 | DIR_Windows.short_name, DIR_Windows.long_name ); |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 143 | TRACE("SystemDir = %s (%s)\n", |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 144 | DIR_System.short_name, DIR_System.long_name ); |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 145 | TRACE("TempDir = %s (%s)\n", |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 146 | tmp_dir.short_name, tmp_dir.long_name ); |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 147 | TRACE("Path = %s\n", path ); |
| 148 | TRACE("Cwd = %c:\\%s\n", |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 149 | 'A' + drive, DRIVE_GetDosCwd( drive ) ); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 150 | |
Gerard Patel | d52e1c4 | 2001-02-16 19:05:42 +0000 | [diff] [blame] | 151 | if (DIR_GetPath( "profile", "", &profile_dir, FALSE )) |
Juergen Schmied | 8573cc7 | 2000-01-30 03:03:23 +0000 | [diff] [blame] | 152 | { |
| 153 | TRACE("USERPROFILE= %s\n", profile_dir.short_name ); |
| 154 | SetEnvironmentVariableA( "USERPROFILE", profile_dir.short_name ); |
| 155 | } |
| 156 | |
| 157 | TRACE("SYSTEMROOT = %s\n", DIR_Windows.short_name ); |
| 158 | SetEnvironmentVariableA( "SYSTEMROOT", DIR_Windows.short_name ); |
| 159 | |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 160 | return 1; |
| 161 | } |
| 162 | |
| 163 | |
| 164 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 165 | * GetTempPathA (KERNEL32.292) |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 166 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 167 | UINT WINAPI GetTempPathA( UINT count, LPSTR path ) |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 168 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 169 | UINT ret; |
| 170 | if (!(ret = GetEnvironmentVariableA( "TMP", path, count ))) |
| 171 | if (!(ret = GetEnvironmentVariableA( "TEMP", path, count ))) |
| 172 | if (!(ret = GetCurrentDirectoryA( count, path ))) |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 173 | return 0; |
Huw D M Davies | a03f064 | 1998-12-15 18:04:58 +0000 | [diff] [blame] | 174 | if (count && (ret < count - 1) && (path[ret-1] != '\\')) |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 175 | { |
| 176 | path[ret++] = '\\'; |
| 177 | path[ret] = '\0'; |
| 178 | } |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 179 | return ret; |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | |
| 183 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 184 | * GetTempPathW (KERNEL32.293) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 185 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 186 | UINT WINAPI GetTempPathW( UINT count, LPWSTR path ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 187 | { |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 188 | static const WCHAR tmp[] = { 'T', 'M', 'P', 0 }; |
| 189 | static const WCHAR temp[] = { 'T', 'E', 'M', 'P', 0 }; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 190 | UINT ret; |
| 191 | if (!(ret = GetEnvironmentVariableW( tmp, path, count ))) |
| 192 | if (!(ret = GetEnvironmentVariableW( temp, path, count ))) |
| 193 | if (!(ret = GetCurrentDirectoryW( count, path ))) |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 194 | return 0; |
Huw D M Davies | a03f064 | 1998-12-15 18:04:58 +0000 | [diff] [blame] | 195 | if (count && (ret < count - 1) && (path[ret-1] != '\\')) |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 196 | { |
| 197 | path[ret++] = '\\'; |
| 198 | path[ret] = '\0'; |
| 199 | } |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 200 | return ret; |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | |
| 204 | /*********************************************************************** |
| 205 | * DIR_GetWindowsUnixDir |
| 206 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 207 | UINT DIR_GetWindowsUnixDir( LPSTR path, UINT count ) |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 208 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 209 | if (path) lstrcpynA( path, DIR_Windows.long_name, count ); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 210 | return strlen( DIR_Windows.long_name ); |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | |
| 214 | /*********************************************************************** |
| 215 | * DIR_GetSystemUnixDir |
| 216 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 217 | UINT DIR_GetSystemUnixDir( LPSTR path, UINT count ) |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 218 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 219 | if (path) lstrcpynA( path, DIR_System.long_name, count ); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 220 | return strlen( DIR_System.long_name ); |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | |
| 224 | /*********************************************************************** |
| 225 | * GetTempDrive (KERNEL.92) |
Alexandre Julliard | ac7efef | 2000-11-27 21:54:01 +0000 | [diff] [blame] | 226 | * A closer look at krnl386.exe shows what the SDK doesn't mention: |
| 227 | * |
| 228 | * returns: |
| 229 | * AL: driveletter |
| 230 | * AH: ':' - yes, some kernel code even does stosw with |
| 231 | * the returned AX. |
| 232 | * DX: 1 for success |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 233 | */ |
Alexandre Julliard | ac7efef | 2000-11-27 21:54:01 +0000 | [diff] [blame] | 234 | UINT WINAPI GetTempDrive( BYTE ignored ) |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 235 | { |
Uwe Bonnes | 3dbc788 | 1999-02-14 17:32:46 +0000 | [diff] [blame] | 236 | char *buffer; |
| 237 | BYTE ret; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 238 | UINT len = GetTempPathA( 0, NULL ); |
Uwe Bonnes | 3dbc788 | 1999-02-14 17:32:46 +0000 | [diff] [blame] | 239 | |
| 240 | if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len + 1 )) ) |
Alexandre Julliard | ac7efef | 2000-11-27 21:54:01 +0000 | [diff] [blame] | 241 | ret = DRIVE_GetCurrentDrive() + 'A'; |
| 242 | else |
| 243 | { |
| 244 | /* FIXME: apparently Windows does something with the ignored byte */ |
| 245 | if (!GetTempPathA( len, buffer )) buffer[0] = 'C'; |
| 246 | ret = toupper(buffer[0]); |
| 247 | HeapFree( GetProcessHeap(), 0, buffer ); |
| 248 | } |
| 249 | return MAKELONG( ret | (':' << 8), 1 ); |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 250 | } |
| 251 | |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 252 | |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 253 | /*********************************************************************** |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 254 | * GetWindowsDirectory16 (KERNEL.134) |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 255 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 256 | UINT16 WINAPI GetWindowsDirectory16( LPSTR path, UINT16 count ) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 257 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 258 | return (UINT16)GetWindowsDirectoryA( path, count ); |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | |
| 262 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 263 | * GetWindowsDirectoryA (KERNEL32.311) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 264 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 265 | UINT WINAPI GetWindowsDirectoryA( LPSTR path, UINT count ) |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 266 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 267 | if (path) lstrcpynA( path, DIR_Windows.short_name, count ); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 268 | return strlen( DIR_Windows.short_name ); |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | |
| 272 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 273 | * GetWindowsDirectoryW (KERNEL32.312) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 274 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 275 | UINT WINAPI GetWindowsDirectoryW( LPWSTR path, UINT count ) |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 276 | { |
Alexandre Julliard | 24a62ab | 2000-11-28 22:40:56 +0000 | [diff] [blame] | 277 | UINT len = MultiByteToWideChar( CP_ACP, 0, DIR_Windows.short_name, -1, NULL, 0 ); |
| 278 | if (path && count) |
| 279 | { |
| 280 | if (!MultiByteToWideChar( CP_ACP, 0, DIR_Windows.short_name, -1, path, count )) |
| 281 | path[count-1] = 0; |
| 282 | } |
| 283 | return len; |
Alexandre Julliard | 2c69f6d | 1996-09-28 18:11:01 +0000 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | |
| 287 | /*********************************************************************** |
David Elliott | 44f84b5 | 2000-10-29 01:24:54 +0000 | [diff] [blame] | 288 | * GetSystemWindowsDirectoryA (KERNEL32) W2K, TS4.0SP4 |
| 289 | */ |
| 290 | UINT WINAPI GetSystemWindowsDirectoryA( LPSTR path, UINT count ) |
| 291 | { |
| 292 | return GetWindowsDirectoryA( path, count ); |
| 293 | } |
| 294 | |
| 295 | |
| 296 | /*********************************************************************** |
| 297 | * GetSystemWindowsDirectoryW (KERNEL32) W2K, TS4.0SP4 |
| 298 | */ |
| 299 | UINT WINAPI GetSystemWindowsDirectoryW( LPWSTR path, UINT count ) |
| 300 | { |
| 301 | return GetWindowsDirectoryW( path, count ); |
| 302 | } |
| 303 | |
| 304 | |
| 305 | /*********************************************************************** |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 306 | * GetSystemDirectory16 (KERNEL.135) |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 307 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 308 | UINT16 WINAPI GetSystemDirectory16( LPSTR path, UINT16 count ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 309 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 310 | return (UINT16)GetSystemDirectoryA( path, count ); |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | |
| 314 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 315 | * GetSystemDirectoryA (KERNEL32.282) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 316 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 317 | UINT WINAPI GetSystemDirectoryA( LPSTR path, UINT count ) |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 318 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 319 | if (path) lstrcpynA( path, DIR_System.short_name, count ); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 320 | return strlen( DIR_System.short_name ); |
Alexandre Julliard | 4f8c37b | 1996-01-14 18:12:01 +0000 | [diff] [blame] | 321 | } |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 322 | |
| 323 | |
| 324 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 325 | * GetSystemDirectoryW (KERNEL32.283) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 326 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 327 | UINT WINAPI GetSystemDirectoryW( LPWSTR path, UINT count ) |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 328 | { |
Alexandre Julliard | 24a62ab | 2000-11-28 22:40:56 +0000 | [diff] [blame] | 329 | UINT len = MultiByteToWideChar( CP_ACP, 0, DIR_System.short_name, -1, NULL, 0 ); |
| 330 | if (path && count) |
| 331 | { |
| 332 | if (!MultiByteToWideChar( CP_ACP, 0, DIR_System.short_name, -1, path, count )) |
| 333 | path[count-1] = 0; |
| 334 | } |
| 335 | return len; |
Alexandre Julliard | 3051b64 | 1996-07-05 17:14:13 +0000 | [diff] [blame] | 336 | } |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 337 | |
| 338 | |
| 339 | /*********************************************************************** |
| 340 | * CreateDirectory16 (KERNEL.144) |
| 341 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 342 | BOOL16 WINAPI CreateDirectory16( LPCSTR path, LPVOID dummy ) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 343 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 344 | TRACE_(file)("(%s,%p)\n", path, dummy ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 345 | return (BOOL16)CreateDirectoryA( path, NULL ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | |
| 349 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 350 | * CreateDirectoryA (KERNEL32.39) |
Marcus Meissner | 412d025 | 1999-02-28 19:50:39 +0000 | [diff] [blame] | 351 | * RETURNS: |
| 352 | * TRUE : success |
| 353 | * FALSE : failure |
| 354 | * ERROR_DISK_FULL: on full disk |
| 355 | * ERROR_ALREADY_EXISTS: if directory name exists (even as file) |
| 356 | * ERROR_ACCESS_DENIED: on permission problems |
| 357 | * ERROR_FILENAME_EXCED_RANGE: too long filename(s) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 358 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 359 | BOOL WINAPI CreateDirectoryA( LPCSTR path, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 360 | LPSECURITY_ATTRIBUTES lpsecattribs ) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 361 | { |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 362 | DOS_FULL_NAME full_name; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 363 | |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 364 | TRACE_(file)("(%s,%p)\n", path, lpsecattribs ); |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 365 | if (DOSFS_GetDevice( path )) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 366 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 367 | TRACE_(file)("cannot use device '%s'!\n",path); |
Alexandre Julliard | 4ff2a27 | 1999-01-31 15:23:45 +0000 | [diff] [blame] | 368 | SetLastError( ERROR_ACCESS_DENIED ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 369 | return FALSE; |
| 370 | } |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 371 | if (!DOSFS_GetFullName( path, FALSE, &full_name )) return 0; |
Marcus Meissner | 412d025 | 1999-02-28 19:50:39 +0000 | [diff] [blame] | 372 | if (mkdir( full_name.long_name, 0777 ) == -1) { |
Andreas Mohr | 8c2f4b1 | 2001-03-03 00:22:50 +0000 | [diff] [blame] | 373 | WARN_(file)("Error '%s' trying to create directory '%s'\n", strerror(errno), full_name.long_name); |
Marcus Meissner | 412d025 | 1999-02-28 19:50:39 +0000 | [diff] [blame] | 374 | /* the FILE_SetDosError() generated error codes don't match the |
| 375 | * CreateDirectory ones for some errnos */ |
| 376 | switch (errno) { |
| 377 | case EEXIST: SetLastError(ERROR_ALREADY_EXISTS); break; |
| 378 | case ENOSPC: SetLastError(ERROR_DISK_FULL); break; |
| 379 | default: FILE_SetDosError();break; |
| 380 | } |
| 381 | return FALSE; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 382 | } |
| 383 | return TRUE; |
| 384 | } |
| 385 | |
| 386 | |
| 387 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 388 | * CreateDirectoryW (KERNEL32.42) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 389 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 390 | BOOL WINAPI CreateDirectoryW( LPCWSTR path, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 391 | LPSECURITY_ATTRIBUTES lpsecattribs ) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 392 | { |
| 393 | LPSTR xpath = HEAP_strdupWtoA( GetProcessHeap(), 0, path ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 394 | BOOL ret = CreateDirectoryA( xpath, lpsecattribs ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 395 | HeapFree( GetProcessHeap(), 0, xpath ); |
| 396 | return ret; |
| 397 | } |
| 398 | |
| 399 | |
| 400 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 401 | * CreateDirectoryExA (KERNEL32.40) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 402 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 403 | BOOL WINAPI CreateDirectoryExA( LPCSTR template, LPCSTR path, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 404 | LPSECURITY_ATTRIBUTES lpsecattribs) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 405 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 406 | return CreateDirectoryA(path,lpsecattribs); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | |
| 410 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 411 | * CreateDirectoryExW (KERNEL32.41) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 412 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 413 | BOOL WINAPI CreateDirectoryExW( LPCWSTR template, LPCWSTR path, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 414 | LPSECURITY_ATTRIBUTES lpsecattribs) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 415 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 416 | return CreateDirectoryW(path,lpsecattribs); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | |
| 420 | /*********************************************************************** |
| 421 | * RemoveDirectory16 (KERNEL) |
| 422 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 423 | BOOL16 WINAPI RemoveDirectory16( LPCSTR path ) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 424 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 425 | return (BOOL16)RemoveDirectoryA( path ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | |
| 429 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 430 | * RemoveDirectoryA (KERNEL32.437) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 431 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 432 | BOOL WINAPI RemoveDirectoryA( LPCSTR path ) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 433 | { |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 434 | DOS_FULL_NAME full_name; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 435 | |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 436 | TRACE_(file)("'%s'\n", path ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 437 | |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 438 | if (DOSFS_GetDevice( path )) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 439 | { |
Alexandre Julliard | 06c275a | 1999-05-02 14:32:27 +0000 | [diff] [blame] | 440 | TRACE_(file)("cannot remove device '%s'!\n", path); |
Alexandre Julliard | 4ff2a27 | 1999-01-31 15:23:45 +0000 | [diff] [blame] | 441 | SetLastError( ERROR_FILE_NOT_FOUND ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 442 | return FALSE; |
| 443 | } |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 444 | if (!DOSFS_GetFullName( path, TRUE, &full_name )) return FALSE; |
| 445 | if (rmdir( full_name.long_name ) == -1) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 446 | { |
| 447 | FILE_SetDosError(); |
| 448 | return FALSE; |
| 449 | } |
| 450 | return TRUE; |
| 451 | } |
| 452 | |
| 453 | |
| 454 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 455 | * RemoveDirectoryW (KERNEL32.438) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 456 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 457 | BOOL WINAPI RemoveDirectoryW( LPCWSTR path ) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 458 | { |
| 459 | LPSTR xpath = HEAP_strdupWtoA( GetProcessHeap(), 0, path ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 460 | BOOL ret = RemoveDirectoryA( xpath ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 461 | HeapFree( GetProcessHeap(), 0, xpath ); |
| 462 | return ret; |
| 463 | } |
| 464 | |
| 465 | |
| 466 | /*********************************************************************** |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 467 | * DIR_TryPath |
| 468 | * |
| 469 | * Helper function for DIR_SearchPath. |
| 470 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 471 | static BOOL DIR_TryPath( const DOS_FULL_NAME *dir, LPCSTR name, |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 472 | DOS_FULL_NAME *full_name ) |
| 473 | { |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 474 | LPSTR p_l = full_name->long_name + strlen(dir->long_name) + 1; |
| 475 | LPSTR p_s = full_name->short_name + strlen(dir->short_name) + 1; |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 476 | |
| 477 | if ((p_s >= full_name->short_name + sizeof(full_name->short_name) - 14) || |
| 478 | (p_l >= full_name->long_name + sizeof(full_name->long_name) - 1)) |
| 479 | { |
Alexandre Julliard | 4ff2a27 | 1999-01-31 15:23:45 +0000 | [diff] [blame] | 480 | SetLastError( ERROR_PATH_NOT_FOUND ); |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 481 | return FALSE; |
| 482 | } |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 483 | if (!DOSFS_FindUnixName( dir->long_name, name, p_l, |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 484 | sizeof(full_name->long_name) - (p_l - full_name->long_name), |
Andreas Mohr | 0471841 | 1999-08-07 12:36:11 +0000 | [diff] [blame] | 485 | p_s, !(DRIVE_GetFlags(dir->drive) & DRIVE_CASE_SENSITIVE) )) |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 486 | return FALSE; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 487 | strcpy( full_name->long_name, dir->long_name ); |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 488 | p_l[-1] = '/'; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 489 | strcpy( full_name->short_name, dir->short_name ); |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 490 | p_s[-1] = '\\'; |
| 491 | return TRUE; |
| 492 | } |
| 493 | |
| 494 | |
| 495 | /*********************************************************************** |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 496 | * DIR_TryEnvironmentPath |
| 497 | * |
| 498 | * Helper function for DIR_SearchPath. |
Alexandre Julliard | 9400e2d | 2000-11-01 21:48:38 +0000 | [diff] [blame] | 499 | * Search in the specified path, or in $PATH if NULL. |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 500 | */ |
Alexandre Julliard | 9400e2d | 2000-11-01 21:48:38 +0000 | [diff] [blame] | 501 | static BOOL DIR_TryEnvironmentPath( LPCSTR name, DOS_FULL_NAME *full_name, LPCSTR envpath ) |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 502 | { |
| 503 | LPSTR path, next, buffer; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 504 | BOOL ret = FALSE; |
| 505 | INT len = strlen(name); |
Alexandre Julliard | 9400e2d | 2000-11-01 21:48:38 +0000 | [diff] [blame] | 506 | DWORD size; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 507 | |
Alexandre Julliard | 9400e2d | 2000-11-01 21:48:38 +0000 | [diff] [blame] | 508 | size = envpath ? strlen(envpath)+1 : GetEnvironmentVariableA( "PATH", NULL, 0 ); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 509 | if (!size) return FALSE; |
| 510 | if (!(path = HeapAlloc( GetProcessHeap(), 0, size ))) return FALSE; |
Alexandre Julliard | 9400e2d | 2000-11-01 21:48:38 +0000 | [diff] [blame] | 511 | if (envpath) strcpy( path, envpath ); |
| 512 | else if (!GetEnvironmentVariableA( "PATH", path, size )) goto done; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 513 | next = path; |
| 514 | while (!ret && next) |
| 515 | { |
| 516 | LPSTR cur = next; |
| 517 | while (*cur == ';') cur++; |
| 518 | if (!*cur) break; |
| 519 | next = strchr( cur, ';' ); |
| 520 | if (next) *next++ = '\0'; |
| 521 | if (!(buffer = HeapAlloc( GetProcessHeap(), 0, strlen(cur) + len + 2))) |
| 522 | goto done; |
| 523 | strcpy( buffer, cur ); |
| 524 | strcat( buffer, "\\" ); |
| 525 | strcat( buffer, name ); |
| 526 | ret = DOSFS_GetFullName( buffer, TRUE, full_name ); |
| 527 | HeapFree( GetProcessHeap(), 0, buffer ); |
| 528 | } |
| 529 | |
| 530 | done: |
| 531 | HeapFree( GetProcessHeap(), 0, path ); |
| 532 | return ret; |
| 533 | } |
| 534 | |
| 535 | |
| 536 | /*********************************************************************** |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 537 | * DIR_TryModulePath |
| 538 | * |
| 539 | * Helper function for DIR_SearchPath. |
| 540 | */ |
Alexandre Julliard | b18dbd2 | 2000-07-25 12:11:53 +0000 | [diff] [blame] | 541 | static BOOL DIR_TryModulePath( LPCSTR name, DOS_FULL_NAME *full_name, BOOL win32 ) |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 542 | { |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 543 | /* FIXME: for now, GetModuleFileNameA can't return more */ |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 544 | /* than OFS_MAXPATHNAME. This may change with Win32. */ |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 545 | |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 546 | char buffer[OFS_MAXPATHNAME]; |
| 547 | LPSTR p; |
| 548 | |
Alexandre Julliard | b18dbd2 | 2000-07-25 12:11:53 +0000 | [diff] [blame] | 549 | if (!win32) |
| 550 | { |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 551 | if (!GetCurrentTask()) return FALSE; |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 552 | if (!GetModuleFileName16( GetCurrentTask(), buffer, sizeof(buffer) )) |
| 553 | buffer[0]='\0'; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 554 | } else { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 555 | if (!GetModuleFileNameA( 0, buffer, sizeof(buffer) )) |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 556 | buffer[0]='\0'; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 557 | } |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 558 | if (!(p = strrchr( buffer, '\\' ))) return FALSE; |
| 559 | if (sizeof(buffer) - (++p - buffer) <= strlen(name)) return FALSE; |
| 560 | strcpy( p, name ); |
| 561 | return DOSFS_GetFullName( buffer, TRUE, full_name ); |
| 562 | } |
| 563 | |
| 564 | |
| 565 | /*********************************************************************** |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 566 | * DIR_SearchPath |
| 567 | * |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 568 | * Implementation of SearchPathA. 'win32' specifies whether the search |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 569 | * order is Win16 (module path last) or Win32 (module path first). |
| 570 | * |
| 571 | * FIXME: should return long path names. |
| 572 | */ |
| 573 | DWORD DIR_SearchPath( LPCSTR path, LPCSTR name, LPCSTR ext, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 574 | DOS_FULL_NAME *full_name, BOOL win32 ) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 575 | { |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 576 | LPCSTR p; |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 577 | LPSTR tmp = NULL; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 578 | BOOL ret = TRUE; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 579 | |
| 580 | /* First check the supplied parameters */ |
| 581 | |
Alexandre Julliard | 641ee76 | 1997-08-04 16:34:36 +0000 | [diff] [blame] | 582 | p = strrchr( name, '.' ); |
| 583 | if (p && !strchr( p, '/' ) && !strchr( p, '\\' )) |
| 584 | ext = NULL; /* Ignore the specified extension */ |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 585 | if ((*name && (name[1] == ':')) || |
| 586 | strchr( name, '/' ) || strchr( name, '\\' )) |
| 587 | path = NULL; /* Ignore path if name already contains a path */ |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 588 | if (path && !*path) path = NULL; /* Ignore empty path */ |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 589 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 590 | /* Allocate a buffer for the file name and extension */ |
| 591 | |
Alexandre Julliard | 9400e2d | 2000-11-01 21:48:38 +0000 | [diff] [blame] | 592 | if (ext) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 593 | { |
Alexandre Julliard | 9400e2d | 2000-11-01 21:48:38 +0000 | [diff] [blame] | 594 | DWORD len = strlen(name) + strlen(ext); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 595 | if (!(tmp = HeapAlloc( GetProcessHeap(), 0, len + 1 ))) |
| 596 | { |
| 597 | SetLastError( ERROR_OUTOFMEMORY ); |
| 598 | return 0; |
| 599 | } |
Alexandre Julliard | 9400e2d | 2000-11-01 21:48:38 +0000 | [diff] [blame] | 600 | strcpy( tmp, name ); |
| 601 | strcat( tmp, ext ); |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 602 | name = tmp; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 603 | } |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 604 | |
Alexandre Julliard | 9400e2d | 2000-11-01 21:48:38 +0000 | [diff] [blame] | 605 | /* If the name contains an explicit path, everything's easy */ |
| 606 | |
| 607 | if ((*name && (name[1] == ':')) || strchr( name, '/' ) || strchr( name, '\\' )) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 608 | { |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 609 | ret = DOSFS_GetFullName( name, TRUE, full_name ); |
| 610 | goto done; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 611 | } |
| 612 | |
Alexandre Julliard | 9400e2d | 2000-11-01 21:48:38 +0000 | [diff] [blame] | 613 | /* Search in the specified path */ |
| 614 | |
| 615 | if (path) |
| 616 | { |
| 617 | ret = DIR_TryEnvironmentPath( name, full_name, path ); |
| 618 | goto done; |
| 619 | } |
| 620 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 621 | /* Try the path of the current executable (for Win32 search order) */ |
| 622 | |
Alexandre Julliard | b18dbd2 | 2000-07-25 12:11:53 +0000 | [diff] [blame] | 623 | if (win32 && DIR_TryModulePath( name, full_name, win32 )) goto done; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 624 | |
| 625 | /* Try the current directory */ |
| 626 | |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 627 | if (DOSFS_GetFullName( name, TRUE, full_name )) goto done; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 628 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 629 | /* Try the Windows system directory */ |
| 630 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 631 | if (DIR_TryPath( &DIR_System, name, full_name )) |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 632 | goto done; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 633 | |
Guy Albertelli | e40c9b0 | 1999-06-05 11:47:25 +0000 | [diff] [blame] | 634 | /* Try the Windows directory */ |
| 635 | |
| 636 | if (DIR_TryPath( &DIR_Windows, name, full_name )) |
| 637 | goto done; |
| 638 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 639 | /* Try the path of the current executable (for Win16 search order) */ |
| 640 | |
Alexandre Julliard | b18dbd2 | 2000-07-25 12:11:53 +0000 | [diff] [blame] | 641 | if (!win32 && DIR_TryModulePath( name, full_name, win32 )) goto done; |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 642 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 643 | /* Try all directories in path */ |
| 644 | |
Alexandre Julliard | 9400e2d | 2000-11-01 21:48:38 +0000 | [diff] [blame] | 645 | ret = DIR_TryEnvironmentPath( name, full_name, NULL ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 646 | |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 647 | done: |
| 648 | if (tmp) HeapFree( GetProcessHeap(), 0, tmp ); |
| 649 | return ret; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 650 | } |
| 651 | |
| 652 | |
| 653 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 654 | * SearchPathA [KERNEL32.447] |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 655 | * |
| 656 | * Searches for a specified file in the search path. |
| 657 | * |
| 658 | * PARAMS |
| 659 | * path [I] Path to search |
| 660 | * name [I] Filename to search for. |
| 661 | * ext [I] File extension to append to file name. The first |
| 662 | * character must be a period. This parameter is |
| 663 | * specified only if the filename given does not |
| 664 | * contain an extension. |
| 665 | * buflen [I] size of buffer, in characters |
| 666 | * buffer [O] buffer for found filename |
| 667 | * lastpart [O] address of pointer to last used character in |
| 668 | * buffer (the final '\') |
| 669 | * |
| 670 | * RETURNS |
| 671 | * Success: length of string copied into buffer, not including |
| 672 | * terminating null character. If the filename found is |
| 673 | * longer than the length of the buffer, the length of the |
| 674 | * filename is returned. |
| 675 | * Failure: Zero |
| 676 | * |
| 677 | * NOTES |
James Juran | 65020b3 | 2000-05-23 01:13:50 +0000 | [diff] [blame] | 678 | * If the file is not found, calls SetLastError(ERROR_FILE_NOT_FOUND) |
| 679 | * (tested on NT 4.0) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 680 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 681 | DWORD WINAPI SearchPathA( LPCSTR path, LPCSTR name, LPCSTR ext, DWORD buflen, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 682 | LPSTR buffer, LPSTR *lastpart ) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 683 | { |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 684 | LPSTR p, res; |
| 685 | DOS_FULL_NAME full_name; |
| 686 | |
James Juran | 65020b3 | 2000-05-23 01:13:50 +0000 | [diff] [blame] | 687 | if (!DIR_SearchPath( path, name, ext, &full_name, TRUE )) |
| 688 | { |
| 689 | SetLastError(ERROR_FILE_NOT_FOUND); |
| 690 | return 0; |
| 691 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 692 | lstrcpynA( buffer, full_name.short_name, buflen ); |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 693 | res = full_name.long_name + |
| 694 | strlen(DRIVE_GetRoot( full_name.short_name[0] - 'A' )); |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 695 | while (*res == '/') res++; |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 696 | if (buflen) |
| 697 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 698 | if (buflen > 3) lstrcpynA( buffer + 3, res, buflen - 3 ); |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 699 | for (p = buffer; *p; p++) if (*p == '/') *p = '\\'; |
| 700 | if (lastpart) *lastpart = strrchr( buffer, '\\' ) + 1; |
| 701 | } |
Dimitrie O. Paun | dd03cc1 | 1999-12-08 03:56:23 +0000 | [diff] [blame] | 702 | TRACE("Returning %d\n", strlen(res) + 3 ); |
Guy Albertelli | e711ba2 | 1999-04-06 07:14:09 +0000 | [diff] [blame] | 703 | return strlen(res) + 3; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 704 | } |
| 705 | |
| 706 | |
| 707 | /*********************************************************************** |
Patrik Stridvall | 2d6457c | 2000-03-28 20:22:59 +0000 | [diff] [blame] | 708 | * SearchPathW (KERNEL32.448) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 709 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 710 | DWORD WINAPI SearchPathW( LPCWSTR path, LPCWSTR name, LPCWSTR ext, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 711 | DWORD buflen, LPWSTR buffer, LPWSTR *lastpart ) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 712 | { |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 713 | LPWSTR p; |
| 714 | LPSTR res; |
| 715 | DOS_FULL_NAME full_name; |
| 716 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 717 | LPSTR pathA = HEAP_strdupWtoA( GetProcessHeap(), 0, path ); |
| 718 | LPSTR nameA = HEAP_strdupWtoA( GetProcessHeap(), 0, name ); |
| 719 | LPSTR extA = HEAP_strdupWtoA( GetProcessHeap(), 0, ext ); |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 720 | DWORD ret = DIR_SearchPath( pathA, nameA, extA, &full_name, TRUE ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 721 | HeapFree( GetProcessHeap(), 0, extA ); |
| 722 | HeapFree( GetProcessHeap(), 0, nameA ); |
| 723 | HeapFree( GetProcessHeap(), 0, pathA ); |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 724 | if (!ret) return 0; |
| 725 | |
Alexandre Julliard | 24a62ab | 2000-11-28 22:40:56 +0000 | [diff] [blame] | 726 | if (buflen > 0 && !MultiByteToWideChar( CP_ACP, 0, full_name.short_name, -1, buffer, buflen )) |
| 727 | buffer[buflen-1] = 0; |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 728 | res = full_name.long_name + |
| 729 | strlen(DRIVE_GetRoot( full_name.short_name[0] - 'A' )); |
Alexandre Julliard | 349a953 | 1997-02-02 19:01:52 +0000 | [diff] [blame] | 730 | while (*res == '/') res++; |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 731 | if (buflen) |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 732 | { |
Alexandre Julliard | 24a62ab | 2000-11-28 22:40:56 +0000 | [diff] [blame] | 733 | if (buflen > 3) |
| 734 | { |
| 735 | if (!MultiByteToWideChar( CP_ACP, 0, res, -1, buffer+3, buflen-3 )) |
| 736 | buffer[buflen-1] = 0; |
| 737 | } |
Alexandre Julliard | 3db94ef | 1997-09-28 17:43:24 +0000 | [diff] [blame] | 738 | for (p = buffer; *p; p++) if (*p == '/') *p = '\\'; |
| 739 | if (lastpart) |
| 740 | { |
| 741 | for (p = *lastpart = buffer; *p; p++) |
| 742 | if (*p == '\\') *lastpart = p + 1; |
| 743 | } |
Alexandre Julliard | c6c0944 | 1997-01-12 18:32:19 +0000 | [diff] [blame] | 744 | } |
Guy Albertelli | e711ba2 | 1999-04-06 07:14:09 +0000 | [diff] [blame] | 745 | return strlen(res) + 3; |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 746 | } |
| 747 | |
| 748 | |