コード例 #1
0
ファイル: FileManager.cs プロジェクト: Dahx/bns.spo
        public static void ProcessFileInfo(string parent, string x, MigrationSettigs d, LogCsvFile log)
        {
            try
            {
                string i        = "blank";
                string end_part = x.Substring(x.LastIndexOf("\\"));
                if (end_part.LastIndexOf(".") != -1)
                {
                    i = end_part.Substring(end_part.LastIndexOf("."));
                }

                if (x.Length < 260)
                {
                    FileInfo f = new FileInfo(x);
                    if (d.DoIncremental)
                    {
                        if (f.LastWriteTime < DateTime.Parse(d.LastDate))
                        {
                            log.WriteWarning("[excluded]: " + x);
                            return;
                        }
                    }
                    log.WriteToCVS(parent, x, i, f.Length.ToString(), LogManager.GetFileOwner(x), f.LastWriteTime.ToShortDateString());
                }
                else
                {
                    log.WriteWarning("[invalid_length]: " + x);
                }
            }
            catch (Exception ex)
            {
                log.WriteError("[" + x + "]:" + ex.Message);
            }
        }
コード例 #2
0
ファイル: FileManager.cs プロジェクト: Dahx/bns.spo
        private static long DirSize(string sourceDir, bool recurse, MigrationSettigs d, LogCsvFile log)
        {
            long size = 0;

            string[] fileEntries = Directory.GetFiles(sourceDir);

            foreach (string fileName in fileEntries)
            {
                if (fileName.Length < 256)
                {
                    Interlocked.Add(ref size, (new FileInfo(fileName)).Length);
                }
                else
                {
                    log.WriteWarning("[invalid length] :" + fileName);
                }
            }

            if (recurse)
            {
                string[] subdirEntries = Directory.GetDirectories(sourceDir);

                Parallel.For <long>(0, subdirEntries.Length, () => 0, (i, loop, subtotal) =>
                {
                    if (subdirEntries[i].Length < 256)
                    {
                        if ((File.GetAttributes(subdirEntries[i]) & FileAttributes.ReparsePoint) != FileAttributes.ReparsePoint)
                        {
                            subtotal += DirSize(subdirEntries[i], true, d, log);
                            return(subtotal);
                        }
                    }
                    else
                    {
                        log.WriteWarning("[invalid length] :" + subdirEntries[i]);
                    }
                    return(0);
                },
                                    (x) => Interlocked.Add(ref size, x)
                                    );
            }
            return(size);
        }
コード例 #3
0
ファイル: FileManager.cs プロジェクト: Dahx/bns.spo
        public static void ProcessDeleteXlsxFiles(string parent, string x, MigrationSettigs d, LogCsvFile log)
        {
            if (x.Length < 260)
            {
                FileInfo file = new FileInfo(x);
                if (file.Extension == "xlsx")
                {
                    file.Delete();
                }

                log.WriteInfo("[deleting]: " + x);
                log.WriteToCVS(parent, x, "deleted");
            }
            else
            {
                if (x.EndsWith(".xlsx"))
                {
                    File.Delete(x);
                }

                log.WriteWarning("[invalid_length]: " + x);
                log.WriteToCVS(parent, x, "invalid url");
            }
        }