19 package org.turro.elephant.impl.repository;
22 import java.io.FileFilter;
23 import java.io.FileInputStream;
24 import java.io.IOException;
25 import java.io.InputStream;
26 import java.io.InputStreamReader;
27 import java.text.DateFormat;
28 import java.util.Date;
29 import java.util.Properties;
31 import java.util.TreeSet;
32 import org.amic.util.date.DateFormats;
33 import org.amic.util.file.FileUtil;
34 import org.turro.formatter.BytesFormatter;
35 import org.turro.string.Strings;
36 import org.turro.elephant.context.ElephantContext;
37 import org.turro.elephant.context.IConstructor;
38 import org.turro.html.FontAwesome;
39 import org.turro.i18n.I_;
40 import org.turro.util.CompareUtil;
48 private final File file;
50 private Properties properties;
54 this.constructor = constructor;
58 return file.isDirectory() && file.list().length > 0;
66 return file.isDirectory();
70 return file.getName();
74 return file.getAbsolutePath().replace(
80 StringBuilder webPath =
new StringBuilder(
getWebPath());
81 webPath.insert(webPath.lastIndexOf(
"/"),
"/thumbs");
82 return webPath.toString();
86 return FontAwesome.getMimeIcon(FileUtil.getExtension(file));
93 return new BytesFormatter(file.length()).toString();
97 return DateFormats.format(
new Date(file.lastModified()),
98 DateFormat.SHORT,
I_.
api().used());
102 if(properties ==
null) {
103 properties =
new Properties();
104 File fprop =
new File(FileUtil.getBasePath(file) +
".properties");
106 try (InputStream is =
new FileInputStream(fprop)) {
108 }
catch (IOException ex) {
117 int result = CompareUtil.compare(file.isFile(), o.
getFile().isFile());
119 result = CompareUtil.compare(file.getName(), o.
getFile().getName());
125 File repository = file;
126 final String patterns[] = pattern.split(
",");
127 return repository.listFiles(
new FileFilter() {
129 public boolean accept(File pathname) {
130 if(pathname.isFile() && !pathname.isHidden()) {
131 for(String p : patterns) {
132 if(Strings.compareIgnoreCase(pathname.getName(), p)) {
143 File repository = file;
144 final String patterns[] = pattern.split(
",");
145 return repository.listFiles(
new FileFilter() {
147 public boolean accept(File pathname) {
148 if(pathname.isDirectory() && !pathname.isHidden()) {
149 for(String p : patterns) {
150 if(Strings.compareIgnoreCase(pathname.getName(), p)) {
162 TreeSet<RepositoryFile>
set =
new TreeSet<>();
164 for(File f : files) {
173 TreeSet<RepositoryFile>
set =
new TreeSet<>();
175 for(File f : files) {
static String getRealPath(String path)
static String getRootWebPath()
static String getEncoding()
int compareTo(RepositoryFile o)
Set< RepositoryFile > getRepositoryFiles(String pattern)
RepositoryFile(File file, IConstructor constructor)
File[] getFolders(String pattern)
File[] getFiles(String pattern)
Properties getProperties()
Set< RepositoryFile > getRepositoryFolders(String pattern)
static I18nApiWrapper api()