|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.pebble.domain.FileManager
public class FileManager
Encapsulates methods for managing and manipulating files under the following locations:
Constructor Summary | |
---|---|
FileManager(Blog blog,
java.lang.String type)
Creates a new instande for the specified blog and type. |
Method Summary | |
---|---|
java.io.File |
copyFile(java.lang.String path,
java.lang.String name,
java.lang.String newName)
Copies a file. |
java.io.File |
createDirectory(java.lang.String path,
java.lang.String name)
Creates a new directory with the specified name underneath the given path. |
void |
deleteFile(java.lang.String path,
java.lang.String name)
Deletes a file. |
static double |
getCurrentUsage(Blog blog)
Determines how much space is being used in files, images and theme. |
java.io.File |
getFile(java.lang.String path)
Gets a java.io.File reference to the specified path, regardless of whether it represents a file or directory. |
FileMetaData |
getFileMetaData(java.lang.String path)
Gets meta data about a specific file or directory. |
FileMetaData |
getFileMetaData(java.lang.String path,
java.lang.String name)
Gets meta data about a specific file or directory. |
java.util.List |
getFiles(java.lang.String path)
Gets a list of files that reside under a given path. |
java.util.List |
getFiles(java.lang.String path,
boolean includeChildren)
|
FileMetaData |
getParent(FileMetaData file)
|
java.io.File |
getRootDirectory()
Gets the root directory that this class is managing. |
static boolean |
hasEnoughSpace(Blog blog,
double itemSize)
Determines whether there is enough space to store the given number of KB. |
boolean |
isUnderneathRootDirectory(java.io.File file)
Determines whether the specified file is underneath the root directory for this file manager. |
java.lang.String |
loadFile(java.lang.String path,
java.lang.String name)
Loads a file into a String. |
java.io.File |
renameFile(java.lang.String path,
java.lang.String name,
java.lang.String newName)
Renames a file. |
FileMetaData |
saveFile(java.lang.String name,
byte[] content)
Saves a file with the given binary content. |
void |
saveFile(java.lang.String path,
java.lang.String name,
java.lang.String content)
Saves a file with the given content. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileManager(Blog blog, java.lang.String type)
blog
- the blog that this manager refers totype
- the type of files to manageMethod Detail |
---|
public java.io.File getRootDirectory()
public FileMetaData getFileMetaData(java.lang.String path)
path
- the path of the file/directory
public FileMetaData getParent(FileMetaData file)
public FileMetaData getFileMetaData(java.lang.String path, java.lang.String name)
path
- the path of the file/directoryname
- the name of the file/directory
public java.io.File getFile(java.lang.String path)
path
- an absolute path from the root
public boolean isUnderneathRootDirectory(java.io.File file)
file
- the java.io.File to test
public java.io.File createDirectory(java.lang.String path, java.lang.String name) throws IllegalFileAccessException
path
- the path under which to create the directoryname
- the name of the directory
IllegalFileAccessException
public java.io.File copyFile(java.lang.String path, java.lang.String name, java.lang.String newName) throws java.io.IOException, IllegalFileAccessException
path
- the path under which the file existsname
- the name of the filenewName
- the new name of the file
java.io.IOException
IllegalFileAccessException
public java.io.File renameFile(java.lang.String path, java.lang.String name, java.lang.String newName) throws IllegalFileAccessException
path
- the path under which the file existsname
- the name of the filenewName
- the new name of the file
IllegalFileAccessException
public void deleteFile(java.lang.String path, java.lang.String name) throws IllegalFileAccessException
path
- the path under which the file existsname
- the name of the file
IllegalFileAccessException
public java.lang.String loadFile(java.lang.String path, java.lang.String name) throws IllegalFileAccessException
path
- the path under which the file existsname
- the name of the file
IllegalFileAccessException
public void saveFile(java.lang.String path, java.lang.String name, java.lang.String content) throws java.io.IOException, IllegalFileAccessException
path
- the path under which the file existsname
- the name of the filecontent
- the content as a String
java.io.IOException
IllegalFileAccessException
public FileMetaData saveFile(java.lang.String name, byte[] content) throws java.io.IOException, IllegalFileAccessException
name
- the name of the filecontent
- the binary content
java.io.IOException
IllegalFileAccessException
public java.util.List getFiles(java.lang.String path) throws IllegalFileAccessException
path
- the path under which the file exists
IllegalFileAccessException
- if trying to access a file outside the rootpublic java.util.List getFiles(java.lang.String path, boolean includeChildren) throws IllegalFileAccessException
IllegalFileAccessException
public static double getCurrentUsage(Blog blog)
blog
- the blog to check against
public static boolean hasEnoughSpace(Blog blog, double itemSize)
blog
- the blog to check againstitemSize
- the size of the item to be written
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |