mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
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 svn path=/trunk/; revision=16493
This commit is contained in:
parent
dfcc16249d
commit
497eba8519
3 changed files with 33 additions and 130 deletions
|
@ -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__ */
|
|
@ -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 @@ static void read_directory_unix(Entry* dir, LPCTSTR path)
|
|||
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 @@ static void read_directory_unix(Entry* dir, LPCTSTR path)
|
|||
const char* cpath = path;
|
||||
#endif
|
||||
|
||||
pdir = call_opendir(cpath);
|
||||
|
||||
int level = dir->level + 1;
|
||||
pdir = opendir(cpath);
|
||||
|
||||
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 @@ static void read_directory_unix(Entry* dir, LPCTSTR path)
|
|||
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 @@ static void read_directory_unix(Entry* dir, LPCTSTR path)
|
|||
|
||||
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
|
||||
|
||||
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;
|
||||
|
||||
memset(&entry->data.ftCreationTime, 0, sizeof(FILETIME));
|
||||
time_to_filetime(&atime, &entry->data.ftLastAccessTime);
|
||||
time_to_filetime(&mtime, &entry->data.ftLastWriteTime);
|
||||
entry->data.nFileSizeLow = st.st_size & 0xFFFFFFFF;
|
||||
entry->data.nFileSizeHigh = st.st_size >> 32;
|
||||
|
||||
entry->bhfi.nFileIndexLow = inode;
|
||||
memset(&entry->data.ftCreationTime, 0, sizeof(FILETIME));
|
||||
time_to_filetime(&st.st_atime, &entry->data.ftLastAccessTime);
|
||||
time_to_filetime(&st.st_mtime, &entry->data.ftLastWriteTime);
|
||||
|
||||
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 @@ static void read_directory_unix(Entry* dir, LPCTSTR path)
|
|||
if (last)
|
||||
last->next = NULL;
|
||||
|
||||
call_closedir(pdir);
|
||||
closedir(pdir);
|
||||
}
|
||||
|
||||
dir->down = first_entry;
|
||||
|
@ -2348,10 +2353,10 @@ static LRESULT CALLBACK FrameWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM
|
|||
|
||||
|
||||
#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 @@ static BOOL pattern_match(LPCTSTR str, LPCTSTR pattern)
|
|||
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 @@ static int insert_entries(Pane* pane, Entry* dir, LPCTSTR pattern, int filter_fl
|
|||
|
||||
/* 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 @@ static void set_curdir(ChildWnd* child, Entry* entry, int idx, HWND hwnd)
|
|||
{
|
||||
TCHAR path[MAX_PATH];
|
||||
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
path[0] = '\0';
|
||||
|
||||
child->left.cur = entry;
|
||||
|
|
|
@ -163,21 +163,6 @@ extern void _splitpath(const CHAR* path, CHAR* drv, CHAR* dir, CHAR* name, CHAR*
|
|||
#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() */
|
||||
|
|
Loading…
Reference in a new issue