static bool TryUpdateDirectory(string source, string target, out int errno)
        {
            Directory.CreateDirectory(target);

            // Mono's File.Copy can't handle symlinks (the symlinks are followed instead of copied),
            // so we need to use native functions directly. Luckily OSX provides exactly what we need.
            IntPtr state = copyfile_state_alloc();

            try {
                CopyFileCallbackDelegate del = CopyFileCallback;
                copyfile_state_set(state, CopyFileState.StatusCB, Marshal.GetFunctionPointerForDelegate(del));
                int rv = copyfile(source, target, state, CopyFileFlags.Data | CopyFileFlags.Recursive | CopyFileFlags.Nofollow | CopyFileFlags.Clone);
                if (rv == 0)
                {
                    errno = 0;                     // satisfy compiler and make sure not to pick up some older error code
                    return(true);
                }
                else
                {
                    errno = Marshal.GetLastWin32Error();                      // might not be very useful since the callback signaled an error (CopyFileResult.Quit)
                    return(false);
                }
            } finally {
                copyfile_state_free(state);
            }
        }
Beispiel #2
0
        static int TryUpdateDirectory(string source, string target)
        {
            Directory.CreateDirectory(target);

            // Mono's File.Copy can't handle symlinks (the symlinks are followed instead of copied),
            // so we need to use native functions directly. Luckily OSX provides exactly what we need.
            IntPtr state = copyfile_state_alloc();

            try {
                CopyFileCallbackDelegate del = CopyFileCallback;
                copyfile_state_set(state, CopyFileState.StatusCB, Marshal.GetFunctionPointerForDelegate(del));
                return(copyfile(source, target, state, CopyFileFlags.Data | CopyFileFlags.Recursive | CopyFileFlags.Nofollow | CopyFileFlags.Clone));
            } finally {
                copyfile_state_free(state);
            }
        }
Beispiel #3
0
        public static void UpdateDirectory(string source, string target)
        {
            if (!Directory.Exists(target))
            {
                Directory.CreateDirectory(target);
            }

            // Mono's File.Copy can't handle symlinks (the symlinks are followed instead of copied),
            // so we need to use native functions directly. Luckily OSX provides exactly what we need.
            IntPtr state = copyfile_state_alloc();

            try {
                CopyFileCallbackDelegate del = CopyFileCallback;
                copyfile_state_set(state, CopyFileState.StatusCB, Marshal.GetFunctionPointerForDelegate(del));
                int rv = copyfile(source, target, state, CopyFileFlags.Data | CopyFileFlags.Recursive | CopyFileFlags.Nofollow);
                if (rv != 0)
                {
                    throw ErrorHelper.CreateError(1022, "Could not copy the directory '{0}' to '{1}': {2}", source, target, Target.strerror(Marshal.GetLastWin32Error()));
                }
            } finally {
                copyfile_state_free(state);
            }
        }