mirror of
https://github.com/reactos/reactos.git
synced 2024-09-09 12:20:21 +00:00
Removed hacks from findfirst/findnext APIs
See issue #1736 for more details. svn path=/trunk/; revision=27847
This commit is contained in:
parent
4473df2e66
commit
bf93eab031
|
@ -12,24 +12,10 @@ int
|
||||||
_tfindfirst(const _TCHAR* _name, struct _tfinddata_t* result)
|
_tfindfirst(const _TCHAR* _name, struct _tfinddata_t* result)
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATA FindFileData;
|
WIN32_FIND_DATA FindFileData;
|
||||||
_TCHAR dir[MAX_PATH];
|
|
||||||
long hFindFile;
|
long hFindFile;
|
||||||
int len = 0;
|
|
||||||
|
|
||||||
if (_name == NULL || _name[0] == 0) {
|
hFindFile = (long)FindFirstFile(_name, &FindFileData);
|
||||||
len = GetCurrentDirectory(MAX_PATH-4,dir);
|
|
||||||
if (dir[len-1] != '\\') {
|
|
||||||
dir[len] = '\\';
|
|
||||||
dir[len+1] = 0;
|
|
||||||
}
|
|
||||||
_tcscat(dir,_T("*.*"));
|
|
||||||
} else {
|
|
||||||
_tcscpy(dir,_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
hFindFile = (long)FindFirstFile(dir, &FindFileData);
|
|
||||||
if (hFindFile == -1) {
|
if (hFindFile == -1) {
|
||||||
memset(result,0,sizeof(struct _tfinddata_t));
|
|
||||||
_dosmaperr(GetLastError());
|
_dosmaperr(GetLastError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -41,14 +27,6 @@ _tfindfirst(const _TCHAR* _name, struct _tfinddata_t* result)
|
||||||
result->size = FindFileData.nFileSizeLow;
|
result->size = FindFileData.nFileSizeLow;
|
||||||
_tcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
|
_tcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
|
||||||
|
|
||||||
// if no wildcard the find file handle can be closed right away
|
|
||||||
// a return value of 0 can flag this.
|
|
||||||
|
|
||||||
if (!_tcschr(dir,'*') && !_tcschr(dir,'?')) {
|
|
||||||
_findclose(hFindFile);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hFindFile;
|
return hFindFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,10 +43,6 @@ int _tfindnext(
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATA FindFileData;
|
WIN32_FIND_DATA FindFileData;
|
||||||
|
|
||||||
// check no wildcards or invalid handle
|
|
||||||
if (handle == 0 || handle == -1)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!FindNextFile((void*)handle, &FindFileData)) {
|
if (!FindNextFile((void*)handle, &FindFileData)) {
|
||||||
_dosmaperr(GetLastError());
|
_dosmaperr(GetLastError());
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -91,27 +65,11 @@ int _tfindnext(
|
||||||
long _tfindfirsti64(const _TCHAR *_name, struct _tfinddatai64_t *result)
|
long _tfindfirsti64(const _TCHAR *_name, struct _tfinddatai64_t *result)
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATA FindFileData;
|
WIN32_FIND_DATA FindFileData;
|
||||||
_TCHAR dir[MAX_PATH];
|
|
||||||
long hFindFile;
|
long hFindFile;
|
||||||
int len = 0;
|
|
||||||
|
|
||||||
if ( _name == NULL || _name[0] == 0 )
|
hFindFile = (long)FindFirstFile(_name, &FindFileData);
|
||||||
{
|
|
||||||
len = GetCurrentDirectory(MAX_PATH-4,dir);
|
|
||||||
if (dir[len-1] != '\\')
|
|
||||||
{
|
|
||||||
dir[len] = '\\';
|
|
||||||
dir[len+1] = 0;
|
|
||||||
}
|
|
||||||
_tcscat(dir, _T("*.*"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
_tcscpy(dir, _name);
|
|
||||||
|
|
||||||
hFindFile = (long)FindFirstFile(dir, &FindFileData);
|
|
||||||
if (hFindFile == -1)
|
if (hFindFile == -1)
|
||||||
{
|
{
|
||||||
memset(result,0,sizeof(struct _tfinddatai64_t));
|
|
||||||
_dosmaperr(GetLastError());
|
_dosmaperr(GetLastError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -124,13 +82,6 @@ long _tfindfirsti64(const _TCHAR *_name, struct _tfinddatai64_t *result)
|
||||||
(((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
|
(((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
|
||||||
_tcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
|
_tcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
|
||||||
|
|
||||||
// if no wildcard the find file handle can be closed right away
|
|
||||||
// a return value of 0 can flag this.
|
|
||||||
|
|
||||||
if (!_tcschr(dir,'*') && !_tcschr(dir,'?')) {
|
|
||||||
_findclose(hFindFile);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return hFindFile;
|
return hFindFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,10 +96,6 @@ int _tfindnexti64(long handle, struct _tfinddatai64_t *result)
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATA FindFileData;
|
WIN32_FIND_DATA FindFileData;
|
||||||
|
|
||||||
// check no wildcards or invalid handle
|
|
||||||
if (handle == 0 || handle == -1)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (!FindNextFile((HANDLE)handle, &FindFileData)) {
|
if (!FindNextFile((HANDLE)handle, &FindFileData)) {
|
||||||
_dosmaperr(GetLastError());
|
_dosmaperr(GetLastError());
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -180,10 +127,12 @@ int _findclose(
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// check no wildcards or invalid handle
|
if (!FindClose((void*)handle)) {
|
||||||
if (handle == 0 || handle == -1)
|
_dosmaperr(GetLastError());
|
||||||
return 0;
|
return -1;
|
||||||
return FindClose((void*)handle);
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue