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