| | |
| | | } |
| | | |
| | | File[] files = file.listFiles(); |
| | | if (files.length < SettingData.MAX_FILES) { |
| | | if (null == files || files.length < SettingData.MAX_FILES) { |
| | | return subPath; |
| | | } |
| | | |
| | |
| | | */ |
| | | public String getTempPath() { |
| | | String tempName = StringHelper.YMDHMS2_FORMAT.format(new Date()); |
| | | String tempPath = config.getTempPath(); |
| | | String path = tempPath + File.separator + tempName; |
| | | String path = config.getTempPath() + File.separator + tempName; |
| | | |
| | | File file = new File(path); |
| | | if (!file.exists() && !file.isDirectory()) { |
| | | file.mkdirs(); |
| | | } |
| | | |
| | | double ran = Math.random() * 99; |
| | | if (ran > D90) { |
| | | deleteOldPath(tempPath); |
| | | } |
| | | deleteOldPath(config.getTempPath()); |
| | | |
| | | return path; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | deleteOldPath(config.getTempPath()); |
| | | |
| | | return getTempPath(); |
| | | } |
| | | |
| | | /** |
| | | * 获取临时路径名称 |
| | | */ |
| | | public String getTempPathName() { |
| | | String tempName = StringHelper.YMDHMS2_FORMAT.format(new Date()); |
| | | String path = config.getTempPath() + File.separator + tempName; |
| | | |
| | | File file = new File(path); |
| | | if (!file.exists() && !file.isDirectory()) { |
| | | file.mkdirs(); |
| | | } |
| | | |
| | | deleteOldPath(config.getTempPath()); |
| | | |
| | | return tempName; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public void deleteOldPath(String tempPath) { |
| | | try { |
| | | double ran = Math.random() * 99; |
| | | if (ran < D90) { |
| | | return; |
| | | } |
| | | |
| | | File file = new File(tempPath); |
| | | String str = StringHelper.YMD__FORMAT.format(new Date()); |
| | | |
| | | File[] files = file.listFiles(); |
| | | for (File f : files) { |
| | | if (f.getPath().indexOf(str) > -1) { |
| | | if (f.getPath().contains(str)) { |
| | | continue; |
| | | } |
| | | |