vcs-svn: remove custom mode constants
[git/git.git] / vcs-svn / repo_tree.c
1 /*
2 * Licensed under a two-clause BSD-style license.
3 * See LICENSE for details.
4 */
5
6 #include "git-compat-util.h"
7 #include "strbuf.h"
8 #include "repo_tree.h"
9 #include "fast_export.h"
10
11 const char *svn_repo_read_path(const char *path, uint32_t *mode_out)
12 {
13 int err;
14 static struct strbuf buf = STRBUF_INIT;
15
16 strbuf_reset(&buf);
17 err = fast_export_ls(path, mode_out, &buf);
18 if (err) {
19 if (errno != ENOENT)
20 die_errno("BUG: unexpected fast_export_ls error");
21 /* Treat missing paths as directories. */
22 *mode_out = S_IFDIR;
23 return NULL;
24 }
25 return buf.buf;
26 }
27
28 void svn_repo_copy(uint32_t revision, const char *src, const char *dst)
29 {
30 int err;
31 uint32_t mode;
32 static struct strbuf data = STRBUF_INIT;
33
34 strbuf_reset(&data);
35 err = fast_export_ls_rev(revision, src, &mode, &data);
36 if (err) {
37 if (errno != ENOENT)
38 die_errno("BUG: unexpected fast_export_ls_rev error");
39 fast_export_delete(dst);
40 return;
41 }
42 fast_export_modify(dst, mode, data.buf);
43 }
44
45 void svn_repo_delete(const char *path)
46 {
47 fast_export_delete(path);
48 }