Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sourceforge.pebble.domain
Class FileManager

    java.lang.Object
      net.sourceforge.pebble.domain.FileManager

    public class FileManager

extends java.lang.Object

Encapsulates methods for managing and manipulating files under the following locations:

- ${blog.dir}/images
- ${blog.dir}/files
- ${editableTheme}

Author:
  Simon Brown

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

### FileManager

    public FileManager(Blog blog,
                       java.lang.String type)

  Creates a new instande for the specified blog and type.

  Parameters:
    `blog` - the blog that this manager refers to
    `type` - the type of files to manage

Method Detail

### getRootDirectory

    public java.io.File getRootDirectory()

  Gets the root directory that this class is managing.

  Returns:
    a File instance

### getFileMetaData

    public FileMetaData getFileMetaData(java.lang.String path)

  Gets meta data about a specific file or directory.

  Parameters:
    `path` - the path of the file/directory
  Returns:
    a FileMetaData object

### getParent

    public FileMetaData getParent(FileMetaData file)

### getFileMetaData

    public FileMetaData getFileMetaData(java.lang.String path,
                                        java.lang.String name)

  Gets meta data about a specific file or directory.

  Parameters:
    `path` - the path of the file/directory
    `name` - the name of the file/directory
  Returns:
    a FileMetaData object

### getFile

    public 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.

  Parameters:
    `path` - an absolute path from the root
  Returns:
    a java.io.File instance

### isUnderneathRootDirectory

    public boolean isUnderneathRootDirectory(java.io.File file)

  Determines whether the specified file is underneath the root directory for this file manager.

  Parameters:
    `file` - the java.io.File to test
  Returns:
    true if the file is underneath the root, false otherwise

### createDirectory

    public java.io.File createDirectory(java.lang.String path,
                                        java.lang.String name)
                                 throws IllegalFileAccessException

  Creates a new directory with the specified name underneath the given path.

  Parameters:
    `path` - the path under which to create the directory
    `name` - the name of the directory
  Returns:
    a java.io.File instance representing the new directory
  Throws:
    `IllegalFileAccessException`

### copyFile

    public java.io.File copyFile(java.lang.String path,
                                 java.lang.String name,
                                 java.lang.String newName)
                          throws java.io.IOException,
                                 IllegalFileAccessException

  Copies a file.

  Parameters:
    `path` - the path under which the file exists
    `name` - the name of the file
    `newName` - the new name of the file
  Returns:
    a java.io.File instance representing the new file, or null if the file isn't copied because no new name was given, or the new name is the same as the old name
  Throws:
    `java.io.IOException`
    `IllegalFileAccessException`

### renameFile

    public java.io.File renameFile(java.lang.String path,
                                   java.lang.String name,
                                   java.lang.String newName)
                            throws IllegalFileAccessException

  Renames a file.

  Parameters:
    `path` - the path under which the file exists
    `name` - the name of the file
    `newName` - the new name of the file
  Returns:
    a java.io.File instance representing the new file, or null if the file isn't copied because no new name was given, or the new name is the same as the old name
  Throws:
    `IllegalFileAccessException`

### deleteFile

    public void deleteFile(java.lang.String path,
                           java.lang.String name)
                    throws IllegalFileAccessException

  Deletes a file.

  Parameters:
    `path` - the path under which the file exists
    `name` - the name of the file
  Throws:
    `IllegalFileAccessException`

### loadFile

    public java.lang.String loadFile(java.lang.String path,
                                     java.lang.String name)
                              throws IllegalFileAccessException

  Loads a file into a String.

  Parameters:
    `path` - the path under which the file exists
    `name` - the name of the file
  Returns:
    a String containing the content of the specified file
  Throws:
    `IllegalFileAccessException`

### saveFile

    public void saveFile(java.lang.String path,
                         java.lang.String name,
                         java.lang.String content)
                  throws java.io.IOException,
                         IllegalFileAccessException

  Saves a file with the given content.

  Parameters:
    `path` - the path under which the file exists
    `name` - the name of the file
    `content` - the content as a String
  Throws:
    `java.io.IOException`
    `IllegalFileAccessException`

### saveFile

    public FileMetaData saveFile(java.lang.String name,
                                 byte[] content)
                          throws java.io.IOException,
                                 IllegalFileAccessException

  Saves a file with the given binary content.

  Parameters:
    `name` - the name of the file
    `content` - the binary content
  Returns:
    a FileMetaData instance representing the saved file
  Throws:
    `java.io.IOException`
    `IllegalFileAccessException`

### getFiles

    public java.util.List getFiles(java.lang.String path)
                            throws IllegalFileAccessException

  Gets a list of files that reside under a given path.

  Parameters:
    `path` - the path under which the file exists
  Returns:
    a List of FileMetaData instances
  Throws:
    `IllegalFileAccessException` - if trying to access a file outside the root

### getFiles

    public java.util.List getFiles(java.lang.String path,
                                   boolean includeChildren)
                            throws IllegalFileAccessException

  Throws:
    `IllegalFileAccessException`

### getCurrentUsage

    public static double getCurrentUsage(Blog blog)

  Determines how much space is being used in files, images and theme.

  Parameters:
    `blog` - the blog to check against
  Returns:
    the number of KB

### hasEnoughSpace

    public static boolean hasEnoughSpace(Blog blog,
                                         double itemSize)

  Determines whether there is enough space to store the given number of KB.

  Parameters:
    `blog` - the blog to check against
    `itemSize` - the size of the item to be written
  Returns:
    true if there is enough space or quotas aren't active

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2006, Simon Brown. All Rights Reserved.