File indexing completed on 2024-05-12 04:51:05

0001 /*
0002     SPDX-FileCopyrightText: 1998-2007 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef _K3B_FILECOMPILATION_SIZE_HANDLER_H_
0007 #define _K3B_FILECOMPILATION_SIZE_HANDLER_H_
0008 
0009 #include "k3bmsf.h"
0010 #include <KIO/Global>
0011 
0012 namespace K3b {
0013     class DataItem;
0014 
0015     /**
0016      * This class maintains a map of indoes and the number
0017      * of files in the doc that belong to that inode.
0018      * This way a more accurate size calculation is possible
0019      *
0020      * It has to be noted that the sizes of the directories
0021      * are only locally true. That means that in some cases
0022      * the root directory of the project may show a much
0023      * higher size than calculated by this class.
0024      */
0025     class FileCompilationSizeHandler
0026     {
0027     public:
0028         FileCompilationSizeHandler();
0029         ~FileCompilationSizeHandler();
0030 
0031         /**
0032          * This does NOT equal blocks() * 2048.
0033          * This is the sum of the actual file sizes.
0034          */
0035         const KIO::filesize_t& size( bool followSymlinks = false ) const;
0036 
0037         /**
0038          * Number of blocks the files will occupy.
0039          */
0040         const Msf& blocks( bool followSymlinks = false ) const;
0041 
0042         /**
0043          * This will increase the counter for the inode of
0044          * the file in url and update the totel size.
0045          */
0046         void addFile( DataItem* );
0047 
0048         /**
0049          * This will decrease the counter for the inode of
0050          * the file in url and update the totel size.
0051          */
0052         void removeFile( DataItem* );
0053 
0054         void clear();
0055 
0056     private:
0057         class Private;
0058         Private* d_symlinks;
0059         Private* d_noSymlinks;
0060     };
0061 }
0062 
0063 #endif