예제 #1
0
        public NPath Move(NPath dest)
        {
            ThrowIfRelative();
            if (dest.IsRelative)
            {
                return(Move(Parent.Combine(dest)));
            }

            if (dest.DirectoryExists())
            {
                return(Move(dest.Combine(FileName)));
            }

            if (FileExists())
            {
                dest.EnsureParentDirectoryExists();
                File.Move(ToString(), dest.ToString());
                return(dest);
            }

            if (DirectoryExists())
            {
                Directory.Move(ToString(), dest.ToString());
                return(dest);
            }

            throw new ArgumentException("Move() called on a path that doesn't exist: " + ToString());
        }
예제 #2
0
        public NPath Copy(NPath dest, Func <NPath, bool> fileFilter)
        {
            ThrowIfRelative();
            if (dest.IsRelative)
            {
                dest = Parent.Combine(dest);
            }

            if (dest.DirectoryExists())
            {
                return(CopyWithDeterminedDestination(dest.Combine(FileName), fileFilter));
            }

            return(CopyWithDeterminedDestination(dest, fileFilter));
        }
예제 #3
0
파일: NiceIO.cs 프로젝트: naruse/NiceIO
        public NPath Copy(NPath dest, Func <NPath, bool> fileFilter)
        {
            ThrowIfRelative();
            if (dest.IsRelative)
            {
                dest = Parent().Combine(dest);
            }

            if (dest.DirectoryExists())
            {
                return(Copy(dest.Combine(FileName), fileFilter));
            }

            if (FileExists())
            {
                if (!fileFilter(dest))
                {
                    return(null);
                }

                dest.EnsureParentDirectoryExists();

                File.Copy(ToString(), dest.ToString(), true);
                return(dest);
            }

            if (DirectoryExists())
            {
                dest.EnsureDirectoryExists();
                foreach (var thing in Contents())
                {
                    thing.Copy(dest.Combine(thing.RelativeTo(this)), fileFilter);
                }
                return(dest);
            }

            throw new ArgumentException("Copy() called on path that doesnt exist: " + ToString());
        }
예제 #4
0
        public NPath Move(NPath dest)
        {
            ThrowIfRelative();
            if (dest.IsRelative)
                return Move(Parent.Combine(dest));

            if (dest.DirectoryExists())
                return Move(dest.Combine(FileName));

            if (FileExists())
            {
                dest.EnsureParentDirectoryExists();
                File.Move(ToString(), dest.ToString());
                return dest;
            }

            if (DirectoryExists())
            {
                Directory.Move(ToString(), dest.ToString());
                return dest;
            }

            throw new ArgumentException("Move() called on a path that doesn't exist: " + ToString());
        }
예제 #5
0
        public NPath Copy(NPath dest, Func<NPath, bool> fileFilter)
        {
            ThrowIfRelative();
            if (dest.IsRelative)
                dest = Parent.Combine(dest);

            if (dest.DirectoryExists())
                return CopyWithDeterminedDestination(dest.Combine(FileName), fileFilter);

            return CopyWithDeterminedDestination (dest, fileFilter);
        }