Beispiel #1
0
        public static void CopyDir(string srcDirName, string destDirName, CopyDirPreCopyDelegate preCopy, bool ignoreError, bool printStatus,
                                   bool skipIfNoChange, bool deleteBom, bool useTimeStampToCheckNoChange)
        {
            string[] files = Directory.GetFiles(srcDirName, "*", SearchOption.AllDirectories);

            foreach (string srcFile in files)
            {
                FileInfo info = new FileInfo(srcFile);

                string relativeFileName = IO.GetRelativeFileName(srcFile, srcDirName);
                string destFileName     = Path.Combine(destDirName, relativeFileName);
                string destFileDirName  = Path.GetDirectoryName(destFileName);

                if (preCopy != null)
                {
                    if (preCopy(info) == false)
                    {
                        continue;
                    }
                }

                try
                {
                    if (Directory.Exists(destFileDirName) == false)
                    {
                        Directory.CreateDirectory(destFileDirName);
                    }

                    FileCopy(srcFile, destFileName, skipIfNoChange, deleteBom, useTimeStampToCheckNoChange);
                }
                catch
                {
                    if (ignoreError == false)
                    {
                        throw;
                    }
                }

                if (printStatus)
                {
                    Con.WriteLine(relativeFileName);
                }
            }
        }
Beispiel #2
0
        public static byte[] PackDir(PackerFileFormat format, string topDirPath, string appendPrefixDirName, ProgressDelegate proc)
        {
            string[]      fileList         = Directory.GetFiles(topDirPath, "*", SearchOption.AllDirectories);
            List <string> relativeFileList = new List <string>();

            foreach (string fileName in fileList)
            {
                string relativePath = IO.GetRelativeFileName(fileName, topDirPath);

                if (Str.IsEmptyStr(appendPrefixDirName) == false)
                {
                    relativePath = IO.RemoteLastEnMark(appendPrefixDirName) + "\\" + relativePath;
                }

                relativeFileList.Add(relativePath);
            }

            return(PackFiles(format, fileList, relativeFileList.ToArray(), proc));
        }
Beispiel #3
0
        public void AddFile(string fileName, string baseDirFileName)
        {
            string name = IO.GetRelativeFileName(fileName, baseDirFileName);

            AddFile(name, File.ReadAllBytes(fileName));
        }
Beispiel #4
0
        public void AddFile(string fileName, string baseDirFileName, bool overwrite = false)
        {
            string name = IO.GetRelativeFileName(fileName, baseDirFileName);

            AddFile(name, File.ReadAllBytes(fileName), overwrite);
        }