File: files.h

package info (click to toggle)
reprepro 4.2.0-2squeeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 4,016 kB
  • ctags: 3,674
  • sloc: ansic: 46,905; sh: 13,899; pascal: 160; makefile: 159; python: 138
file content (84 lines) | stat: -rw-r--r-- 3,376 bytes parent folder | download
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
#ifndef REPREPRO_FILES_H
#define REPREPRO_FILES_H

#ifndef REPREPRO_ERROR_H
#include "error.h"
#warning "What's hapening here?"
#endif
#ifndef REPREPRO_DATABASE_H
#include "database.h"
#endif
#ifndef REPREPRO_NAMES_H
#include "names.h"
#endif

struct checksums;
struct checksumsarray;

/* Add file's md5sum to database */
retvalue files_add_checksums(struct database *, const char *, const struct checksums *);

/* remove file's md5sum from database */
retvalue files_remove(struct database *, const char *filekey);
/* same but do not call pool_markremoved */
retvalue files_removesilent(struct database *, const char *filekey);

/* check for file in the database and if not found there in the pool */
retvalue files_expect(struct database *, const char *, const struct checksums *, bool warnifreadded);
/* same for multiple files */
retvalue files_expectfiles(struct database *, const struct strlist *, struct checksums **);

/* print missing files */
retvalue files_printmissing(struct database *, const struct strlist *filekeys, const struct checksumsarray *);

/* what to do with files */
/* file should already be there, just make sure it is in the database */
#define D_INPLACE      -1
/* copy the file to the given location, return RET_NOTHING, if already in place */
#define D_COPY 		0
/* move the file in place: */
#define D_MOVE 		1
/* move needed and delete unneeded files: */
#define D_DELETE	2

/* Include a given file into the pool
 * return RET_NOTHING, if a file with the same checksums is already there
 * return RET_OK, if copied and added
 * return RET_ERROR_MISSING, if there is no file to copy.
 * return RET_ERROR_WRONG_MD5 if wrong md5sum.
 *  (the original file is not deleted in that case, even if delete is positive)
 */
retvalue files_preinclude(struct database *, const char *sourcefilename, const char *filekey, /*@null@*//*@out@*/struct checksums **);
retvalue files_checkincludefile(struct database *, const char *directory, const char *sourcefilename, const char *filekey, struct checksums **);

typedef retvalue per_file_action(void *data, const char *filekey);

/* callback for each registered file */
retvalue files_foreach(struct database *,per_file_action action,void *data);

/* check if all files are corect. (skip md5sum if fast is true) */
retvalue files_checkpool(struct database *, bool fast);
/* calculate all missing hashes */
retvalue files_collectnewchecksums(struct database *);

/* dump out all information */
retvalue files_printmd5sums(struct database *);
retvalue files_printchecksums(struct database *);

/* look for the given filekey and add it into the filesdatabase */
retvalue files_detect(struct database *,const char *filekey);

retvalue files_regenerate_filelist(struct database *, bool redo);

/* hardlink file with known checksums and add it to database */
retvalue files_hardlinkandadd(struct database *, const char *tempfile, const char *filekey, const struct checksums *);

/* check if file is already there (RET_NOTHING) or could be added (RET_OK)
 * or RET_ERROR_WRONG_MD5SUM if filekey is already there with different md5sum */
retvalue files_canadd(struct database *, const char *filekey, const struct checksums *);

/* make a filekey to a fullfilename. return NULL if OutOfMemory */
static inline char *files_calcfullfilename(const char *filekey) {
	return calc_dirconcat(global.outdir, filekey);
}
#endif