Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
a19bf290
Commit
a19bf290
authored
Mar 31, 2005
by
Hans Leidekker
Committed by
Alexandre Julliard
Mar 31, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement and test _chsize.
parent
313554f0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
9 deletions
+71
-9
file.c
dlls/msvcrt/file.c
+36
-9
file.c
dlls/msvcrt/tests/file.c
+35
-0
No files found.
dlls/msvcrt/file.c
View file @
a19bf290
...
...
@@ -525,15 +525,6 @@ int _wchmod(const MSVCRT_wchar_t *path, int flags)
}
/*********************************************************************
* _chsize (MSVCRT.@)
*/
int
_chsize
(
int
fd
,
long
size
)
{
FIXME
(
"(fd=%d, size=%ld): stub
\n
"
,
fd
,
size
);
return
-
1
;
}
/*********************************************************************
* _unlink (MSVCRT.@)
*/
int
_unlink
(
const
char
*
path
)
...
...
@@ -910,6 +901,42 @@ int MSVCRT_fseek(MSVCRT_FILE* file, long offset, int whence)
}
/*********************************************************************
* _chsize (MSVCRT.@)
*/
int
_chsize
(
int
fd
,
long
size
)
{
LONG
cur
,
pos
;
HANDLE
handle
;
BOOL
ret
=
FALSE
;
TRACE
(
"(fd=%d, size=%ld)
\n
"
,
fd
,
size
);
LOCK_FILES
();
handle
=
msvcrt_fdtoh
(
fd
);
if
(
handle
!=
INVALID_HANDLE_VALUE
)
{
/* save the current file pointer */
cur
=
_lseek
(
fd
,
0
,
SEEK_CUR
);
if
(
cur
>=
0
)
{
pos
=
_lseek
(
fd
,
size
,
SEEK_SET
);
if
(
pos
>=
0
)
{
ret
=
SetEndOfFile
(
handle
);
if
(
!
ret
)
msvcrt_set_errno
(
GetLastError
());
}
/* restore the file pointer */
_lseek
(
fd
,
cur
,
SEEK_SET
);
}
}
UNLOCK_FILES
();
return
ret
?
0
:
-
1
;
}
/*********************************************************************
* clearerr (MSVCRT.@)
*/
void
MSVCRT_clearerr
(
MSVCRT_FILE
*
file
)
...
...
dlls/msvcrt/tests/file.c
View file @
a19bf290
...
...
@@ -316,7 +316,41 @@ static void test_tmpnam( void )
ok
(
res
[
strlen
(
res
)
-
1
]
!=
'.'
,
"second call - last character is a dot
\n
"
);
}
static
void
test_chsize
(
void
)
{
int
fd
;
long
cur
,
pos
,
count
;
char
temptext
[]
=
"012345678"
;
char
*
tempfile
=
_tempnam
(
"."
,
"tst"
);
ok
(
tempfile
!=
NULL
,
"Couldn't create test file: %s
\n
"
,
tempfile
);
fd
=
_open
(
tempfile
,
_O_CREAT
|
_O_TRUNC
|
_O_RDWR
,
_S_IREAD
|
_S_IWRITE
);
ok
(
fd
>
0
,
"Couldn't open test file
\n
"
);
count
=
_write
(
fd
,
temptext
,
sizeof
(
temptext
)
);
ok
(
count
>
0
,
"Couldn't write to test file
\n
"
);
/* get current file pointer */
cur
=
_lseek
(
fd
,
0
,
SEEK_CUR
);
/* make the file smaller */
ok
(
_chsize
(
fd
,
sizeof
(
temptext
)
/
2
)
==
0
,
"_chsize() failed
\n
"
);
pos
=
_lseek
(
fd
,
0
,
SEEK_CUR
);
ok
(
cur
==
pos
,
"File pointer changed from: %ld to: %ld
\n
"
,
cur
,
pos
);
ok
(
_filelength
(
fd
)
==
sizeof
(
temptext
)
/
2
,
"Wrong file size
\n
"
);
/* enlarge the file */
ok
(
_chsize
(
fd
,
sizeof
(
temptext
)
*
2
)
==
0
,
"_chsize() failed
\n
"
);
pos
=
_lseek
(
fd
,
0
,
SEEK_CUR
);
ok
(
cur
==
pos
,
"File pointer changed from: %ld to: %ld
\n
"
,
cur
,
pos
);
ok
(
_filelength
(
fd
)
==
sizeof
(
temptext
)
*
2
,
"Wrong file size
\n
"
);
_close
(
fd
);
_unlink
(
tempfile
);
}
START_TEST
(
file
)
{
...
...
@@ -338,4 +372,5 @@ START_TEST(file)
test_file_write_read
();
test_file_inherit
(
arg_v
[
0
]);
test_tmpnam
();
test_chsize
();
}
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