summaryrefslogtreecommitdiff
path: root/src/fileops.c
diff options
context:
space:
mode:
authorRussell Belfer <arrbee@arrbee.com>2012-02-28 16:14:47 -0800
committerRussell Belfer <arrbee@arrbee.com>2012-03-02 15:49:29 -0800
commit74fa4bfae37e9d7c9e35550c881b114d7a83c4fa (patch)
tree98184643a8c42b1402e4b33f835eac424fe88768 /src/fileops.c
parent760db29c456ef2029a81d577d95a3fafb37ce5c6 (diff)
downloadlibgit2-74fa4bfae37e9d7c9e35550c881b114d7a83c4fa.tar.gz
Update diff to use iterators
This is a major reorganization of the diff code. This changes the diff functions to use the iterators for traversing the content. This allowed a lot of code to be simplified. Also, this moved the functions relating to outputting a diff into a new file (diff_output.c). This includes a number of other changes - adding utility functions, extending iterators, etc. plus more tests for the diff code. This also takes the example diff.c program much further in terms of emulating git-diff command line options.
Diffstat (limited to 'src/fileops.c')
-rw-r--r--src/fileops.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/fileops.c b/src/fileops.c
index d2b4af51e..6e45ff8a8 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -79,10 +79,6 @@ git_off_t git_futils_filesize(git_file fd)
return sb.st_size;
}
-#define GIT_MODE_PERMS_MASK 0777
-#define GIT_CANONICAL_PERMS(MODE) (((MODE) & 0100) ? 0755 : 0644)
-#define GIT_MODE_TYPE(MODE) ((MODE) & ~GIT_MODE_PERMS_MASK)
-
mode_t git_futils_canonical_mode(mode_t raw_mode)
{
if (S_ISREG(raw_mode))
@@ -181,6 +177,15 @@ int git_futils_mmap_ro(git_map *out, git_file fd, git_off_t begin, size_t len)
return p_mmap(out, len, GIT_PROT_READ, GIT_MAP_SHARED, fd, begin);
}
+int git_futils_mmap_ro_file(git_map *out, const char *path)
+{
+ git_file fd = p_open(path, O_RDONLY /* | O_NOATIME */);
+ size_t len = git_futils_filesize(fd);
+ int result = git_futils_mmap_ro(out, fd, 0, len);
+ p_close(fd);
+ return result;
+}
+
void git_futils_mmap_free(git_map *out)
{
p_munmap(out);