Ignore:
Timestamp:
Aug 31, 2001, 9:53:11 PM (24 years ago)
Author:
phaller
Message:

fix for MoveFile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/Fileio.cpp

    r6511 r6613  
    1 /* $Id: Fileio.cpp,v 1.52 2001-08-10 19:32:23 sandervl Exp $ */
     1/* $Id: Fileio.cpp,v 1.53 2001-08-31 19:53:11 phaller Exp $ */
    22
    33/*
     
    927927//******************************************************************************
    928928//******************************************************************************
     929
     930
     931/*****************************************************************************
     932 * Name      : MoveFileExA
     933 * Purpose   : Move or delete a file
     934 * Parameters: LPCSTR lpExistingFileName
     935 *             LPCSTR lpNewFileName
     936 *             DWORD  dwFlags
     937 * Variables :
     938 * Result    :
     939 * Remark    : "delete on system-reboot" feature is not supported!
     940 * Status    :
     941 *
     942 * Author    : Patrick Haller [2001-08-30]
     943 *****************************************************************************/
     944
    929945ODINFUNCTION3(BOOL, MoveFileExA,
    930               LPCSTR, arg1,
    931               LPCSTR, arg2,
     946              LPCSTR, lpszOldFilename,
     947              LPCSTR, lpszNewFilename,
    932948              DWORD, fdwFlags)
    933949{
    934     dprintf(("KERNEL32:  MoveFileExA %s to %s %x, not complete!\n", arg1, arg2, fdwFlags));
    935     return OSLibDosMoveFile(arg1, arg2);
     950  dprintf(("KERNEL32:  MoveFileExA %s to %s %x, not complete!\n",
     951           lpszOldFilename,
     952           lpszNewFilename,
     953           fdwFlags));
     954 
     955  // this parameter combination is illegal
     956  if ( (fdwFlags & MOVEFILE_DELAY_UNTIL_REBOOT) &&
     957       (fdwFlags & MOVEFILE_COPY_ALLOWED) )
     958  {
     959    // Note: error code not verified
     960    SetLastError(ERROR_INVALID_PARAMETER);
     961    return FALSE;
     962  }
     963 
     964  // first, we take care about the special cases
     965  if (fdwFlags && MOVEFILE_DELAY_UNTIL_REBOOT)
     966  {
     967    // We cannot really support this in any other way than
     968    // to call the IBMCSFLK driver. As the first place I've encountered
     969    // this call is Microsoft ACMSETUP wanting to replace OLEPRO32.DLL
     970    // in the ODIN system directory, we are better skipping the call.
     971   
     972    // Anyway, this is only supported under Windows NT
     973    fdwFlags &= ~MOVEFILE_DELAY_UNTIL_REBOOT;
     974   
     975    // Until we support this, we have to intercept
     976    // lpszNewFilename == NULL
     977    if (NULL == lpszNewFilename)
     978    {
     979      // try to delete the filename
     980      dprintf(("KERNEL32-MoveFileExA: trying to delete file [%s], skipped.",
     981               lpszOldFilename));
     982     
     983      SetLastError( NO_ERROR );
     984      return TRUE;
     985    }
     986  }
     987 
     988  if (fdwFlags && MOVEFILE_COPY_ALLOWED)
     989  {
     990    // if lpszOldFilename and lpszNewFilename refer to different
     991    // volumes, this flag controls if a copy operation is allowed.
     992  }
     993 
     994  if (fdwFlags && MOVEFILE_REPLACE_EXISTING)
     995  {
     996    // We can only attempt to
     997    // 1 move away the current file if existing,
     998    // 2 do the current move operation
     999    // 3 if succesful, delete the backup
     1000    //   otherwise restore the original file
     1001  }
     1002 
     1003  return OSLibDosMoveFile(lpszOldFilename,
     1004                          lpszNewFilename);
    9361005}
    9371006//******************************************************************************
     
    9541023//******************************************************************************
    9551024ODINFUNCTION3(BOOL, MoveFileExW,
    956               LPCWSTR, arg1,
    957               LPCWSTR, arg2,
     1025              LPCWSTR, lpSrc,
     1026              LPCWSTR, lpDest,
    9581027              DWORD, fdwFlags)
    9591028{
    960     dprintf(("KERNEL32:  MoveFileExW %ls to %ls %x, not complete!", arg1, arg2, fdwFlags));
    961     return MoveFileW(arg1, arg2);
     1029  dprintf(("KERNEL32: MoveFileExW %ls to %ls %x",
     1030           lpSrc,
     1031           lpDest,
     1032           fdwFlags));
     1033 
     1034  char *asciisrc,
     1035       *asciidest;
     1036  BOOL rc;
     1037
     1038  asciisrc  = UnicodeToAsciiString((LPWSTR)lpSrc);
     1039  if (NULL != lpDest)
     1040    asciidest = UnicodeToAsciiString((LPWSTR)lpDest);
     1041  else
     1042    asciidest = NULL;
     1043 
     1044  rc = MoveFileExA(asciisrc,
     1045                   asciidest,
     1046                   fdwFlags);
     1047 
     1048  if (NULL != asciidest)
     1049    FreeAsciiString(asciidest);
     1050 
     1051  FreeAsciiString(asciisrc);
     1052 
     1053  return(rc);
    9621054}
    9631055//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.