mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
- Patched prsht.h bug reported by Jonathan Wilson.
- Applied MSVCRT_doserrno patch by Mark Weaver <mark@npsl.co.uk>. svn path=/trunk/; revision=6853
This commit is contained in:
parent
883794822c
commit
a27b1a9ef3
37 changed files with 217 additions and 93 deletions
|
@ -4920,6 +4920,7 @@ DECLARE_HANDLE(HANDLE);
|
|||
|
||||
#ifndef __USE_W32API
|
||||
|
||||
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
|
||||
|
||||
typedef enum _SC_STATUS_TYPE {
|
||||
SC_STATUS_PROCESS_INFO = 0
|
||||
|
|
|
@ -68,6 +68,7 @@ typedef struct __file_rec
|
|||
|
||||
extern __file_rec* __file_rec_list;
|
||||
|
||||
void _dosmaperr(unsigned long oserrcode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ typedef struct _PROPSHEETPAGEW {
|
|||
LPCWSTR pszHeaderSubTitle;
|
||||
#endif
|
||||
} PROPSHEETPAGEW,*LPPROPSHEETPAGEW;
|
||||
typedef const PROPSHEETPAGEA *LPCPROPSHEETPAGEW;
|
||||
typedef const PROPSHEETPAGEW *LPCPROPSHEETPAGEW;
|
||||
typedef UINT(CALLBACK *LPFNPSPCALLBACKA)(HWND,UINT,LPPROPSHEETPAGEA);
|
||||
typedef UINT(CALLBACK *LPFNPSPCALLBACKW)(HWND,UINT,LPPROPSHEETPAGEW);
|
||||
typedef int(CALLBACK *PFNPROPSHEETCALLBACK)(HWND,UINT,LPARAM);
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
#include <msvcrt/direct.h>
|
||||
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _chdir(const char* _path)
|
||||
{
|
||||
if (_path[1] == ':')
|
||||
_chdrive(tolower(_path[0] - 'a')+1);
|
||||
if (!SetCurrentDirectoryA((char*)_path))
|
||||
return -1;
|
||||
if (!SetCurrentDirectoryA((char*)_path)) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#include <msvcrt/ctype.h>
|
||||
#include <msvcrt/direct.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/errno.h>
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
|
||||
int cur_drive = 0;
|
||||
|
@ -14,14 +16,19 @@ int _chdrive(int drive)
|
|||
{
|
||||
char d[3];
|
||||
|
||||
if (!( drive >= 1 && drive <= 26))
|
||||
if (!( drive >= 1 && drive <= 26)) {
|
||||
__set_errno(EINVAL);
|
||||
return -1;
|
||||
}
|
||||
if (cur_drive != drive) {
|
||||
cur_drive = drive;
|
||||
d[0] = toupper(cur_drive + '@');
|
||||
d[1] = ':';
|
||||
d[2] = 0;
|
||||
SetCurrentDirectoryA(d);
|
||||
if (!SetCurrentDirectoryA(d)) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/direct.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/errno.h>
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
|
||||
/*
|
||||
|
@ -12,13 +14,17 @@ char *_getcwd(char* buffer, int maxlen)
|
|||
int len;
|
||||
|
||||
if (buffer == NULL) {
|
||||
cwd = malloc(MAX_PATH);
|
||||
if ( (cwd = malloc(MAX_PATH)) == NULL ) {
|
||||
__set_errno(ENOMEM);
|
||||
return NULL;
|
||||
}
|
||||
len = MAX_PATH;
|
||||
} else {
|
||||
cwd = buffer;
|
||||
len = maxlen;
|
||||
}
|
||||
if (GetCurrentDirectoryA(len, cwd) == 0) {
|
||||
_dosmaperr(GetLastError());
|
||||
return NULL;
|
||||
}
|
||||
return cwd;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/direct.h>
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
|
@ -11,12 +12,16 @@ char* _getdcwd(int nDrive, char* caBuffer, int nBufLen)
|
|||
|
||||
if (nDrive < 1 || nDrive > 26)
|
||||
return NULL;
|
||||
if (dr != nDrive)
|
||||
_chdrive(nDrive);
|
||||
if (dr != nDrive) {
|
||||
if ( _chdrive(nDrive) != 0 )
|
||||
return NULL;
|
||||
}
|
||||
i = GetCurrentDirectoryA(nBufLen, caBuffer);
|
||||
if (i == nBufLen)
|
||||
if (i == nBufLen)
|
||||
return NULL;
|
||||
if (dr != nDrive)
|
||||
_chdrive(dr);
|
||||
if (dr != nDrive) {
|
||||
if ( _chdrive(dr) != 0 )
|
||||
return NULL;
|
||||
}
|
||||
return caBuffer;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/direct.h>
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
|
||||
/*
|
||||
|
@ -7,7 +8,9 @@
|
|||
*/
|
||||
int _mkdir(const char* _path)
|
||||
{
|
||||
if (!CreateDirectoryA(_path, NULL))
|
||||
if (!CreateDirectoryA(_path, NULL)) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/direct.h>
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
|
||||
/*
|
||||
|
@ -7,7 +8,9 @@
|
|||
*/
|
||||
int _rmdir(const char* _path)
|
||||
{
|
||||
if (!RemoveDirectoryA(_path))
|
||||
if (!RemoveDirectoryA(_path)) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/ctype.h>
|
||||
#include <msvcrt/direct.h>
|
||||
|
||||
#include <msvcrt/internal/file.h>
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _wchdir (const wchar_t *_path)
|
||||
{
|
||||
if (_path[1] == L':')
|
||||
_chdrive(towlower(_path[0] - L'a')+1);
|
||||
if (!SetCurrentDirectoryW((wchar_t *)_path))
|
||||
if (!SetCurrentDirectoryW((wchar_t *)_path)) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/direct.h>
|
||||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/errno.h>
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
|
||||
/*
|
||||
|
@ -11,13 +13,16 @@ wchar_t* _wgetcwd(wchar_t* buffer, int maxlen)
|
|||
wchar_t *cwd;
|
||||
int len;
|
||||
if (buffer == NULL) {
|
||||
cwd = malloc(MAX_PATH * sizeof(wchar_t));
|
||||
if ( (cwd = malloc(MAX_PATH * sizeof(wchar_t))) == NULL ) {
|
||||
__set_errno(ENOMEM);
|
||||
return NULL;
|
||||
}
|
||||
len = MAX_PATH;
|
||||
} else {
|
||||
cwd = buffer;
|
||||
len = maxlen;
|
||||
}
|
||||
if (GetCurrentDirectoryW(len, cwd) == 0 )
|
||||
if (GetCurrentDirectoryW(len, cwd) == 0)
|
||||
return NULL;
|
||||
return cwd;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/direct.h>
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
|
||||
/*
|
||||
|
@ -13,15 +14,19 @@ wchar_t* _wgetdcwd(int nDrive, wchar_t* caBuffer, int nBufLen)
|
|||
if (nDrive < 1 || nDrive > 26)
|
||||
return NULL;
|
||||
|
||||
if (dr != nDrive)
|
||||
_chdrive(nDrive);
|
||||
if (dr != nDrive) {
|
||||
if ( _chdrive(nDrive) != 0 )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
i = GetCurrentDirectoryW(nBufLen, caBuffer);
|
||||
if (i == nBufLen)
|
||||
if (i == nBufLen)
|
||||
return NULL;
|
||||
|
||||
if (dr != nDrive)
|
||||
_chdrive(dr);
|
||||
if (dr != nDrive) {
|
||||
if ( _chdrive(dr) != 0 )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return caBuffer;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/direct.h>
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
|
||||
/*
|
||||
|
@ -7,7 +8,9 @@
|
|||
*/
|
||||
int _wmkdir(const wchar_t* _path)
|
||||
{
|
||||
if (!CreateDirectoryW(_path, NULL))
|
||||
if (!CreateDirectoryW(_path, NULL)) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/direct.h>
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _wrmdir(const wchar_t* _path)
|
||||
{
|
||||
if (!RemoveDirectoryW(_path))
|
||||
if (!RemoveDirectoryW(_path)) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@ int _access( const char *_path, int _amode )
|
|||
DWORD Attributes = GetFileAttributesA(_path);
|
||||
DPRINT("_access('%s', %x)\n", _path, _amode);
|
||||
|
||||
if (Attributes == -1) {
|
||||
__set_errno(ENOENT);
|
||||
if (Attributes == -1) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
if ((_amode & W_OK) == W_OK) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/io.h>
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <msvcrt/msvcrtdbg.h>
|
||||
|
@ -16,8 +17,10 @@ int _chmod(const char* filename, mode_t mode)
|
|||
DPRINT("_chmod('%s', %x)\n", filename, mode);
|
||||
|
||||
FileAttributes = GetFileAttributesA(filename);
|
||||
if ( FileAttributes == -1 )
|
||||
if ( FileAttributes == -1 ) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( mode == 0 )
|
||||
return -1;
|
||||
|
@ -29,8 +32,10 @@ int _chmod(const char* filename, mode_t mode)
|
|||
else
|
||||
FileAttributes &= FILE_ATTRIBUTE_NORMAL;
|
||||
|
||||
if (SetFileAttributesA(filename, FileAttributes) == FALSE)
|
||||
if (SetFileAttributesA(filename, FileAttributes) == FALSE) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* $Id: dup.c,v 1.5 2003/07/11 21:57:54 royce Exp $ */
|
||||
/* $Id: dup.c,v 1.6 2003/12/03 17:17:03 navaraf Exp $ */
|
||||
#include <windows.h>
|
||||
#include <msvcrt/io.h>
|
||||
#include <msvcrt/errno.h>
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
|
||||
|
@ -15,8 +16,10 @@ int _dup(int handle)
|
|||
int fd;
|
||||
|
||||
hFile = _get_osfhandle(handle);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return -1;
|
||||
if (hFile == INVALID_HANDLE_VALUE) {
|
||||
__set_errno(EBADF);
|
||||
return -1;
|
||||
}
|
||||
result = DuplicateHandle(hProcess,
|
||||
hFile,
|
||||
hProcess,
|
||||
|
@ -24,8 +27,10 @@ int _dup(int handle)
|
|||
0,
|
||||
TRUE,
|
||||
DUPLICATE_SAME_ACCESS);
|
||||
if (result == FALSE)
|
||||
return -1;
|
||||
if (result == FALSE) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
fd = __fileno_alloc(hFile, __fileno_getmode(handle));
|
||||
if (fd < 0)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/io.h>
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
|
||||
/*
|
||||
|
@ -7,5 +8,13 @@
|
|||
*/
|
||||
long _filelength(int _fd)
|
||||
{
|
||||
return GetFileSize(_get_osfhandle(_fd), NULL);
|
||||
DWORD len = GetFileSize(_get_osfhandle(_fd), NULL);
|
||||
if (len == INVALID_FILE_SIZE) {
|
||||
DWORD oserror = GetLastError();
|
||||
if (oserror != 0) {
|
||||
_dosmaperr(oserror);
|
||||
return -1L;
|
||||
}
|
||||
}
|
||||
return (long)len;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/io.h>
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
|
||||
/*
|
||||
|
@ -7,8 +8,15 @@
|
|||
*/
|
||||
__int64 _filelengthi64(int _fd)
|
||||
{
|
||||
long lo_length, hi_length;
|
||||
DWORD lo_length, hi_length;
|
||||
|
||||
lo_length = GetFileSize(_get_osfhandle(_fd), &hi_length);
|
||||
if (lo_length == INVALID_FILE_SIZE) {
|
||||
DWORD oserror = GetLastError();
|
||||
if (oserror != 0) {
|
||||
_dosmaperr(oserror);
|
||||
return (__int64)-1;
|
||||
}
|
||||
}
|
||||
return((((__int64)hi_length) << 32) + lo_length);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ int _findfirst(const char* _name, struct _finddata_t* result)
|
|||
hFindFile = (long)FindFirstFileA(dir, &FindFileData);
|
||||
if (hFindFile == -1) {
|
||||
memset(result,0,sizeof(struct _finddata_t));
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -71,8 +72,10 @@ int _findnext(int handle, struct _finddata_t* result)
|
|||
if (handle == 0 || handle == -1)
|
||||
return 0;
|
||||
|
||||
if (!FindNextFileA((void*)handle, &FindFileData))
|
||||
if (!FindNextFileA((void*)handle, &FindFileData)) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
result->attrib = FindFileData.dwFileAttributes;
|
||||
result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
#include <windows.h>
|
||||
#include <msvcrt/io.h>
|
||||
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _locking(int _fd, int mode, long nbytes)
|
||||
{
|
||||
long offset = _lseek(_fd, 0L, 1);
|
||||
if (!LockFile(_get_osfhandle(_fd),offset,0,nbytes,0))
|
||||
return -1;
|
||||
long offset = _lseek(_fd, 0L, 1);
|
||||
if (offset == -1L)
|
||||
return -1;
|
||||
if (!LockFile(_get_osfhandle(_fd),offset,0,nbytes,0)) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -8,5 +8,13 @@
|
|||
*/
|
||||
long _lseek(int _fildes, long _offset, int _whence)
|
||||
{
|
||||
return (SetFilePointer((HANDLE)filehnd(_fildes), _offset, NULL, _whence));
|
||||
DWORD newpos = SetFilePointer((HANDLE)filehnd(_fildes), _offset, NULL, _whence);
|
||||
if (newpos == INVALID_SET_FILE_POINTER) {
|
||||
DWORD oserror = GetLastError();
|
||||
if (oserror != 0) {
|
||||
_dosmaperr(oserror);
|
||||
return -1L;
|
||||
}
|
||||
}
|
||||
return newpos;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ __int64 _lseeki64(int _fildes, __int64 _offset, int _whence)
|
|||
// }
|
||||
if (SetFilePointerEx((HANDLE)filehnd(_fildes), offset, &new_pos, _whence)) {
|
||||
} else {
|
||||
//__set_errno ( EINVAL );
|
||||
_dosmaperr(error);
|
||||
return -1L;
|
||||
}
|
||||
return new_pos.QuadPart;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: open.c,v 1.16 2003/08/05 15:41:03 weiden Exp $
|
||||
/* $Id: open.c,v 1.17 2003/12/03 17:17:03 navaraf Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -105,7 +105,6 @@ int _open(const char* _path, int _oflag,...)
|
|||
DWORD dwShareMode = 0;
|
||||
DWORD dwCreationDistribution = 0;
|
||||
DWORD dwFlagsAndAttributes = 0;
|
||||
DWORD dwLastError;
|
||||
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
|
||||
|
||||
#if !defined(NDEBUG) && defined(DBG)
|
||||
|
@ -185,17 +184,10 @@ int _open(const char* _path, int _oflag,...)
|
|||
dwCreationDistribution,
|
||||
dwFlagsAndAttributes,
|
||||
NULL);
|
||||
if (hFile == (HANDLE)-1) {
|
||||
dwLastError = GetLastError();
|
||||
if (dwLastError == ERROR_ALREADY_EXISTS) {
|
||||
DPRINT("ERROR_ALREADY_EXISTS\n");
|
||||
__set_errno(EEXIST);
|
||||
} else {
|
||||
DPRINT("%x\n", dwLastError);
|
||||
__set_errno(ENOFILE);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
if (hFile == (HANDLE)-1) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
DPRINT("OK\n");
|
||||
if (!(_oflag & (_O_TEXT|_O_BINARY))) {
|
||||
_oflag |= _fmode;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: pipe.c,v 1.6 2003/07/11 21:57:54 royce Exp $
|
||||
/* $Id: pipe.c,v 1.7 2003/12/03 17:17:03 navaraf Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -25,8 +25,10 @@ int _pipe(int _fildes[2], unsigned int size, int mode )
|
|||
if (mode & O_NOINHERIT)
|
||||
sa.bInheritHandle = FALSE;
|
||||
|
||||
if (!CreatePipe(&hReadPipe,&hWritePipe,&sa,size))
|
||||
return -1;
|
||||
if (!CreatePipe(&hReadPipe,&hWritePipe,&sa,size)) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((_fildes[0] = __fileno_alloc(hReadPipe, mode)) < 0)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: read.c,v 1.11 2003/07/11 21:57:54 royce Exp $
|
||||
/* $Id: read.c,v 1.12 2003/12/03 17:17:03 navaraf Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -46,6 +46,7 @@ size_t _read(int _fd, void *_buf, size_t _nbyte)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
_dosmaperr(error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
*/
|
||||
int _unlink(const char* filename)
|
||||
{
|
||||
int result = 0;
|
||||
DPRINT("_unlink('%s')\n", filename);
|
||||
if (!DeleteFileA(filename))
|
||||
result = -1;
|
||||
DPRINT("%d\n", result);
|
||||
return result;
|
||||
if (!DeleteFileA(filename)) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ int _waccess(const wchar_t *_path, int _amode)
|
|||
DWORD Attributes = GetFileAttributesW(_path);
|
||||
|
||||
if (Attributes == -1) {
|
||||
__set_errno(ENOENT);
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
if ((_amode & W_OK) == W_OK) {
|
||||
|
|
|
@ -16,8 +16,10 @@ int _wchmod(const wchar_t* filename, mode_t mode)
|
|||
DPRINT("_wchmod('%S', %x)\n", filename, mode);
|
||||
|
||||
FileAttributes = GetFileAttributesW(filename);
|
||||
if ( FileAttributes == -1 )
|
||||
if ( FileAttributes == -1 ) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( mode == 0 )
|
||||
return -1;
|
||||
|
@ -29,8 +31,10 @@ int _wchmod(const wchar_t* filename, mode_t mode)
|
|||
else
|
||||
FileAttributes &= FILE_ATTRIBUTE_NORMAL;
|
||||
|
||||
if (SetFileAttributesW(filename, FileAttributes) == FALSE)
|
||||
if (SetFileAttributesW(filename, FileAttributes) == FALSE) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ int _wfindfirst(const wchar_t* _name, struct _wfinddata_t* result)
|
|||
hFindFile = (long)FindFirstFileW(dir, &FindFileData);
|
||||
if (hFindFile == -1) {
|
||||
memset(result,0,sizeof(struct _wfinddata_t));
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -75,6 +76,7 @@ int _findfirsti64(const char *_name, struct _finddatai64_t *result)
|
|||
if (hFindFile == -1)
|
||||
{
|
||||
memset(result,0,sizeof(struct _finddatai64_t));
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -107,8 +109,10 @@ int _findnexti64(int handle, struct _finddatai64_t *result)
|
|||
if (handle == 0 || handle == -1)
|
||||
return 0;
|
||||
|
||||
if (!FindNextFileA((void *)handle, &FindFileData))
|
||||
return -1;
|
||||
if (!FindNextFileA((void *)handle, &FindFileData)) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
result->attrib = FindFileData.dwFileAttributes;
|
||||
result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
|
||||
|
@ -148,6 +152,7 @@ int _wfindfirsti64(const wchar_t *_name, struct _wfinddatai64_t *result)
|
|||
if (hFindFile == -1)
|
||||
{
|
||||
memset(result,0,sizeof(struct _wfinddatai64_t));
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: wopen.c,v 1.3 2003/07/11 21:57:54 royce Exp $
|
||||
/* $Id: wopen.c,v 1.4 2003/12/03 17:17:03 navaraf Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -132,8 +132,10 @@ int _wopen(const wchar_t* _path, int _oflag, ...)
|
|||
dwCreationDistribution,
|
||||
dwFlagsAndAttributes,
|
||||
NULL);
|
||||
if (hFile == (HANDLE)-1)
|
||||
if (hFile == (HANDLE)-1) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
return __fileno_alloc(hFile,_oflag);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <msvcrt/stdlib.h>
|
||||
#include <msvcrt/string.h>
|
||||
#include <msvcrt/internal/file.h>
|
||||
#include <msvcrt/errno.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <msvcrt/msvcrtdbg.h>
|
||||
|
@ -48,7 +49,8 @@ size_t _write(int _fd, const void* _buf, size_t _nbyte)
|
|||
result = _nbyte;
|
||||
tmp = (char*) malloc(BUFSIZE);
|
||||
if (tmp == NULL) {
|
||||
return -1;
|
||||
__set_errno(ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
count = BUFSIZE;
|
||||
out = tmp;
|
||||
|
@ -76,10 +78,10 @@ size_t _write(int _fd, const void* _buf, size_t _nbyte)
|
|||
if (count == 0 || _nbyte == 0) {
|
||||
int tmp_len_debug = strlen(tmp);
|
||||
if (!WriteFile(_get_osfhandle(_fd), tmp, BUFSIZE - count, &wbyte, NULL)) {
|
||||
//ReportLastError();
|
||||
result = -1;
|
||||
tmp_len_debug = 0;
|
||||
break;
|
||||
_dosmaperr(GetLastError());
|
||||
result = -1;
|
||||
tmp_len_debug = 0;
|
||||
break;
|
||||
}
|
||||
if (wbyte < (BUFSIZE - count)) {
|
||||
result = in - (char*)_buf;
|
||||
|
@ -93,8 +95,8 @@ size_t _write(int _fd, const void* _buf, size_t _nbyte)
|
|||
return result;
|
||||
} else {
|
||||
if(!WriteFile(_get_osfhandle(_fd), _buf, _nbyte, &wbyte, NULL)) {
|
||||
//ReportLastError();
|
||||
return -1;
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
return wbyte;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#define NDEBUG
|
||||
#include <msvcrt/msvcrtdbg.h>
|
||||
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
|
@ -20,7 +20,9 @@
|
|||
int _wunlink(const wchar_t* filename)
|
||||
{
|
||||
DPRINT("_wunlink('%S')\n", filename);
|
||||
if (!DeleteFileW(filename))
|
||||
if (!DeleteFileW(filename)) {
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: _system.c,v 1.8 2003/08/05 15:41:03 weiden Exp $
|
||||
/* $Id: _system.c,v 1.9 2003/12/03 17:17:03 navaraf Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -110,7 +110,7 @@ int system(const char *command)
|
|||
|
||||
if (result == FALSE)
|
||||
{
|
||||
__set_errno(ENOEXEC);
|
||||
_dosmaperr(GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: threadx.c,v 1.5 2003/11/14 17:13:31 weiden Exp $
|
||||
/* $Id: threadx.c,v 1.6 2003/12/03 17:17:03 navaraf Exp $
|
||||
*
|
||||
*/
|
||||
#include <windows.h>
|
||||
|
@ -29,8 +29,7 @@ unsigned long _beginthreadex(
|
|||
arglist, initflag, (PULONG)thrdaddr );
|
||||
if (NULL == NewThread)
|
||||
{
|
||||
/* FIXME map GetLastError() to errno */
|
||||
__set_errno ( ENOSYS );
|
||||
_dosmaperr( GetLastError() );
|
||||
}
|
||||
|
||||
return (unsigned long) NewThread;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: errno.c,v 1.10 2003/07/16 17:53:34 royce Exp $
|
||||
/* $Id: errno.c,v 1.11 2003/12/03 17:17:03 navaraf Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
|||
#include <msvcrt/internal/tls.h>
|
||||
#include <msvcrt/internal/file.h>
|
||||
|
||||
#include "doserrmap.h"
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
|
@ -45,4 +47,32 @@ int __set_errno(int error)
|
|||
return(error);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function sets both doserrno to the passed in OS error code
|
||||
* and also maps this to an appropriate errno code. The mapping
|
||||
* has been deduced automagically by running this functions, which
|
||||
* exists in MSVCRT but is undocumented, on all the error codes in
|
||||
* winerror.h.
|
||||
*/
|
||||
void _dosmaperr(unsigned long oserror)
|
||||
{
|
||||
int pos, base, lim;
|
||||
|
||||
__set_doserrno(oserror);
|
||||
|
||||
/* Use binary chop to find the corresponding errno code */
|
||||
for (base=0, lim=sizeof(doserrmap)/sizeof(doserrmap[0]); lim; lim >>= 1) {
|
||||
pos = base+(lim >> 1);
|
||||
if (doserrmap[pos].winerr == oserror) {
|
||||
__set_errno(doserrmap[pos].en);
|
||||
return;
|
||||
} else if (doserrmap[pos].winerr > oserror) {
|
||||
base = pos + 1;
|
||||
--lim;
|
||||
}
|
||||
}
|
||||
/* EINVAL appears to be the default */
|
||||
__set_errno(EINVAL);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -212,7 +212,7 @@ EnumDesktopsA=EnumDesktopsA@12
|
|||
EnumDesktopsW=EnumDesktopsW@12
|
||||
EnumDisplayDevicesA=EnumDisplayDevicesA@16
|
||||
EnumDisplayDevicesW=EnumDisplayDevicesW@16
|
||||
EnumDisplayMonitors=EnumDisplayMonitors@16
|
||||
;EnumDisplayMonitors=EnumDisplayMonitors@16
|
||||
EnumDisplaySettingsA=EnumDisplaySettingsA@12
|
||||
EnumDisplaySettingsExA=EnumDisplaySettingsExA@16
|
||||
EnumDisplaySettingsExW=EnumDisplaySettingsExW@16
|
||||
|
|
Loading…
Reference in a new issue