Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
7e9b21aa
Commit
7e9b21aa
authored
Feb 27, 2015
by
Jeff Hostetler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix p_ftruncate to handle big files for git_clone
parent
fb2f3a76
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
4 deletions
+70
-4
src/win32/posix.h
+1
-1
src/win32/posix_w32.c
+21
-3
tests/core/ftruncate.c
+48
-0
No files found.
src/win32/posix.h
View file @
7e9b21aa
...
@@ -41,7 +41,7 @@ extern int p_chdir(const char* path);
...
@@ -41,7 +41,7 @@ extern int p_chdir(const char* path);
extern
int
p_chmod
(
const
char
*
path
,
mode_t
mode
);
extern
int
p_chmod
(
const
char
*
path
,
mode_t
mode
);
extern
int
p_rmdir
(
const
char
*
path
);
extern
int
p_rmdir
(
const
char
*
path
);
extern
int
p_access
(
const
char
*
path
,
mode_t
mode
);
extern
int
p_access
(
const
char
*
path
,
mode_t
mode
);
extern
int
p_ftruncate
(
int
fd
,
long
size
);
extern
int
p_ftruncate
(
int
fd
,
git_off_t
size
);
/* p_lstat is almost but not quite POSIX correct. Specifically, the use of
/* p_lstat is almost but not quite POSIX correct. Specifically, the use of
* ENOTDIR is wrong, in that it does not mean precisely that a non-directory
* ENOTDIR is wrong, in that it does not mean precisely that a non-directory
...
...
src/win32/posix_w32.c
View file @
7e9b21aa
...
@@ -42,12 +42,30 @@
...
@@ -42,12 +42,30 @@
/* GetFinalPathNameByHandleW signature */
/* GetFinalPathNameByHandleW signature */
typedef
DWORD
(
WINAPI
*
PFGetFinalPathNameByHandleW
)(
HANDLE
,
LPWSTR
,
DWORD
,
DWORD
);
typedef
DWORD
(
WINAPI
*
PFGetFinalPathNameByHandleW
)(
HANDLE
,
LPWSTR
,
DWORD
,
DWORD
);
int
p_ftruncate
(
int
fd
,
long
size
)
/**
* Truncate or extend file.
*
* We now take a "git_off_t" rather than "long" because
* files may be longer than 2Gb.
*/
int
p_ftruncate
(
int
fd
,
git_off_t
size
)
{
{
if
(
size
<
0
)
{
errno
=
EINVAL
;
return
-
1
;
}
#if defined(_MSC_VER) && _MSC_VER >= 1500
#if defined(_MSC_VER) && _MSC_VER >= 1500
return
_chsize_s
(
fd
,
size
);
return
((
_chsize_s
(
fd
,
size
)
==
0
)
?
0
:
-
1
);
#else
#else
return
_chsize
(
fd
,
size
);
/* TODO Find a replacement for _chsize() that handles big files.
* This comment is probably __MINGW32__ specific.
*/
if
(
size
>
INT32_MAX
)
{
errno
=
EFBIG
;
return
-
1
;
}
return
_chsize
(
fd
,
(
long
)
size
);
#endif
#endif
}
}
...
...
tests/core/ftruncate.c
0 → 100644
View file @
7e9b21aa
/**
* Some tests for p_ftruncate() to ensure that
* properly handles large (2Gb+) files.
*/
#include "clar_libgit2.h"
static
const
char
*
filename
=
"core_ftruncate.txt"
;
static
int
fd
=
-
1
;
void
test_core_ftruncate__initialize
(
void
)
{
if
(
!
cl_getenv
(
"GITTEST_INVASIVE_FS_SIZE"
))
cl_skip
();
cl_must_pass
((
fd
=
p_open
(
filename
,
O_CREAT
|
O_RDWR
,
0644
)));
}
void
test_core_ftruncate__cleanup
(
void
)
{
if
(
fd
<
0
)
return
;
p_close
(
fd
);
fd
=
0
;
p_unlink
(
filename
);
}
static
void
_extend
(
git_off_t
i64len
)
{
struct
stat
st
;
int
error
;
cl_assert
((
error
=
p_ftruncate
(
fd
,
i64len
))
==
0
);
cl_assert
((
error
=
p_fstat
(
fd
,
&
st
))
==
0
);
cl_assert
(
st
.
st_size
==
i64len
);
}
void
test_core_ftruncate__2gb
(
void
)
{
_extend
(
0x80000001
);
}
void
test_core_ftruncate__4gb
(
void
)
{
_extend
(
0x100000001
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment