Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libardir/testar.c
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 2002-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* David Korn <[email protected]> *
19
* *
20
***********************************************************************/
21
#include <ast.h>
22
#include <ardir.h>
23
#include <error.h>
24
25
main(int argc, char** argv)
26
{
27
Ardir_t* dir;
28
Ardirent_t* ent;
29
long touch;
30
char* file;
31
32
touch = 0;
33
while (file = *++argv)
34
{
35
if (!strcmp(file, "-t") && *(argv + 1))
36
touch = strtol(*++argv, NiL, 0);
37
else if (dir = ardiropen(file, NiL, touch ? ARDIR_UPDATE : 0))
38
{
39
sfprintf(sfstdout, "%s: type=%s truncate=%d%s\n", file, dir->meth->name, dir->truncate, (dir->flags & ARDIR_RANLIB) ? " ranlib" : "");
40
while (ent = ardirnext(dir))
41
{
42
if (touch)
43
{
44
ent->mtime = touch;
45
ardirchange(dir, ent);
46
sfprintf(sfstdout, "touch %s\n", ent->name);
47
}
48
else
49
sfprintf(sfstdout, "%s %8u %8u %8llu %8llu %s %s\n", fmtmode(ent->mode, 1), ent->uid, ent->gid, ent->size, ent->offset, fmttime("%k", ent->mtime), ent->name);
50
}
51
if (ardirclose(dir))
52
error(2, "%s: archive read error", file);
53
}
54
else
55
error(ERROR_SYSTEM|2, "%s: not an archive", file);
56
}
57
return 0;
58
}
59
60