Exemplo n.º 1
0
        protected override void MoveFileInternal(string source, string destination)
        {
            var sourceInfo = UnixFileSystemInfo.GetFileSystemEntry(source);

            if (sourceInfo.IsSymbolicLink)
            {
                var isSameDir   = UnixPath.GetDirectoryName(source) == UnixPath.GetDirectoryName(destination);
                var symlinkInfo = (UnixSymbolicLinkInfo)sourceInfo;
                var symlinkPath = symlinkInfo.ContentsPath;

                var newFile = new UnixSymbolicLinkInfo(destination);

                if (isSameDir)
                {
                    // We're in the same dir, so we can preserve relative symlinks.
                    newFile.CreateSymbolicLinkTo(symlinkInfo.ContentsPath);
                }
                else
                {
                    var fullPath = UnixPath.Combine(UnixPath.GetDirectoryName(source), symlinkPath);
                    newFile.CreateSymbolicLinkTo(fullPath);
                }

                try
                {
                    // Finally remove the original symlink.
                    symlinkInfo.Delete();
                }
                catch
                {
                    // Removing symlink failed, so rollback the new link and throw.
                    newFile.Delete();
                    throw;
                }
            }
            else if ((PlatformInfo.Platform == PlatformType.Mono && PlatformInfo.GetVersion() >= new Version(6, 0)) ||
                     PlatformInfo.Platform == PlatformType.NetCore)
            {
                TransferFilePatched(source, destination, false, true);
            }
            else
            {
                base.MoveFileInternal(source, destination);
            }
        }
Exemplo n.º 2
0
        public static void RemoveListenerSocket()
        {
            var socketPath = InternalSocketPath;

            Logger.Log.Info($"Deleting socket: {socketPath}");
            try
            {
                if (_SymLink != null)
                {
                    _SymLink.Delete();
                }
                File.Delete(socketPath);
                Logger.Log.Info("Socket deleted");
            }
            catch (Exception ex)
            {
                Logger.Log.Fatal($"Unable to delete socket, exception: {ex}");
                Environment.Exit(-1);
            }
        }
Exemplo n.º 3
0
        public void Analyze()
        {
            UnixSymbolicLinkInfo info = new UnixSymbolicLinkInfo(BifDatabasePath);

            if (info.Exists)
            {
                if (!info.IsSymbolicLink && File.Exists(BifLocalPath))
                {
                    info.Delete();

                    UnixFileInfo newInfo = new UnixFileInfo(BifLocalPath);
                    newInfo.CreateSymbolicLink(BifDatabasePath);
                }
                else if (!info.IsSymbolicLink)
                {
                    if (File.Exists(BifLocalPath))
                    {
                        File.Delete(BifLocalPath);
                    }

                    File.Move(BifDatabasePath, BifLocalPath);

                    UnixFileInfo newInfo = new UnixFileInfo(BifLocalPath);
                    newInfo.CreateSymbolicLink(BifDatabasePath);
                }
            }
            else
            {
                if (File.Exists(BifLocalPath))
                {
                    UnixFileInfo newInfo = new UnixFileInfo(BifLocalPath);
                    if (!Directory.Exists(IndexDirectory))
                    {
                        Directory.CreateDirectory(IndexDirectory);
                    }
                    newInfo.CreateSymbolicLink(BifDatabasePath);
                }
            }
        }