Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
33854afb
Commit
33854afb
authored
Sep 16, 2003
by
Alex Pasadyn
Committed by
Alexandre Julliard
Sep 16, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Use HeapAlloc instead of GlobalAlloc in FindNextFile.
- Add test for FindNextFile that checks last error value.
parent
d4f13811
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
22 deletions
+37
-22
file.c
dlls/kernel/tests/file.c
+18
-0
dos_fs.c
files/dos_fs.c
+19
-22
No files found.
dlls/kernel/tests/file.c
View file @
33854afb
...
...
@@ -918,6 +918,23 @@ void test_FindFirstFileA()
ok
(
FindClose
(
handle
)
==
TRUE
,
"Failed to close handle"
);
}
void
test_FindNextFileA
()
{
HANDLE
handle
;
WIN32_FIND_DATAA
search_results
;
int
err
;
handle
=
FindFirstFileA
(
"C:
\\
*"
,
&
search_results
);
ok
(
handle
!=
INVALID_HANDLE_VALUE
,
"FindFirstFile on C:
\\
* should succeed"
);
while
(
FindNextFile
(
handle
,
&
search_results
))
{
/* get to the end of the files */
}
ok
(
FindClose
(
handle
)
==
TRUE
,
"Failed to close handle"
);
err
=
GetLastError
();
ok
(
err
==
ERROR_NO_MORE_FILES
,
"GetLastError should return ERROR_NO_MORE_FILES"
);
}
START_TEST
(
file
)
{
test__hread
(
);
...
...
@@ -935,6 +952,7 @@ START_TEST(file)
test_DeleteFileA
();
test_DeleteFileW
();
test_FindFirstFileA
();
test_FindNextFileA
();
test_LockFile
();
test_offset_in_overlapped_structure
();
}
files/dos_fs.c
View file @
33854afb
...
...
@@ -147,6 +147,7 @@ typedef struct
BYTE
attr
;
int
drive
;
int
cur_pos
;
CRITICAL_SECTION
cs
;
union
{
DOS_DIR
*
dos_dir
;
...
...
@@ -1995,7 +1996,6 @@ HANDLE WINAPI FindFirstFileExW(
LPVOID
lpSearchFilter
,
DWORD
dwAdditionalFlags
)
{
HGLOBAL
handle
;
FIND_FIRST_INFO
*
info
;
if
(
!
lpFileName
)
...
...
@@ -2023,20 +2023,15 @@ HANDLE WINAPI FindFirstFileExW(
if
(
lpFileName
[
0
]
==
'\\'
&&
lpFileName
[
1
]
==
'\\'
)
{
ERR
(
"UNC path name
\n
"
);
if
(
!
(
handle
=
GlobalAlloc
(
GMEM_MOVEABLE
,
sizeof
(
FIND_FIRST_INFO
))))
break
;
info
=
(
FIND_FIRST_INFO
*
)
GlobalLock
(
handle
);
if
(
!
(
info
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FIND_FIRST_INFO
))))
break
;
info
->
u
.
smb_dir
=
SMB_FindFirst
(
lpFileName
);
if
(
!
info
->
u
.
smb_dir
)
{
GlobalUnlock
(
handle
);
GlobalFree
(
handle
);
HeapFree
(
GetProcessHeap
(),
0
,
info
);
break
;
}
info
->
drive
=
-
1
;
GlobalUnlock
(
handle
);
RtlInitializeCriticalSection
(
&
info
->
cs
);
}
else
{
...
...
@@ -2053,8 +2048,8 @@ HANDLE WINAPI FindFirstFileExW(
}
}
if
(
!
DOSFS_GetFullName
(
lpFileName
,
FALSE
,
&
full_name
))
break
;
if
(
!
(
handle
=
GlobalAlloc
(
GMEM_MOVEABLE
,
sizeof
(
FIND_FIRST_INFO
))))
break
;
info
=
(
FIND_FIRST_INFO
*
)
GlobalLock
(
handle
);
if
(
!
(
info
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
FIND_FIRST_INFO
))))
break
;
RtlInitializeCriticalSection
(
&
info
->
cs
);
info
->
path
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
full_name
.
long_name
)
+
1
);
strcpy
(
info
->
path
,
full_name
.
long_name
);
...
...
@@ -2071,15 +2066,14 @@ HANDLE WINAPI FindFirstFileExW(
info
->
cur_pos
=
0
;
info
->
u
.
dos_dir
=
DOSFS_OpenDir
(
codepage
,
info
->
path
);
GlobalUnlock
(
handle
);
}
if
(
!
FindNextFileW
(
handle
,
data
))
if
(
!
FindNextFileW
(
(
HANDLE
)
info
,
data
))
{
FindClose
(
handle
);
FindClose
(
(
HANDLE
)
info
);
SetLastError
(
ERROR_FILE_NOT_FOUND
);
break
;
}
return
handle
;
return
(
HANDLE
)
info
;
}
break
;
default:
...
...
@@ -2163,12 +2157,13 @@ BOOL WINAPI FindNextFileW( HANDLE handle, WIN32_FIND_DATAW *data )
BOOL
ret
=
FALSE
;
DWORD
gle
=
ERROR_NO_MORE_FILES
;
if
((
handle
==
INVALID_HANDLE_VALUE
)
||
!
(
info
=
(
FIND_FIRST_INFO
*
)
GlobalLock
(
handle
)))
if
(
handle
==
INVALID_HANDLE_VALUE
)
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
ret
;
}
info
=
(
FIND_FIRST_INFO
*
)
handle
;
RtlEnterCriticalSection
(
&
info
->
cs
);
if
(
info
->
drive
==
-
1
)
{
ret
=
SMB_FindNext
(
info
->
u
.
smb_dir
,
data
);
...
...
@@ -2194,7 +2189,7 @@ BOOL WINAPI FindNextFileW( HANDLE handle, WIN32_FIND_DATAW *data )
}
ret
=
TRUE
;
done:
GlobalUnlock
(
handle
);
RtlLeaveCriticalSection
(
&
info
->
cs
);
if
(
!
ret
)
SetLastError
(
gle
);
return
ret
;
}
...
...
@@ -2226,13 +2221,14 @@ BOOL WINAPI FindNextFileA( HANDLE handle, WIN32_FIND_DATAA *data )
*/
BOOL
WINAPI
FindClose
(
HANDLE
handle
)
{
FIND_FIRST_INFO
*
info
;
FIND_FIRST_INFO
*
info
=
(
FIND_FIRST_INFO
*
)
handle
;
if
(
handle
==
INVALID_HANDLE_VALUE
)
goto
error
;
__TRY
{
if
((
info
=
(
FIND_FIRST_INFO
*
)
GlobalLock
(
handle
)))
RtlEnterCriticalSection
(
&
info
->
cs
);
if
(
info
)
{
if
(
info
->
u
.
dos_dir
)
DOSFS_CloseDir
(
info
->
u
.
dos_dir
);
if
(
info
->
path
)
HeapFree
(
GetProcessHeap
(),
0
,
info
->
path
);
...
...
@@ -2247,8 +2243,9 @@ BOOL WINAPI FindClose( HANDLE handle )
}
__ENDTRY
if
(
!
info
)
goto
error
;
GlobalUnlock
(
handle
);
GlobalFree
(
handle
);
RtlLeaveCriticalSection
(
&
info
->
cs
);
RtlDeleteCriticalSection
(
&
info
->
cs
);
HeapFree
(
GetProcessHeap
(),
0
,
info
);
return
TRUE
;
error:
...
...
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