File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,16 @@ int git_futils_open_ro(const char *path)
102102 return fd ;
103103}
104104
105+ int git_futils_truncate (const char * path , int mode )
106+ {
107+ int fd = p_open (path , O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC , mode );
108+ if (fd < 0 )
109+ return git_path_set_error (errno , path , "open" );
110+
111+ close (fd );
112+ return 0 ;
113+ }
114+
105115git_off_t git_futils_filesize (git_file fd )
106116{
107117 struct stat sb ;
Original file line number Diff line number Diff line change @@ -247,6 +247,11 @@ extern int git_futils_cp_r(
247247 */
248248extern int git_futils_open_ro (const char * path );
249249
250+ /**
251+ * Truncate a file, creating it if it doesn't exist.
252+ */
253+ extern int git_futils_truncate (const char * path , int mode );
254+
250255/**
251256 * Get the filesize in bytes of a file
252257 */
You can’t perform that action at this time.
0 commit comments