|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.fckeditor.tool.UtilsFile
public class UtilsFile
Static helper methods for files.
| Field Summary | |
|---|---|
protected static Pattern |
ILLEGAL_CURRENT_FOLDER_PATTERN
|
| Constructor Summary | |
|---|---|
UtilsFile()
|
|
| Method Summary | |
|---|---|
static void |
checkDirAndCreate(File dir)
Checks a directory for existence and creates it if non-existent. |
static String |
forceSingleExtension(String filename)
Replaces all dots in a filename with underscores except the last one. |
static File |
getUniqueFile(File file)
Iterates over a base name and returns the first non-existent file. |
static boolean |
isImage(InputStream in)
Checks if the underlying input stream contains an image. |
static boolean |
isSingleExtension(String filename)
Checks if a filename contains more than one dot. |
static boolean |
isValidPath(String path)
Checks whether a path complies with the FCKeditor File Browser rules. |
static String |
sanitizeFileName(String filename)
Sanitizes a filename from certain chars. |
static String |
sanitizeFolderName(String folderName)
Sanitizes a folder name from certain chars. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final Pattern ILLEGAL_CURRENT_FOLDER_PATTERN
| Constructor Detail |
|---|
public UtilsFile()
| Method Detail |
|---|
public static String sanitizeFileName(String filename)
forceSingleExtension property and
then replaces all occurrences of \, /, |, :, ?, *, ", <, >,
control chars by _ (underscore).
filename - a potentially 'malicious' filename
public static String sanitizeFolderName(String folderName)
folderName - a potentially 'malicious' folder name
public static boolean isImage(InputStream in)
in - input stream of an image
true if the underlying input stream contains an
image, else falsepublic static boolean isValidPath(String path)
path - a potentially 'malicious' path
true if path complies with the rules, else
falsepublic static String forceSingleExtension(String filename)
filename - filename to sanitize
public static boolean isSingleExtension(String filename)
filename - filename to check
true if filename contains severals dots, else
falsepublic static void checkDirAndCreate(File dir)
dir - directory to check/createpublic static File getUniqueFile(File file)
basename(n).ext. Where n is a
positive integer starting from one.
file - base file
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||