File: MultiFiles.h

package info (click to toggle)
gcvs 1.0final-12
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 12,248 kB
  • ctags: 10,631
  • sloc: ansic: 71,709; cpp: 39,780; sh: 18,434; makefile: 1,915; yacc: 1,299; tcl: 1,283; perl: 910; lex: 249; csh: 185; lisp: 7
file content (131 lines) | stat: -rwxr-xr-x 2,822 bytes parent folder | download | duplicates (3)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
** 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 1, or (at your option)
** any later version.

** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.

** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
 * Author : Alexandre Parenteau <aubonbeurre@hotmail.com> --- December 1997
 */

/*
 * MultiFiles.h --- class to store multiple files by directory
 */

#ifndef MULTIFILES_H
#define MULTIFILES_H

#include "TextBinary.h"

#include "CPStr.h"
#include <vector>

#ifdef _MSC_VER
	using namespace std;
#endif

class CvsArgs;

// used internally
class FileEntry
{
public:
	FileEntry() {}

	FileEntry(const char *filename, const UFSSpec *macspec = 0L, const char *currRevision = 0L)
	{
		file = filename;

		if( currRevision != 0L )
			currRev = currRevision;

  		if( macspec != 0L )
			spec = *macspec;
	}

	FileEntry(const FileEntry & entry)
	{
		*this = entry;
	}

	FileEntry & operator=(const FileEntry & entry)
	{
		file = entry.file;
		currRev = entry.currRev;
		spec = entry.spec;
		return *this;
	}

	CStr file;
	CStr currRev;
	UFSSpec spec;
};

// used internally
class MultiFilesEntry
{
public:
	MultiFilesEntry() {}
	MultiFilesEntry(const char *path)
	{
		dir = path;
	}
	MultiFilesEntry(const MultiFilesEntry & entries)
	{
		*this = entries;
	}

	MultiFilesEntry & operator=(const MultiFilesEntry & entries)
	{
		dir = entries.dir;
		files = entries.files;
		return *this;
	}

	void setdir(const char *newdir);
	void add(const char *file, const UFSSpec *spec = 0L, const char *currRevision = 0L);

	CStr dir;
	std::vector<FileEntry> files;
};

class MultiFiles
{
public:
	MultiFiles() : pos(-1) {}

	void newdir(const char *dir);
		// add a new directory
	void newfile(const char *file, const UFSSpec *spec = 0L, const char *currRevision = 0L);
		// add a new file to the current directory

	inline void rewind(void) {pos = -1;}
		// rewind to first directory
	bool next(void);
		// return false if no more directories
	char *add (CvsArgs & args);
		// add the files to a CvsArgs, return the directory
	bool get (int index, CStr & path, CStr & fileName, CStr &currRev);
  		// return the file in the current directory (false if failed)

	int NumFiles(void) const;
		// number of files in the current dir

	void reset();
		// reset for reuse.
protected:
	int pos;
	std::vector<MultiFilesEntry> dirs;
};

#endif /* MULTIFILES_H */