vendor/libgit2/src/fileops.c in rugged-0.26.7 vs vendor/libgit2/src/fileops.c in rugged-0.27.0
- old
+ new
@@ -2,12 +2,13 @@
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
-#include "common.h"
+
#include "fileops.h"
+
#include "global.h"
#include "strmap.h"
#include <ctype.h>
#if GIT_WIN32
#include "win32/findfile.h"
@@ -97,9 +98,19 @@
{
int fd = p_open(path, O_RDONLY);
if (fd < 0)
return git_path_set_error(errno, path, "open");
return fd;
+}
+
+int git_futils_truncate(const char *path, int mode)
+{
+ int fd = p_open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, mode);
+ if (fd < 0)
+ return git_path_set_error(errno, path, "open");
+
+ close(fd);
+ return 0;
}
git_off_t git_futils_filesize(git_file fd)
{
struct stat sb;