Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

FragmentedFile.h

Go to the documentation of this file.
00001 //
00002 // FragmentedFile.h
00003 //
00004 // Copyright (c) Shareaza Development Team, 2002-2005.
00005 // This file is part of SHAREAZA (www.shareaza.com)
00006 //
00007 // Shareaza is free software; you can redistribute it
00008 // and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // Shareaza is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with Shareaza; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //
00021 
00022 #if !defined(AFX_FRAGMENTEDFILE_H__03EF9CB6_10EC_43A5_B6E0_D74B54044B51__INCLUDED_)
00023 #define AFX_FRAGMENTEDFILE_H__03EF9CB6_10EC_43A5_B6E0_D74B54044B51__INCLUDED_
00024 
00025 #pragma once
00026 
00027 #include "FileFragments.hpp"
00028 
00029 class CTransferFile;
00030 class CEDPartImporter;
00031 
00032 class CFragmentedFile
00033 {
00034 // Construction
00035 public:
00036         CFragmentedFile();
00037         virtual ~CFragmentedFile();
00038 
00039 // Attributes
00040 protected:
00041         CTransferFile*  m_pFile;
00042         QWORD                   m_nUnflushed;
00043 
00044 private:
00045     FF::SimpleFragmentList m_oFList;
00046         
00047 // Operations
00048 public:
00049         BOOL                    Create(LPCTSTR pszFile, QWORD nLength);
00050         BOOL                    Open(LPCTSTR pszFile);
00051         BOOL                    Flush();
00052         void                    Close();
00053         void                    Clear();
00054         BOOL                    MakeComplete();
00055         void                    Serialize(CArchive& ar, int nVersion);
00056 public:
00057         BOOL                    IsPositionRemaining(QWORD nOffset) const;
00058         BOOL                    DoesRangeOverlap(QWORD nOffset, QWORD nLength) const;
00059         QWORD                   GetRangeOverlap(QWORD nOffset, QWORD nLength) const;
00060         BOOL                    WriteRange(QWORD nOffset, LPCVOID pData, QWORD nLength);
00061         BOOL                    ReadRange(QWORD nOffset, LPVOID pData, QWORD nLength);
00062         QWORD                   InvalidateRange(QWORD nOffset, QWORD nLength);
00063         
00064 // Operations
00065 public:
00066         inline BOOL IsValid() const
00067         {
00068                 return m_oFList.limit() > 0; // && this != NULL
00069         }
00070         
00071         inline BOOL IsOpen() const
00072         {
00073                 return m_pFile != NULL;// && this != NULL
00074         }
00075 
00076         inline QWORD GetTotal() const
00077         {
00078                 return m_oFList.limit();
00079         }
00080         
00081         inline QWORD GetRemaining() const
00082         {
00083                 return m_oFList.sumLength();
00084         }
00085         
00086         inline QWORD GetCompleted() const
00087         {
00088                 return m_oFList.missing();
00089         }
00090         
00091     const FF::SimpleFragmentList& GetEmptyFragmentList() const
00092     {
00093         return m_oFList;
00094     }
00095         
00096         inline QWORD GetEmptyFragmentCount() const
00097         {
00098                 return m_oFList.size();
00099         }
00100         
00101         inline BOOL IsFlushNeeded() const
00102         {
00103                 return ( m_pFile != NULL ) && ( m_nUnflushed > 0 );
00104         }
00105 
00106         friend class CEDPartImporter;
00107 };
00108 
00109 
00110 #endif // !defined(AFX_FRAGMENTEDFILE_H__03EF9CB6_10EC_43A5_B6E0_D74B54044B51__INCLUDED_)

Generated on Thu Dec 15 10:39:42 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2