Changeset 3799 for trunk/src/kernel32/Fileio.cpp
- Timestamp:
- Jul 4, 2000, 10:41:13 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/Fileio.cpp
r3697 r3799 1 /* $Id: Fileio.cpp,v 1.3 5 2000-06-13 07:11:37 phallerExp $ */1 /* $Id: Fileio.cpp,v 1.36 2000-07-04 08:41:12 sandervl Exp $ */ 2 2 3 3 /* … … 6 6 * Copyright 1998 Sander van Leeuwen 7 7 * Copyright 1998 Patrick Haller 8 * 9 * Some parts copied from Wine (CopyFileExA/W) 10 * 11 * Copyright 1993 John Burton 12 * Copyright 1996 Alexandre Julliard 13 * 8 14 * 9 15 * Project Odin Software License can be found in LICENSE.TXT … … 288 294 FreeAsciiString(astring1); 289 295 return(rc); 296 } 297 /***************************************************************************** 298 * Name : BOOL WIN32API CopyFileExA 299 * Purpose : The CopyFileExA function copies an existing file to a new file. 300 * This function preserves extended attributes, OLE structured 301 * storage, NTFS alternate data streams, and file attributes. 302 * Security attributes for the existing file are not copied to 303 * the new file. 304 * Parameters: LPCSTR lpExistingFileName pointer to name of an existing file 305 * LPCSTR lpNewFileName pointer to filename to copy to 306 * LPPROGRESS_ROUTINE lpProgressRoutine pointer to the callback function 307 * LPVOID lpData to be passed to the callback function 308 * LPBOOL pbCancel flag that can be used to cancel the operation 309 * DWORD dwCopyFlags flags that specify how the file is copied 310 * Variables : 311 * Result : f the function succeeds, the return value is nonzero. 312 * If the function fails, the return value is zero. 313 * To get extended error information call GetLastError. 314 * Remark : 315 * Status : UNTESTED STUB 316 * 317 * Author : Markus Montkowski [Thu, 1998/05/19 11:46] 318 *****************************************************************************/ 319 320 BOOL WIN32API CopyFileExA( LPCSTR lpExistingFileName, 321 LPCSTR lpNewFileName, 322 LPPROGRESS_ROUTINE lpProgressRoutine, 323 LPVOID lpData, 324 LPBOOL pbCancel, 325 DWORD dwCopyFlags) 326 { 327 328 dprintf(("KERNEL32: CopyFileExA(%08x,%08x,%08x,%08x,%08x,%08x) not properly implemented\n", 329 lpExistingFileName, 330 lpNewFileName, 331 lpProgressRoutine, 332 lpData, 333 pbCancel, 334 dwCopyFlags 335 )); 336 337 BOOL failIfExists = FALSE; 338 339 /* 340 * Interpret the only flag that CopyFile can interpret. 341 */ 342 if((dwCopyFlags & COPY_FILE_FAIL_IF_EXISTS) != 0) 343 { 344 failIfExists = TRUE; 345 } 346 347 return CopyFileA(lpExistingFileName, lpNewFileName, failIfExists); 348 } 349 350 351 /***************************************************************************** 352 * Name : BOOL WIN32API CopyFileExW 353 * Purpose : The CopyFileExW function copies an existing file to a new file. 354 * This function preserves extended attributes, OLE structured 355 * storage, NTFS alternate data streams, and file attributes. 356 * Security attributes for the existing file are not copied to 357 * the new file. 358 * Parameters: LPCWSTR lpExistingFileName pointer to name of an existing file 359 * LPCWSTR lpNewFileName pointer to filename to copy to 360 * LPPROGRESS_ROUTINE lpProgressRoutine pointer to the callback function 361 * LPVOID lpData to be passed to the callback function 362 * LPBOOL pbCancel flag that can be used to cancel the operation 363 * DWORD dwCopyFlags flags that specify how the file is copied 364 * Variables : 365 * Result : f the function succeeds, the return value is nonzero. 366 * If the function fails, the return value is zero. 367 * To get extended error information call GetLastError. 368 * Remark : 369 * Status : UNTESTED STUB 370 * 371 * Author : Markus Montkowski [Thu, 1998/05/19 11:46] 372 *****************************************************************************/ 373 374 BOOL WIN32API CopyFileExW( LPCWSTR lpExistingFileName, 375 LPCWSTR lpNewFileName, 376 LPPROGRESS_ROUTINE lpProgressRoutine, 377 LPVOID lpData, 378 LPBOOL pbCancel, 379 DWORD dwCopyFlags) 380 { 381 LPSTR sourceA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpExistingFileName ); 382 LPSTR destA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpNewFileName ); 383 384 BOOL ret = CopyFileExA(sourceA, 385 destA, 386 lpProgressRoutine, 387 lpData, 388 pbCancel, 389 dwCopyFlags); 390 391 HeapFree( GetProcessHeap(), 0, sourceA ); 392 HeapFree( GetProcessHeap(), 0, destA ); 393 394 return ret; 290 395 } 291 396 //****************************************************************************** … … 780 885 } 781 886 //****************************************************************************** 887 //Behaviour in NT 4, SP6: 888 //- converts long filename to 8.3 short filname (TODO: not yet done here!) 889 //- fails on volume that doesn't support 8.3 filenames 890 //- if lpszShortPath 0 or cchBuffer too small -> return required length 891 // (INCLUDING 0 terminator) 892 //- if lpszLongPath == NULL -> ERROR_INVALID_PARAMETER (return 0) 893 //- if lpszLongPath empty -> proceed as if nothing is wrong 894 //- does NOT clear the last error if successful! 895 //- if successful -> return length of string (excluding 0 terminator) 782 896 //****************************************************************************** 783 897 ODINFUNCTION3(DWORD, GetShortPathNameA, … … 788 902 int length; 789 903 790 dprintf(("KERNEL32: GetShortPathNameA of %s, just copying it\n", lpszLongPath)); 791 length = strlen(lpszLongPath) + 1; 904 dprintf(("KERNEL32: GetShortPathNameA of %s, just copying it", lpszLongPath)); 905 906 if(!lpszLongPath) { 907 SetLastError(ERROR_INVALID_PARAMETER); 908 return 0; 909 } 910 911 length = lstrlenA(lpszLongPath) + 1; 792 912 if(length > cchBuffer) { 793 *lpszShortPath = 0; 794 return(length); 795 } 796 memcpy(lpszShortPath, lpszLongPath, length); 913 if(lpszShortPath) { 914 *lpszShortPath = 0; 915 } 916 return(length); //return length required (including 0 terminator) 917 } 918 lstrcpyA(lpszShortPath, lpszLongPath); 797 919 return(length-1); 798 920 } … … 806 928 int length; 807 929 808 dprintf(("KERNEL32: GetShortPathNameW; just copying it\n")); 809 length = UniStrlen((UniChar*)lpszLongPath) + 1; 930 dprintf(("KERNEL32: GetShortPathNameW; just copying it")); 931 if(!lpszLongPath) { 932 SetLastError(ERROR_INVALID_PARAMETER); 933 return 0; 934 } 935 936 length = lstrlenW(lpszLongPath) + 1; 810 937 if(length > cchBuffer) { 811 *lpszShortPath = 0; 812 return(length); 813 } 814 memcpy(lpszShortPath, lpszLongPath, length*sizeof(USHORT)); 938 if(lpszShortPath) { 939 *lpszShortPath = 0; 940 } 941 return(length); //return length required (including 0 terminator) 942 } 943 lstrcpyW(lpszShortPath, lpszLongPath); 815 944 return(length-1); 816 945 } 946 //****************************************************************************** 947 //****************************************************************************** 817 948 ODINPROCEDURE0(SetFileApisToANSI) 818 949 {
Note:
See TracChangeset
for help on using the changeset viewer.