Changeset 3461 for trunk/src/kernel32/directory.cpp
- Timestamp:
- Apr 29, 2000, 8:26:59 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/directory.cpp
r3375 r3461 1 /* $Id: directory.cpp,v 1. 19 2000-04-14 22:35:26sandervl Exp $ */1 /* $Id: directory.cpp,v 1.20 2000-04-29 18:26:58 sandervl Exp $ */ 2 2 3 3 /* … … 63 63 void InitDirectories() 64 64 { 65 GetWindowsDirectoryA((LPSTR)&DIR_Windows, sizeof(DIR_Windows)); 66 GetSystemDirectoryA((LPSTR)&DIR_System, sizeof(DIR_System)); 67 } 68 65 char *endofwinpath, *tmp; 66 int len; 67 68 strcpy(DIR_System, kernel32Path); 69 len = strlen(DIR_System); 70 if(DIR_System[len-1] == '\\') { 71 DIR_System[len-1] = 0; 72 } 73 len = ODIN_PROFILE_GetOdinIniString(ODINDIRECTORIES,"WINDOWS","",DIR_Windows,sizeof(DIR_Windows)); 74 if (len > 2) { 75 if(DIR_Windows[len-1] == '\\') { 76 DIR_Windows[len-1] = 0; 77 } 78 } 79 else { 80 strcpy(DIR_Windows, DIR_System); 81 endofwinpath = tmp = strchr(DIR_Windows, '\\'); 82 while(tmp) { 83 tmp = strchr(endofwinpath+1, '\\'); 84 if(tmp) 85 endofwinpath = tmp; 86 } 87 if(endofwinpath) { 88 *endofwinpath = 0; //remove \SYSTEM32 89 } 90 else DebugInt3(); 91 } 92 } 69 93 /***************************************************************************** 70 94 * Name : GetCurrentDirectoryA … … 231 255 UINT,uSize) 232 256 { 233 char buf[255]; 234 int len; 235 236 lstrcpynA(buf, kernel32Path, sizeof(buf)-1); 237 len = lstrlenA(buf);; 238 if(buf[len-1] == '\\') { 239 buf[len-1] = 0; 240 len--; 241 } 257 int len; 258 char *dir; 259 260 dir = InternalGetSystemDirectoryA(); 261 len = lstrlenA(dir); 242 262 if(lpBuffer) 243 lstrcpynA(lpBuffer, buf, uSize);263 lstrcpynA(lpBuffer, dir, uSize); 244 264 return len; 245 265 } … … 265 285 266 286 if(lpBuffer) 267 asciibuffer = (char *)malloc(uSize+1); 287 asciibuffer = (char *)alloca(uSize+1); 288 289 if(lpBuffer && asciibuffer == NULL) { 290 DebugInt3(); 291 } 268 292 269 293 rc = GetSystemDirectoryA(asciibuffer, uSize); … … 271 295 AsciiToUnicode(asciibuffer, lpBuffer); 272 296 273 if(asciibuffer)274 free(asciibuffer);275 297 return(rc); 276 298 } … … 292 314 UINT,uSize) 293 315 { 294 static int fWindirExists = FALSE; 295 CHAR buf[255]; 296 int len; 297 298 //SvL: Use path of kernel32.dll instead of calling Open32 api (which returns \OS2\SYSTEM) 299 lstrcpynA(buf, kernel32Path, sizeof(buf)-1); 300 strcat(buf, "WIN"); 301 if(!fWindirExists) { 302 O32_CreateDirectory(buf, NULL); 303 fWindirExists = TRUE; 304 } 305 306 len = lstrlenA(buf);; 307 if(buf[len-1] == '\\') { 308 buf[len-1] = 0; 309 len--; 310 } 316 char *dir; 317 int len; 318 319 dir = InternalGetWindowsDirectoryA(); 320 len = lstrlenA(dir); 311 321 if(lpBuffer) 312 lstrcpynA(lpBuffer, buf, uSize);322 lstrcpynA(lpBuffer, dir, uSize); 313 323 return len; 314 324 } … … 334 344 335 345 if(lpBuffer) 336 asciibuffer = (char *)malloc(uSize+1); 346 asciibuffer = (char *)alloca(uSize+1); 347 348 if(lpBuffer && asciibuffer == NULL) { 349 DebugInt3(); 350 } 337 351 338 352 rc = GetWindowsDirectoryA(asciibuffer, uSize); … … 340 354 AsciiToUnicode(asciibuffer, lpBuffer); 341 355 342 if(asciibuffer)343 free(asciibuffer);344 356 return(rc); 345 357 }
Note:
See TracChangeset
for help on using the changeset viewer.