--- trunk/reactos/subsys/system/winefile/winefile.c 2005-07-07 18:21:44 UTC (rev 16492)
+++ trunk/reactos/subsys/system/winefile/winefile.c 2005-07-07 18:44:08 UTC (rev 16493)
@@ -21,6 +21,11 @@
#ifdef __WINE__
#include "config.h"
#include "wine/port.h"
+
+/* for unix filesystem function calls */
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <dirent.h>
#endif
#include "winefile.h"
@@ -501,8 +506,9 @@
Entry* first_entry = NULL;
Entry* last = NULL;
Entry* entry;
- void* pdir;
+ DIR* pdir;
+ int level = dir->level + 1;
#ifdef UNICODE
char cpath[MAX_PATH];
@@ -511,17 +517,13 @@
const char* cpath = path;
#endif
- pdir = call_opendir(cpath);
+ pdir = opendir(cpath);
- int level = dir->level + 1;
-
if (pdir) {
- char buffer[MAX_PATH];
- time_t atime, mtime;
- unsigned inode;
- int is_dir;
+ struct stat st;
+ struct dirent* ent;
+ char buffer[MAX_PATH], *p;
const char* s;
- char* p;
for(p=buffer,s=cpath; *s; )
*p++ = *s++;
@@ -529,7 +531,7 @@
if (p==buffer || p[-1]!='/')
*p++ = '/';
- while(call_readdir(pdir, p, &inode)) {
+ while((ent=readdir(pdir))) {
entry = alloc_entry();
if (!first_entry)
@@ -540,28 +542,31 @@
entry->etype = ET_UNIX;
+ strcpy(p, ent->d_name);
#ifdef UNICODE
MultiByteToWideChar(CP_UNIXCP, 0, p, -1, entry->data.cFileName, MAX_PATH);
#else
lstrcpy(entry->data.cFileName, p);
#endif
- entry->data.dwFileAttributes = p[0]=='.'? FILE_ATTRIBUTE_HIDDEN: 0;
+ if (!stat(buffer, &st)) {
+ entry->data.dwFileAttributes = p[0]=='.'? FILE_ATTRIBUTE_HIDDEN: 0;
- if (!call_stat(buffer, &is_dir,
- &entry->data.nFileSizeLow, &entry->data.nFileSizeHigh,
- &atime, &mtime, &entry->bhfi.nNumberOfLinks))
- {
- if (is_dir)
+ if (S_ISDIR(st.st_mode))
entry->data.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
+ entry->data.nFileSizeLow = st.st_size & 0xFFFFFFFF;
+ entry->data.nFileSizeHigh = st.st_size >> 32;
+
memset(&entry->data.ftCreationTime, 0, sizeof(FILETIME));
- time_to_filetime(&atime, &entry->data.ftLastAccessTime);
- time_to_filetime(&mtime, &entry->data.ftLastWriteTime);
+ time_to_filetime(&st.st_atime, &entry->data.ftLastAccessTime);
+ time_to_filetime(&st.st_mtime, &entry->data.ftLastWriteTime);
- entry->bhfi.nFileIndexLow = inode;
+ entry->bhfi.nFileIndexLow = ent->d_ino;
entry->bhfi.nFileIndexHigh = 0;
+ entry->bhfi.nNumberOfLinks = st.st_nlink;
+
entry->bhfi_valid = TRUE;
} else {
entry->data.nFileSizeLow = 0;
@@ -581,7 +586,7 @@
if (last)
last->next = NULL;
- call_closedir(pdir);
+ closedir(pdir);
}
dir->down = first_entry;
@@ -2348,10 +2353,10 @@
#ifdef UNICODE
- call_getcwd(cpath, MAX_PATH);
+ getcwd(cpath, MAX_PATH);
MultiByteToWideChar(CP_UNIXCP, 0, cpath, -1, path, MAX_PATH);
#else
- call_getcwd(path, MAX_PATH);
+ getcwd(path, MAX_PATH);
#endif
child = alloc_child_window(path, NULL, hwnd);
@@ -2717,7 +2722,7 @@
return TRUE;
}
-static BOOL pattern_match_ncase(LPCTSTR str, LPCTSTR pattern)
+static BOOL pattern_imatch(LPCTSTR str, LPCTSTR pattern)
{
TCHAR b1[BUFFER_LEN], b2[BUFFER_LEN];
@@ -2773,7 +2778,7 @@
/* filter using the file name pattern */
if (pattern)
- if (!pattern_match_ncase(entry->data.cFileName, pattern))
+ if (!pattern_imatch(entry->data.cFileName, pattern))
continue;
/* filter system and hidden files */
@@ -3691,6 +3696,9 @@
{
TCHAR path[MAX_PATH];
+ if (!entry)
+ return;
+
path[0] = '\0';
child->left.cur = entry;