Beispiel #1
0
 public static void QuickSort(FileInfo[] arr, int low, int high)
 {
     if (low <= high - 1)
     {
         int num = Attachments.Partition(arr, low, high);
         Attachments.QuickSort(arr, low, num - 1);
         Attachments.QuickSort(arr, num + 1, high);
     }
 }
Beispiel #2
0
 private static void DeleteCacheImageFile()
 {
     FileInfo[] files = new DirectoryInfo(Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/rotatethumbnail/")).GetFiles();
     if (files.Length > 100)
     {
         Attachments.QuickSort(files, 0, files.Length - 1);
         for (int i = files.Length - 1; i >= 50; i--)
         {
             try
             {
                 files[i].Delete();
             }
             catch
             {
             }
         }
     }
 }
Beispiel #3
0
        private static void CreateTopicAttThumbnail(string attPhyCachePath, ThumbnailType type, string attPhyPath, int theMaxsize)
        {
            if (!attPhyPath.StartsWith("http://"))
            {
                attPhyPath = Utils.GetMapPath(attPhyPath);
            }
            if (!attPhyPath.StartsWith("http://") && !File.Exists(attPhyPath))
            {
                return;
            }
            string mapPath = Utils.GetMapPath(BaseConfigs.GetForumPath + "cache/thumbnail/");

            if (!Directory.Exists(mapPath))
            {
                try
                {
                    Utils.CreateDir(mapPath);
                }
                catch
                {
                    throw new Exception("请检查程序目录下cache文件夹的用户权限!");
                }
            }
            FileInfo[] files = new DirectoryInfo(mapPath).GetFiles();
            if (files.Length > 1500)
            {
                Attachments.QuickSort(files, 0, files.Length - 1);
                for (int i = files.Length - 1; i >= 1400; i--)
                {
                    try
                    {
                        files[i].Delete();
                    }
                    catch
                    {
                    }
                }
            }
            try
            {
                switch (type)
                {
                case ThumbnailType.Square:
                    if (attPhyPath.StartsWith("http://"))
                    {
                        Thumbnail.MakeRemoteSquareImage(attPhyPath, attPhyCachePath, theMaxsize);
                    }
                    else
                    {
                        Thumbnail.MakeSquareImage(attPhyPath, attPhyCachePath, theMaxsize);
                    }
                    break;

                case ThumbnailType.Thumbnail:
                    if (attPhyPath.StartsWith("http://"))
                    {
                        Thumbnail.MakeRemoteThumbnailImage(attPhyPath, attPhyCachePath, theMaxsize, theMaxsize);
                    }
                    else
                    {
                        Thumbnail.MakeThumbnailImage(attPhyPath, attPhyCachePath, theMaxsize, theMaxsize);
                    }
                    break;

                default:
                    if (attPhyPath.StartsWith("http://"))
                    {
                        Thumbnail.MakeRemoteSquareImage(attPhyPath, attPhyCachePath, theMaxsize);
                    }
                    else
                    {
                        Thumbnail.MakeSquareImage(attPhyPath, attPhyCachePath, theMaxsize);
                    }
                    break;
                }
            }
            catch
            {
            }
        }