Sync to Wine: - switch to UNICODE compilaton in Wine - remove separate unixcalls.c file - don't crash in set_curdir() for NULL in the 'entry' pointer Deleted: trunk/reactos/subsys/system/winefile/unixcalls.c Modified: trunk/reactos/subsys/system/winefile/winefile.c Modified: trunk/reactos/subsys/system/winefile/winefile.h _____
Deleted: trunk/reactos/subsys/system/winefile/unixcalls.c --- trunk/reactos/subsys/system/winefile/unixcalls.c 2005-07-07 18:21:44 UTC (rev 16492) +++ trunk/reactos/subsys/system/winefile/unixcalls.c 2005-07-07 18:44:08 UTC (rev 16493) @@ -1,90 +0,0 @@
-/* - * Winefile - * - * Copyright 2004 Martin Fuchs - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef __WINE__ - -#include <unistd.h> -#include <string.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <dirent.h> - - -void call_getcwd(char* buffer, size_t len) -{ - getcwd(buffer, len); -} - - -#ifndef _NO_EXTENSIONS - -/* proxy functions to call UNIX readdir() */ - -void* call_opendir(const char* path) -{ - DIR* pdir = opendir(path); - - return pdir; -} - -int call_readdir(void* pdir, char* name, unsigned* inode) -{ - struct dirent* ent = readdir((DIR*)pdir); - - if (!ent) - return 0; - - strcpy(name, ent->d_name); - *inode = ent->d_ino; - - return 1; -} - -void call_closedir(void* pdir) -{ - closedir((DIR*)pdir); -} - - -/* proxy function to call UNIX stat() */ -int call_stat( - const char* path, int* pis_dir, - unsigned long* psize_low, unsigned long* psize_high, - time_t* patime, time_t* pmtime, - unsigned long* plinks -) -{ - struct stat st; - - if (stat(path, &st)) - return 1; - - *pis_dir = S_ISDIR(st.st_mode); - *psize_low = st.st_size & 0xFFFFFFFF; - *psize_high = 0; /*st.st_size >> 32;*/ - *patime = st.st_atime; - *pmtime = st.st_mtime; - - return 0; -} - -#endif /* _NO_EXTENSIONS */ - -#endif /* __WINE__ */ _____
Modified: trunk/reactos/subsys/system/winefile/winefile.c --- 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; _____
Modified: trunk/reactos/subsys/system/winefile/winefile.h --- trunk/reactos/subsys/system/winefile/winefile.h 2005-07-07 18:21:44 UTC (rev 16492) +++ trunk/reactos/subsys/system/winefile/winefile.h 2005-07-07 18:44:08 UTC (rev 16493) @@ -163,21 +163,6 @@
#define _stprintf sprintf #endif
- -/* functions in unixcalls.c */ - -extern void call_getcwd(char* buffer, size_t len); -extern void* call_opendir(const char* path); -extern int call_readdir(void* pdir, char* name, unsigned* pinode); -extern void call_closedir(void* pdir); - -extern int call_stat( - const char* path, int* pis_dir, - unsigned long* psize_low, unsigned long* psize_high, - time_t* patime, time_t* pmtime, - unsigned long* plinks -); - #else
#include <tchar.h> /* for _tsplitpath() */