summaryrefslogtreecommitdiffstats
path: root/vcs/cvsservice/cvsdir.h
blob: bd745d3e41ef8dfdb8c32da846a31fff9691aa90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/***************************************************************************
 *   Copyright (C) 2003 by Mario Scalas                                    *
 *   mario.scalas@libero.it                                                *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef CVSDIR_H
#define CVSDIR_H

#include <tqdir.h>
#include <tqstringlist.h>
#include <tqmap.h>

#include "cvsentry.h"

/**
Helper classes for handling CVS dirs

@author Mario Scalas
*/
class CVSDir : public QDir
{
public:
    CVSDir();
    CVSDir( const TQDir &dir );
    explicit CVSDir( const CVSDir & );
    CVSDir &operator=( const CVSDir & );
    virtual ~CVSDir();

    /**
    * A client can use this method to validate the directory state.
    * @return true if the directory is a valid CVS dir, false otherwise
    */
    bool isValid() const;
    /**
    * Returns a list of all the files registered into repository
    */
    TQStringList registeredEntryList() const;
    /**
    * @param fileName is the file name (with no path info, just the file name!)
    * @param refreshCache update internal cache re-parsing "<dirPath>/CVS/Entries"
    * @return an empty CVSEntry if the file is not present
    */
    CVSEntry fileStatus( const TQString &fileName, bool refreshCache = false ) const;
    /**
    */
    VCSFileInfoMap dirStatus() const;
    VCSFileInfoMap *cacheableDirStatus() const;
    /**
    * @return true if the file is registered into repository, false otherwise
    */
    bool isRegistered( const TQString fileName ) const;
    /**
    * Check if the specified @p fileName is in "<CVSDIR>/.cvsignore" and, if not,
    * append it.
    */
    void ignoreFile( const TQString &fileName );
    /**
    * Check if the specified @p fileName is in "<CVSDIR>/.cvsignore" and, if yes,
    * remove it.
    */
    void doNotIgnoreFile( const TQString &fileName );
    /**
    * @return the content of "<CVSDIR>/CVS/Repository"
    */
    TQString repository() const;
    /**
    * @return the content of "<CVSDIR>/CVS/Root"
    */
    TQString root() const;
    /**
    * @return full path of "<this-dir>/CVS/Entries"
    */
    TQString entriesFileName() const;
    /**
    * @return full path of "<this-dir>/CVS/Root"
    */
    TQString rootFileName() const;
    /**
    * @return full path of "<this-dir>/CVS/Repository"
    */
    TQString repoFileName() const;
    /**
    * @return full path of "<this-dir>/.cvsignore"
    */
    TQString cvsIgnoreFileName() const;

private:
    void refreshEntriesCache() const;
    static TQByteArray cacheFile( const TQString &fileName );

    TQString m_cvsDir;

    typedef TQMap<TQString,CVSEntry> CVSEntriesCacheMap;
    mutable CVSEntriesCacheMap m_cachedEntries;
};

#endif