private static void analysisDeleteConfig(string[] lines, int line)
        {
            int flag = 0, index = 0, i = line;
            DeleteConfigInfo infor = new DeleteConfigInfo();

            for (; i < lines.Length; i++)
            {
                index = lines[i].IndexOf(":") + 1;
                if (lines[i].Length > 4 && index != -1)
                {
                    switch (lines[i].Substring(0, 2))
                    {
                    case "FP": infor.setPath(lines[i].Substring(index, lines[i].Length - index)); flag += 2; break;

                    case "SL": infor.setDeleteLimit(lines[i].Substring(index, lines[i].Length - index)); flag--; break;

                    default: break;
                    }
                }
                if (flag == 1)
                {
                    GlobleParams.configListAdd(infor);
                    infor = new DeleteConfigInfo();
                    flag  = 0;
                }
                else if (flag == -1)
                {
                    break;
                }
            }
        }
        /**
         * 清理指定目录下的多余文件
         * 描述:检查指定目录下文件是否过多,如果是
         *       则按照要求清理一定数量的最早创建的文件
         *       并返回本目录下清理文件的日志信息
         * */
        private static StringBuilder cleanUpExcessFilesInThePath(DeleteConfigInfo infor, int percent)
        {
            StringBuilder sb = new StringBuilder();
            //路径
            string path = infor.getPath();
            //删除界线
            int limit = infor.getDeleteLimit();
            //计算文件数量
            int count = countFile(path);

            //向日志字符串中加入开始前信息
            addStartInfor(sb, path, count, limit, percent);
            //检查文件是否过多,如果是则进行清理
            if (isOverLimit(count, limit))
            {
                cleanFiles(path, percent);
            }
            //向日志字符串中加入完成信息
            addEndInfor(sb, path, count, percent);
            return(sb);
        }
Пример #3
0
 public static void configListAdd(DeleteConfigInfo d)
 {
     configList.Add(d);
 }