include/EDocBFD/BFDArchive.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 
00003    Copyright (C) 2007 Brendon Costa
00004 
00005    This code is free software; you can redistribute it and/or modify 
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 2, or (at your option)
00008    any later version.
00009 
00010    This code is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this code; see the file COPYING.  If not, write to
00017    the Free Software Foundation, 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
00019 
00020 *******************************************************************************/
00021 #ifndef EDOCBFD_BFDARCHIVE_H
00022 #define EDOCBFD_BFDARCHIVE_H
00023 
00024 #include "EDoc/ArchiveIFace.h"
00025 #include "EDoc/ManagedFile.h"
00026 #include "EDoc/ManagedFileCleanupIFace.h"
00027 
00028 #include <string>
00029 
00030 namespace EDocBFD
00031 {
00032    //===========================================================================
00033    /** \brief Used to cleanup when usage of an extracted BFD file is complete.
00034     *
00035     * This should perform operations such as cleaning up a temporary work 
00036     * file and merging the temporary files contents back into the BFD archive.
00037     */
00038    class ExtractedBFDFile : public EDoc::ManagedFileCleanupIFace
00039    {
00040    public:
00041 
00042       //------------------------------------------------------------------------
00043       /** \brief Create a instance that cleans up the the specified temporary 
00044        * file.
00045        *
00046        * This is used for when opening a BFD file for reading only as the 
00047        * resulting work file will not need to be re-merged back into the BFD.
00048        */
00049       ExtractedBFDFile(std::string temp_file_name_in);
00050 
00051       //------------------------------------------------------------------------
00052       /** \brief Create a instance that merges the temporary file back into 
00053        * the BFD before cleaning it up.
00054        *
00055        * This is used when a BFD file is being used for writing to.
00056        */
00057       ExtractedBFDFile(std::string bfd_file_name_in, 
00058          std::string temp_file_name_in,
00059          std::string embedded_file_name_in);
00060 
00061       //------------------------------------------------------------------------
00062       /** \brief Will perform cleanup upon destruction.
00063        */
00064       virtual ~ExtractedBFDFile();
00065       
00066       //------------------------------------------------------------------------
00067       /** \brief True if the contents of the temporary file needs to be 
00068        * merged back into bfd_file_name upon cleanup
00069        */
00070       bool sync;
00071 
00072       //------------------------------------------------------------------------
00073       /** \brief The name of the BFD archive from which this file was extracted.
00074        */
00075       std::string bfd_file_name;
00076 
00077       //------------------------------------------------------------------------
00078       /** \brief The name of the temporary file that represents this ManagedFile
00079        * object.
00080        */
00081       std::string temp_file_name;
00082 
00083       //------------------------------------------------------------------------
00084       /** \brief The internal name within the archive to use for writing this 
00085        * data back to the BFD archive.
00086        */
00087       std::string embedded_file_name;
00088 
00089       //------------------------------------------------------------------------
00090    };
00091 
00092    //===========================================================================
00093    /** \brief Factory for inserting/extracting files to/from the .edoc section 
00094     * of a binary file.
00095     *
00096     * This uses the GNU libbfd to read and write data to binary files such as 
00097     * executables, objects and libraries.
00098     */
00099    class BFDArchive : public EDoc::ArchiveIFace
00100    {
00101    public:
00102 
00103       //------------------------------------------------------------------------
00104       /** \brief Default constructor.
00105        */
00106       BFDArchive();
00107       
00108       //------------------------------------------------------------------------
00109       /** \brief See EDoc::ArchiveIFace::HandlesType()
00110        */
00111       virtual bool HandlesType(const EDoc::ManagedFile& arch_filename);
00112 
00113       //------------------------------------------------------------------------
00114       /** \brief See EDoc::ArchiveIFace::ReadExtractAll()
00115        */
00116       virtual std::list<EDoc::ManagedFile> ReadExtractAll(
00117          const EDoc::ManagedFile& arch_filename);
00118 
00119       //------------------------------------------------------------------------
00120       /** \brief See EDoc::ArchiveIFace::WriteOpen()
00121        */
00122       virtual EDoc::ManagedFile WriteOpen(const EDoc::ManagedFile& arch_filename, 
00123          std::string item_filename="default.edc");
00124 
00125       //------------------------------------------------------------------------
00126 
00127    };
00128    //===========================================================================
00129 }
00130 
00131 
00132 #endif // EDOCBFD_BFDARCHIVE_H

Generated on Tue Jan 20 18:26:07 2009 for EDoc-0.2.1 by  doxygen 1.5.1