1 /* archive-cache.c:
2  *
3  ****************************************************************
4  * Copyright (C) 2003 Tom Lord
5  *
6  * See the file "COPYING" for further information about
7  * the copyright and warranty status of this work.
8  */
9 
10 
11 #include "hackerlab/fs/file-names.h"
12 #include "hackerlab/vu/safe.h"
13 #include "tla/libfsutils/tmp-files.h"
14 #include "tla/libfsutils/rmrf.h"
15 #include "tla/libarch/build-revision.h"
16 #include "tla/libarch/archive-cache.h"
17 
18 
19 
20 void
arch_archive_cache(int chatter_fd,struct arch_archive * arch,const t_uchar * archive,const t_uchar * revision,const t_uchar * cache_dir)21 arch_archive_cache (int chatter_fd,
22                     struct arch_archive * arch,
23                     const t_uchar * archive,
24                     const t_uchar * revision,
25                     const t_uchar * cache_dir)
26 {
27   t_uchar * tmp_dir = 0;
28   t_uchar * pristine_dir = 0;
29 
30   tmp_dir = tmp_file_name (".", ",,archive-cache-revision");
31   pristine_dir = file_name_in_vicinity (0, tmp_dir, revision);
32 
33   safe_mkdir (tmp_dir, 0777);
34   safe_mkdir (pristine_dir, 0777);
35 
36   arch_build_revision (chatter_fd, pristine_dir, arch, archive, revision, cache_dir);
37 
38   {
39     t_uchar * errstr;
40 
41     if (arch_archive_put_cached (&errstr, arch, revision, pristine_dir))
42       {
43         safe_printfmt (2, "cacherev: unable to store cached revision of %s/%s (%s)\n", archive, revision, errstr);
44         exit (1);
45       }
46   }
47 
48   rmrf_file (tmp_dir);
49 
50   lim_free (0, tmp_dir);
51   lim_free (0, pristine_dir);
52 }
53 
54 
55 
56 
57 /* tag: Tom Lord Wed Jun 11 14:15:15 2003 (archive-cache.c)
58  */
59