コード例 #1
0
ファイル: NiceIO.cs プロジェクト: liszto/NiceIO
 public static IEnumerable<NPath> Move(this IEnumerable<NPath> self, NPath dest)
 {
     if (dest.IsRelative)
         throw new ArgumentException("When moving multiple files, the destination cannot be a relative path");
     dest.EnsureDirectoryExists();
     return self.Select(p => p.Move(dest.Combine(p.FileName))).ToArray();
 }
コード例 #2
0
ファイル: NiceIO.cs プロジェクト: mrvoorhe/NiceIO
 public static IEnumerable <NPath> Move(this IEnumerable <NPath> self, NPath dest)
 {
     if (dest.IsRelative)
     {
         throw new ArgumentException("When moving multiple files, the destination cannot be a relative path");
     }
     dest.EnsureDirectoryExists();
     return(self.Select(p => p.Move(dest.Combine(p.FileName))).ToArray());
 }
コード例 #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 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));
        }
コード例 #5
0
ファイル: NiceIO.cs プロジェクト: mrvoorhe/redox-extensions
 public IEnumerable<NPath> CopyFiles(NPath destination, bool recurse, Func<NPath, bool> fileFilter = null)
 {
     destination.EnsureDirectoryExists();
     return Files(recurse).Where(fileFilter ?? AlwaysTrue).Select(file => file.Copy(destination.Combine(file.RelativeTo(this)))).ToArray();
 }
コード例 #6
0
ファイル: NiceIO.cs プロジェクト: mrvoorhe/redox-extensions
        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());
        }
コード例 #7
0
ファイル: NiceIO.cs プロジェクト: mrvoorhe/redox-extensions
        NPath CopyWithDeterminedDestination(NPath absoluteDestination, Func<NPath,bool> fileFilter)
        {
            if (absoluteDestination.IsRelative)
                throw new ArgumentException ("absoluteDestination must be absolute");
            
            if (FileExists())
            {
                if (!fileFilter(absoluteDestination))
                    return null;

                absoluteDestination.EnsureParentDirectoryExists();

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

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

            throw new ArgumentException("Copy() called on path that doesnt exist: " + ToString());
        }
コード例 #8
0
ファイル: NiceIO.cs プロジェクト: mrvoorhe/redox-extensions
        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);
        }
コード例 #9
0
 public IEnumerable <NPath> CopyFiles(NPath destination, bool recurse, Func <NPath, bool> fileFilter = null)
 {
     destination.EnsureDirectoryExists();
     return(Files(recurse).Where(fileFilter ?? AlwaysTrue).Select(file => file.Copy(destination.Combine(file.RelativeTo(this)))).ToArray());
 }
コード例 #10
0
 public void Write(NPath outputDir)
 {
     string[] append = new string[] { "driver.cpp" };
     using (SourceCodeWriter writer = new SourceCodeWriter(outputDir.Combine(append)))
     {
         this.WriteIncludes(writer);
         this.WriteMainInvoker(writer);
         this.WriteEntryPoint(writer);
         this.WritePlatformSpecificEntryPoints(writer);
     }
 }