tools/elf4rom/src/outputfile.h
changeset 34 92d87f2e53c2
equal deleted inserted replaced
33:1af5c1be89f8 34:92d87f2e53c2
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 *
       
     5 * This program is free software: you can redistribute it and/or modify
       
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, either version 3 of the License, or
       
     8 * (at your option) any later version.
       
     9 *
       
    10 * This program is distributed in the hope that it will be useful,
       
    11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    13 * GNU Lesser General Public License for more details.
       
    14 * 
       
    15 * You should have received a copy of the GNU Lesser General Public License
       
    16 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
       
    17 */
       
    18 
       
    19 #ifndef OUTPUTFILE_H_
       
    20 #define OUTPUTFILE_H_
       
    21 
       
    22 #include <vector>
       
    23 
       
    24 #include "defs.h"
       
    25 #include "filefragment.h"
       
    26 
       
    27 // uncomment this is output file should be deleted on error
       
    28 //#define DELETE_OUTPUT_ON_ERROR
       
    29 // uncomment to use pwrite (this should be more efficient) but results in different
       
    30 // file pointer behaviour. NB not defined by MINGW in unistd.h 
       
    31 //#define USE_PWRITE
       
    32 
       
    33 // TODO: NB currently this can only deal with 4gb files. Need to upgrade for larger files
       
    34 class OutputFile
       
    35 {
       
    36 public:
       
    37 	OutputFile(PathName aFileName);
       
    38 	virtual ~OutputFile();
       
    39 
       
    40 	virtual void Close();
       
    41 	virtual void Flush();
       
    42 	virtual void Dump();
       
    43 	virtual const FileFragment & GetFileFragment(FileFragmentOwner * aOwner);
       
    44 	virtual void Open();
       
    45 	virtual void Write(size_t aOffset, size_t aSize, char * aData);
       
    46 	virtual size_t Size(){ return iCurrentOffset; }
       
    47 
       
    48 private:
       
    49 	// Don't want one of these to be copied
       
    50 	OutputFile(const OutputFile & aOutputFile);
       
    51 	
       
    52 	OutputFile & operator=(const OutputFile & aOutputFile);
       
    53 	
       
    54 private:
       
    55 	typedef std::vector<FileFragment> FragmentList;
       
    56 	
       
    57 	PathName iFileName;
       
    58 	FragmentList iFileFragments;
       
    59 	bool iOpened;
       
    60 	int iFd;
       
    61 	size_t iCurrentOffset;
       
    62 
       
    63 };
       
    64 
       
    65 #endif /*OUTPUTFILE_H_*/