示例#1
0
        // do not call `Marshal.GetLastWin32Error` inside this method since it's called while the p/invoke is executing and will return `260`
        static CopyFileResult CopyFileCallback(CopyFileWhat what, CopyFileStep stage, IntPtr state, string source, string target, IntPtr ctx)
        {
//			Console.WriteLine ("CopyFileCallback ({0}, {1}, 0x{2}, {3}, {4}, 0x{5})", what, stage, state.ToString ("x"), source, target, ctx.ToString ("x"));
            switch (what)
            {
            case CopyFileWhat.File:
                if (!IsUptodate(source, target))
                {
                    if (stage == CopyFileStep.Finish)
                    {
                        Log(1, "Copied {0} to {1}", source, target);
                    }
                    else if (stage == CopyFileStep.Err)
                    {
                        Log(1, "Could not copy the file '{0}' to '{1}'", source, target);
                        return(CopyFileResult.Quit);
                    }
                    else if (stage == CopyFileStep.Start)
                    {
                        if (File.Exists(target) || Directory.Exists(target))
                        {
                            Log(1, "Deleted target {0}, it's not up-to-date", target);
                            // This callback won't be called for directories, but we can get here for symlinks to directories.
                            // This means that File.Delete should always work (no need to check for a directory to call Directory.Delete)
                            File.Delete(target);
                        }
                    }
                    return(CopyFileResult.Continue);
                }
                else
                {
                    Log(3, "Target '{0}' is up-to-date", target);
                    return(CopyFileResult.Skip);
                }

            case CopyFileWhat.Dir:
            case CopyFileWhat.DirCleanup:
            case CopyFileWhat.CopyData:
            case CopyFileWhat.CopyXattr:
                return(CopyFileResult.Continue);

            case CopyFileWhat.Error:
                Log(1, "Could not copy the file '{0}' to '{1}'", source, target);
                return(CopyFileResult.Quit);

            default:
                return(CopyFileResult.Continue);
            }
        }
示例#2
0
 static CopyFileResult CopyFileCallback(CopyFileWhat what, CopyFileStep stage, IntPtr state, string source, string target, IntPtr ctx)
 {
     //			Console.WriteLine ("CopyFileCallback ({0}, {1}, 0x{2}, {3}, {4}, 0x{5})", what, stage, state.ToString ("x"), source, target, ctx.ToString ("x"));
     switch (what) {
     case CopyFileWhat.File:
         if (!IsUptodate (source, target)) {
             if (stage == CopyFileStep.Finish)
                 Driver.Log (1, "Copied {0} to {1}", source, target);
             return CopyFileResult.Continue;
         } else {
             Driver.Log (3, "Target '{0}' is up-to-date", target);
             return CopyFileResult.Skip;
         }
     case CopyFileWhat.Dir:
     case CopyFileWhat.DirCleanup:
     case CopyFileWhat.CopyData:
     case CopyFileWhat.CopyXattr:
         return CopyFileResult.Continue;
     case CopyFileWhat.Error:
         throw ErrorHelper.CreateError (1021, "Could not copy the file '{0}' to '{1}': {2}", source, target, Target.strerror (Marshal.GetLastWin32Error ()));
     default:
         return CopyFileResult.Continue;
     }
 }