Author: weiden
Date: Thu Jul 26 19:07:07 2007
New Revision: 27847
URL:
http://svn.reactos.org/svn/reactos?rev=27847&view=rev
Log:
Removed hacks from findfirst/findnext APIs
See issue #1736 for more details.
Modified:
trunk/reactos/lib/sdk/crt/io/find.c
Modified: trunk/reactos/lib/sdk/crt/io/find.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/io/find.c?rev=…
==============================================================================
--- trunk/reactos/lib/sdk/crt/io/find.c (original)
+++ trunk/reactos/lib/sdk/crt/io/find.c Thu Jul 26 19:07:07 2007
@@ -12,24 +12,10 @@
_tfindfirst(const _TCHAR* _name, struct _tfinddata_t* result)
{
WIN32_FIND_DATA FindFileData;
- _TCHAR dir[MAX_PATH];
long hFindFile;
- int len = 0;
- if (_name == NULL || _name[0] == 0) {
- 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);
+ hFindFile = (long)FindFirstFile(_name, &FindFileData);
if (hFindFile == -1) {
- memset(result,0,sizeof(struct _tfinddata_t));
_dosmaperr(GetLastError());
return -1;
}
@@ -40,14 +26,6 @@
result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
result->size = FindFileData.nFileSizeLow;
_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;
}
@@ -64,10 +42,6 @@
struct _tfinddata_t* result)
{
WIN32_FIND_DATA FindFileData;
-
- // check no wildcards or invalid handle
- if (handle == 0 || handle == -1)
- return 0;
if (!FindNextFile((void*)handle, &FindFileData)) {
_dosmaperr(GetLastError());
@@ -91,27 +65,11 @@
long _tfindfirsti64(const _TCHAR *_name, struct _tfinddatai64_t *result)
{
WIN32_FIND_DATA FindFileData;
- _TCHAR dir[MAX_PATH];
long hFindFile;
- int len = 0;
- if ( _name == NULL || _name[0] == 0 )
- {
- 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);
+ hFindFile = (long)FindFirstFile(_name, &FindFileData);
if (hFindFile == -1)
{
- memset(result,0,sizeof(struct _tfinddatai64_t));
_dosmaperr(GetLastError());
return -1;
}
@@ -124,13 +82,6 @@
(((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
_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;
}
@@ -144,10 +95,6 @@
int _tfindnexti64(long handle, struct _tfinddatai64_t *result)
{
WIN32_FIND_DATA FindFileData;
-
- // check no wildcards or invalid handle
- if (handle == 0 || handle == -1)
- return 0;
if (!FindNextFile((HANDLE)handle, &FindFileData)) {
_dosmaperr(GetLastError());
@@ -180,10 +127,12 @@
#endif
)
{
- // check no wildcards or invalid handle
- if (handle == 0 || handle == -1)
- return 0;
- return FindClose((void*)handle);
+ if (!FindClose((void*)handle)) {
+ _dosmaperr(GetLastError());
+ return -1;
+ }
+
+ return 0;
}
#endif