The Sleuth Kit Framework  4.1
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
TskFileManagerImpl Class Reference

An implementation of the TskFileManager interface that stores files in a directory named 'files' based on their file ids. More...

#include <TskFileManagerImpl.h>

Inheritance diagram for TskFileManagerImpl:
TskFileManager

Public Member Functions

virtual void addFile (const uint64_t fileId, std::istream &istr)
 Add a file to the system using the given file id and input stream. More...
 
virtual void addFile (const uint64_t fileId, std::wstring &filePath)
 Add a file to the system using the given file id and path. More...
 
virtual void copyDirectory (TskFile *directoryToCopy, const std::wstring &destinationPath, const bool bRecurse=false)
 Copy the contents of a directory to the given fully qualifed file path. More...
 
virtual void copyFile (TskFile *fileToSave, const std::wstring &filePath)
 Copy the file to the given fully qualifed file path. More...
 
virtual void deleteFile (TskFile *fileToDelete)
 Delete the local copy of a file. More...
 
virtual TskFileManager::FilePtrList findFilesByExtension (const std::vector< std::string > &extensions)
 Return a list of any TskFile objects matching the given filename extension. More...
 
virtual TskFileManager::FilePtrList findFilesByFsFileType (TSK_FS_META_TYPE_ENUM fsFileType)
 Return a list of any TskFile objects that match the given file meta type. More...
 
virtual TskFileManager::FilePtrList findFilesByName (const std::string &name, const TSK_FS_META_TYPE_ENUM fsFileType=TSK_FS_META_TYPE_UNDEF)
 Return a list of any TskFile objects matching the given filename. More...
 
virtual TskFileManager::FilePtrList findFilesByParent (const uint64_t parentFileId)
 Return a list of any TskFile objects that are children of the given file id. More...
 
virtual TskFileManager::FilePtrList findFilesByPattern (const std::string &namePattern, const std::string &pathPattern)
 Return a list of any TskFile objects that match the given file and path patterns. More...
 
virtual TskFilegetFile (const uint64_t fileId)
 Return a TskFile object for a given file ID. More...
 
virtual TskFileManager::FilePtrList getFiles (const std::vector< uint64_t > &fileIds)
 Return a list of TskFile objects mapped to the given list of file ids. More...
 
virtual std::wstring getPath (const uint64_t fileId)
 Return the fully qualified path to where the local instance of the file with the given ID should exist. More...
 
virtual void saveFile (TskFile *fileToSave)
 Save the file to the default location. More...
 
- Public Member Functions inherited from TskFileManager
virtual void copyDirectory (uint64_t directoryIdToCopy, const std::wstring &destinationPath, const bool bRecurse=false)
 Copy the contents of a directory to the given fully qualifed file path. More...
 
virtual void copyFile (const uint64_t fileId, const std::wstring &filePath)
 Copy the file to the given fully qualifed file path. More...
 
virtual void deleteFile (const uint64_t fileId)
 Delete the local copy of a file. More...
 
virtual void saveFile (const uint64_t fileId)
 Save the file to the default location. More...
 

Static Public Member Functions

static TskFileManagerImplinstance ()
 

Static Public Attributes

static const int FILE_BUFFER_SIZE = 8192
 
static const std::string FILES_DIRECTORY = "Files"
 
static const int FILES_PER_DIR = 1000
 

Additional Inherited Members

- Public Types inherited from TskFileManager
typedef TskFileFilePtr
 
typedef std::vector< FilePtrFilePtrList
 
- Protected Member Functions inherited from TskFileManager
 TskFileManager ()
 Default Constructor.
 
 TskFileManager (TskFileManager const &)
 Copy Constructor.
 
virtual ~TskFileManager ()
 Destructor.
 

Detailed Description

An implementation of the TskFileManager interface that stores files in a directory named 'files' based on their file ids.

Member Function Documentation

void TskFileManagerImpl::addFile ( const uint64_t  fileId,
std::istream &  istr 
)
virtual

Add a file to the system using the given file id and input stream.

This method saves a local copy of the content contained in the input stream.

Parameters
fileIdID of the new file.
istrInput stream containing the file content to save.
Exceptions
TskFileExceptionif a file with the given fileId already exists or if an error is encountered while saving the input stream.

Implements TskFileManager.

References TskFile::exists(), getFile(), getPath(), LOGERROR, and TskUtilities::toUTF8().

void TskFileManagerImpl::addFile ( const uint64_t  fileId,
std::wstring &  filePath 
)
virtual

Add a file to the system using the given file id and path.

This method saves a local copy of the file given in the path.

Parameters
fileIdID of the new file.
filePathThe path of the file to save.
Exceptions
TskFileExceptionif a file with the given fileId already exists, the file specified in filePath does not exist or an error is encountered while saving the file.

Implements TskFileManager.

References getPath(), LOGERROR, and TskUtilities::toUTF8().

void TskFileManagerImpl::copyDirectory ( TskFile directoryToCopy,
const std::wstring &  destinationPath,
const bool  bRecurse = false 
)
virtual

Copy the contents of a directory to the given fully qualifed file path.

Directories along the path will be created if they do not exist. If the destination directory exists it will be replaced. Defaults to a non-recursive copy.

Parameters
directoryToCopyThe TskFile object representing the directory to copy.
destinationPathThe path to save directory contents to, including the directory name.
bRecurseWhether to recursively copy directory contents.
Exceptions
variousexceptions on errors

Implements TskFileManager.

References copyFile(), TskFile::exists(), getFile(), TskFile::getId(), TskServices::getImgDB(), TskFile::getName(), TskFile::getPath(), TskServices::Instance(), TskFile::isDirectory(), TskUtilities::toUTF16(), and TskUtilities::toUTF8().

void TskFileManagerImpl::copyFile ( TskFile fileToSave,
const std::wstring &  filePath 
)
virtual

Copy the file to the given fully qualifed file path.

Directories along the path will be created if they do not exist. If the destination file exists it will be replaced.

Parameters
fileToSaveThe file to save.
filePathThe path to save to, including the file name.
Exceptions
variousexceptions on errors

Implements TskFileManager.

References TskFile::close(), TskFile::exists(), TskFile::getPath(), TskFile::isDirectory(), TskFile::open(), TskFile::read(), TskFile::seek(), TskFile::tell(), and TskUtilities::toUTF8().

Referenced by copyDirectory(), and saveFile().

void TskFileManagerImpl::deleteFile ( TskFile fileToDelete)
virtual

Delete the local copy of a file.

Parameters
fileToDeleteObject of file to delete local copy of
Exceptions
variousexceptions on errors

Implements TskFileManager.

References TskFile::exists(), TskFile::getPath(), and LOGERROR.

Referenced by TskFileAnalysisPipeline::run().

TskFileManager::FilePtrList TskFileManagerImpl::findFilesByExtension ( const std::vector< std::string > &  extensions)
virtual

Return a list of any TskFile objects matching the given filename extension.

Parameters
extensionsList of file name extension strings.
Returns
List of pointers to file objects. Caller must use AutoFilePtrList or manually free them.

Implements TskFileManager.

References getFiles(), TskServices::getImgDB(), and TskServices::Instance().

TskFileManager::FilePtrList TskFileManagerImpl::findFilesByFsFileType ( TSK_FS_META_TYPE_ENUM  fsFileType)
virtual

Return a list of any TskFile objects that match the given file meta type.

Parameters
fsFileTypeFile meta type.
Returns
List of pointers to file objects. Caller must use AutoFilePtrList or manually free them.

Implements TskFileManager.

References getFiles(), TskServices::getImgDB(), and TskServices::Instance().

TskFileManager::FilePtrList TskFileManagerImpl::findFilesByName ( const std::string &  name,
const TSK_FS_META_TYPE_ENUM  fsFileType = TSK_FS_META_TYPE_UNDEF 
)
virtual

Return a list of any TskFile objects matching the given filename.

Parameters
nameThe file name.
fsFileTypeOptional file meta type. Will not filter on meta_type if this is omitted.
Returns
List of pointers to file objects. Caller must use AutoFilePtrList or manually free them.

Implements TskFileManager.

References getFiles(), TskServices::getImgDB(), TskServices::Instance(), and TSK_FS_META_TYPE_UNDEF.

TskFileManager::FilePtrList TskFileManagerImpl::findFilesByParent ( const uint64_t  parentFileId)
virtual

Return a list of any TskFile objects that are children of the given file id.

Parameters
parentFileIdID of parent file.
Returns
List of pointers to file objects. Caller must use AutoFilePtrList or manually free them.

Implements TskFileManager.

References getFiles(), TskServices::getImgDB(), and TskServices::Instance().

TskFileManager::FilePtrList TskFileManagerImpl::findFilesByPattern ( const std::string &  namePattern,
const std::string &  pathPattern 
)
virtual

Return a list of any TskFile objects that match the given file and path patterns.

Parameters
namePatternFile name pattern. Can include "%" wildcards.
pathPatternFile path pattern. Can include "%" wildcards.
Returns
List of pointers to file objects. Caller must use AutoFilePtrList or manually free them.

Implements TskFileManager.

References getFiles(), TskServices::getImgDB(), TskServices::Instance(), and TSK_FS_META_TYPE_REG.

TskFile * TskFileManagerImpl::getFile ( const uint64_t  fileId)
virtual

Return a TskFile object for a given file ID.

Parameters
fileIdID of file to return object of.
Returns
Pointer to file object. Caller must free it.
Exceptions
TskExceptionin case of error.

Implements TskFileManager.

Referenced by addFile(), copyDirectory(), TskDBBlackboard::createGenInfoAttribute(), and getFiles().

TskFileManager::FilePtrList TskFileManagerImpl::getFiles ( const std::vector< uint64_t > &  fileIds)
virtual

Return a list of TskFile objects mapped to the given list of file ids.

Parameters
fileIdsList of fileId IDs.
Returns
List of pointers to file objects.

Implements TskFileManager.

References getFile().

Referenced by findFilesByExtension(), findFilesByFsFileType(), findFilesByName(), findFilesByParent(), and findFilesByPattern().

std::wstring TskFileManagerImpl::getPath ( const uint64_t  fileId)
virtual

Return the fully qualified path to where the local instance of the file with the given ID should exist.

This does not validate that the ID is for a file and does not validate that the file actually exists.

Parameters
fileIdId of the file.
Returns
Path to where local file should exist.

Implements TskFileManager.

References TskUtilities::toUTF16().

Referenced by addFile(), and saveFile().

void TskFileManagerImpl::saveFile ( TskFile fileToSave)
virtual

Save the file to the default location.

Parameters
fileToSaveFile object of the file to save.
Exceptions
variousexceptions on errors

Implements TskFileManager.

References copyFile(), TskFile::getId(), getPath(), TskFile::getTypeId(), and TskUtilities::toUTF8().

Referenced by TskFileAnalysisPipeline::run().


The documentation for this class was generated from the following files:

Copyright © 2011-2013 Brian Carrier. (carrier -at- sleuthkit -dot- org)
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.