* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
* $Author: ekohl $
- * $Date: 2001/07/03 12:55:00 $
+ * $Date: 2001/07/03 22:15:02 $
*
*/
#endif
/*
- * The following structure is filled in by _findfirst or _findnext when
+ * The following structures are filled in by _findfirst or _findnext when
* they succeed in finding a match.
*/
struct _finddata_t
char name[FILENAME_MAX]; /* may include spaces. */
};
+struct _finddatai64_t
+{
+ unsigned attrib; /* Attributes, see constants above. */
+ time_t time_create;
+ time_t time_access; /* always midnight local time */
+ time_t time_write;
+ __int64 size;
+ char name[FILENAME_MAX]; /* may include spaces. */
+};
+
+struct _wfinddata_t
+{
+ unsigned attrib; /* Attributes, see constants above. */
+ time_t time_create;
+ time_t time_access; /* always midnight local time */
+ time_t time_write;
+ _fsize_t size;
+ wchar_t name[FILENAME_MAX]; /* may include spaces. */
+};
+
+struct _wfinddatai64_t
+{
+ unsigned attrib; /* Attributes, see constants above. */
+ time_t time_create;
+ time_t time_access; /* always midnight local time */
+ time_t time_write;
+ __int64 size;
+ wchar_t name[FILENAME_MAX]; /* may include spaces. */
+};
+
/*
* Functions for searching for files. _findfirst returns -1 if no match
* is found. Otherwise it returns a handle to be used in _findnext and
* _findclose calls. _findnext also returns -1 if no match could be found,
* and 0 if a match was found. Call _findclose when you are finished.
*/
+int _findclose (int nHandle);
int _findfirst (const char* szFilespec, struct _finddata_t* find);
+int _findfirsti64 (const char* szFilespec, struct _finddatai64_t* find);
int _findnext (int nHandle, struct _finddata_t* find);
-int _findclose (int nHandle);
+int _findnexti64 (int nHandle, struct _finddatai64_t* find);
int _chdir (const char* szPath);
char* _getcwd (char* caBuffer, int nBufferSize);
int _rmdir (const char* szPath);
+/* Wide character versions */
+int _wfindfirst(const wchar_t *_name, struct _wfinddata_t *result);
+int _wfindfirsti64(const wchar_t *_name, struct _wfinddatai64_t *result);
+int _wfindnext(int handle, struct _wfinddata_t *result);
+int _wfindnexti64(int handle, struct _wfinddatai64_t *result);
+
+int _wchdir(const wchar_t *szPath);
+wchar_t* _wgetcwd(wchar_t *buffer, int maxlen);
+int _wmkdir(const wchar_t *_path);
+int _wrmdir(const wchar_t *_path);
+
+
#ifndef _NO_OLDNAMES
int chdir (const char* szPath);
int __fileno_dup2( int handle1, int handle2 );
+int __fileno_getmode(int _fd);
int __fileno_setmode(int _fd, int _newmode);
int __fileno_close(int _fd);
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
* $Author: ekohl $
- * $Date: 2001/07/03 12:55:00 $
+ * $Date: 2001/07/03 22:15:02 $
*
*/
/* Appropriated for Reactos Crtdll by Ariadne */
#endif
int _access (const char* szFileName, int nAccessMode);
+int _chmod (const char* szPath, int nMode);
int _chsize (int nHandle, long lnNewSize);
int _close (int nHandle);
-int _commit(int _fd);
+int _commit(int _fd);
int _creat (const char* szFileName, int nAccessMode);
int _dup (int nHandle);
int _dup2 (int nOldHandle, int nNewHandle);
long _filelength (int nHandle);
+__int64 _filelengthi64(int nHandle);
int _fileno (FILE* fileGetHandle);
void* _get_osfhandle (int nHandle);
int _isatty (int nHandle);
int _locking (int nHandle, int nCmd, long lnLockRegionLength);
off_t _lseek(int _fd, off_t _offset, int _whence);
+__int64 _lseeki64(int _fildes, __int64 _offset, int _whence);
int _open (const char* szFileName, int nFlags, ...);
int _open_osfhandle (void *lnOSHandle, int nFlags);
int _pipe (int *naHandles, unsigned int unSize, int nMode);
/* SH_... flags for nFlag defined in share.h */
int _sopen (char* szFileName, int nAccess, int nFlag, int nMode);
-long _tell (int nHandle);
-unsigned _umask (unsigned unMode);
-int _unlink (const char* szFileName);
+long _tell(int nHandle);
+__int64 _telli64(int nHandle);
+unsigned _umask(unsigned unMode);
+int _unlink(const char* szFileName);
size_t _write(int _fd, const void *_buf, size_t _nbyte);
+
+/* wide character functions */
+int _waccess(const wchar_t *_path, int _amode);
+int _wchmod(const wchar_t *filename, int mode);
+int _wcreat(const wchar_t *filename, int mode);
+
+int _wopen(const wchar_t *_path, int _oflag,...);
+int _wsopen(wchar_t *path, int access, int shflag, int mode);
+int _wunlink(const wchar_t *filename);
+
+
#ifndef _NO_OLDNAMES
/*
* Non-underscored versions of non-ANSI functions to improve portability.
* These functions live in libmoldname.a.
*/
-#define access _access
-#define chsize _chsize
-#define close _close
-#define creat _creat
-#define dup _dup
-#define dup2 _dup2
+#define access _access
+#define chmod _chmod
+#define chsize _chsize
+#define close _close
+#define creat _creat
+#define dup _dup
+#define dup2 _dup2
#define eof _eof
-#define filelength _filelength
-#define fileno(f) ((f)->_file)
-#define isatty _isatty
-#define lseek _lseek
-#define open _open
-#define read _read
-#define sopen(path,access,shflag,mode) _open((path), (access)|(shflag), (mode))
-#define tell(file) _lseek(_file, 0, SEEK_CUR)
-#define umask _umask
+#define filelength _filelength
+#define fileno(f) ((f)->_file)
+#define isatty _isatty
+#define lseek _lseek
+#define open _open
+#define read _read
+#define sopen(path,access,shflag,mode) _open((path), (access)|(shflag), (mode))
+#define tell(file) _lseek(_file, 0, SEEK_CUR)
+#define umask _umask
#define unlink _unlink
-#define write _write
-
+#define write _write
#endif /* Not _NO_OLDNAMES */
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
* $Author: ekohl $
- * $Date: 2001/07/03 13:07:12 $
+ * $Date: 2001/07/03 22:16:07 $
*
*/
extern "C" {
#endif
+#ifndef _WCHAR_T_
+#define _WCHAR_T_
+#define _WCHAR_T
+#define _WCHAR_T_DEFINED
+#ifndef __WCHAR_TYPE__
+#define __WCHAR_TYPE__ short unsigned int
+#endif
+#ifndef __cplusplus
+typedef __WCHAR_TYPE__ wchar_t;
+#endif /* C++ */
+#endif /* wchar_t not already defined */
+
+
/*
* Constants for the stat st_mode member.
*/
time_t st_ctime; /* Creation time */
};
+struct _stati64
+{
+ short st_dev; /* Equivalent to drive number 0=A 1=B ... */
+ short st_ino; /* Always zero ? */
+ short st_mode; /* See above constants */
+ short st_nlink; /* Number of links. */
+ int st_uid; /* User: Maybe significant on NT ? */
+ short st_gid; /* Group: Ditto */
+ short st_rdev; /* Seems useless (not even filled in) */
+ __int64 st_size; /* File size in bytes */
+ time_t st_atime; /* Accessed date (always 00:00 hrs local
+ * on FAT) */
+ time_t st_mtime; /* Modified time */
+ time_t st_ctime; /* Creation time */
+};
int _fstat (int nFileNo, struct stat* pstat);
-int _chmod (const char* szPath, int nMode);
+__int64 _fstati64 (int nFileNo, struct _stati64* pstat);
int _stat (const char* szPath, struct stat* pstat);
-
+__int64 _stati64 (const char* szPath, struct _stati64* pstat);
+int _wstat (const wchar_t* szPath, struct stat* pstat);
+__int64 _wstati64 (const wchar_t* szPath, struct _stati64* pstat);
#ifndef _NO_OLDNAMES
-#define fstat(nFileNo, pstat) _fstat(nFileNo, pstat)
-#define chmod(szPath,nMode) _chmod(szPath,nMode)
-#define stat(szPath,pstat) _stat(szPath,pstat)
+#define fstat(nFileNo, pstat) _fstat(nFileNo, pstat)
+#define stat(szPath,pstat) _stat(szPath,pstat)
#endif /* Not _NO_OLDNAMES */
* DISCLAMED. This includes but is not limited to warrenties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
* $Author: ekohl $
- * $Date: 2001/07/03 13:07:12 $
+ * $Date: 2001/07/03 22:16:07 $
*
*/
#ifndef _TYPES_H_
#define _TYPES_H_
+#ifdef __GNUC__
+#undef __int64
+#define __int64 long long
+#endif
+
#ifndef _TIME_T_
#define _TIME_T_
typedef long time_t;
* DISCLAMED. This includes but is not limited to warranties of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
* $Author: ekohl $
- * $Date: 2001/07/03 13:07:12 $
+ * $Date: 2001/07/03 22:16:07 $
*
*/
};
int _utime (const char* szFileName, struct _utimbuf* pTimes);
-int _futime (int nHandle, struct _utimbuf *pTimes);
+int _futime (int nHandle, struct _utimbuf *pTimes);
/* Wide character version */
-int _wutime (const wchar_t *szFileName, struct _utimbuf *times);
+int _wutime (const wchar_t *szFileName, struct _utimbuf *times);
#ifndef _NO_OLDNAMES
--- /dev/null
+#include <windows.h>
+#include <msvcrt/io.h>
+
+#define mode_t int
+
+
+int _chmod(const char *filename, mode_t mode)
+{
+ DWORD FileAttributes = 0;
+
+ FileAttributes = GetFileAttributesA(filename);
+ if ( FileAttributes == -1 )
+ return -1;
+
+ if ( mode == 0 )
+ return -1;
+
+ if ((mode & _S_IREAD) == _S_IREAD && (mode & _S_IWRITE) != _S_IWRITE)
+ FileAttributes &= FILE_ATTRIBUTE_READONLY;
+ else if (((mode & _S_IREAD) != _S_IREAD) && ((mode & _S_IWRITE) == _S_IWRITE))
+ FileAttributes &= FILE_ATTRIBUTE_NORMAL;
+ else
+ FileAttributes &= FILE_ATTRIBUTE_NORMAL;
+
+ if (SetFileAttributesA(filename, FileAttributes) == FALSE)
+ return -1;
+
+ return 1;
+}
+
+int _wchmod(const wchar_t *filename, mode_t mode)
+{
+ DWORD FileAttributes = 0;
+
+ FileAttributes = GetFileAttributesW(filename);
+ if ( FileAttributes == -1 )
+ return -1;
+
+ if ( mode == 0 )
+ return -1;
+
+ if ((mode & _S_IREAD) == _S_IREAD && (mode & _S_IWRITE) != _S_IWRITE)
+ FileAttributes &= FILE_ATTRIBUTE_READONLY;
+ else if (((mode & _S_IREAD) != _S_IREAD) && ((mode & _S_IWRITE) == _S_IWRITE))
+ FileAttributes &= FILE_ATTRIBUTE_NORMAL;
+ else
+ FileAttributes &= FILE_ATTRIBUTE_NORMAL;
+
+ if (SetFileAttributesW(filename, FileAttributes) == FALSE)
+ return -1;
+
+ return 1;
+}
\ No newline at end of file
--- /dev/null
+/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
+#include <msvcrt/io.h>
+
+int _chsize(int _fd, long size)
+{
+ if (lseek(_fd, size, 0) == -1)
+ return -1;
+ if (_write(_fd, 0, 0) < 0)
+ return -1;
+ return 0;
+}
--- /dev/null
+#include <msvcrt/io.h>
+#include <msvcrt/fcntl.h>
+
+int _creat(const char *filename, int mode)
+{
+ return _open(filename,_O_CREAT|_O_TRUNC,mode);
+}
+
+int _wcreat(const wchar_t *filename, int mode)
+{
+ return _wopen(filename,_O_CREAT|_O_TRUNC,mode);
+}
--- /dev/null
+#include <msvcrt/io.h>
+#include <msvcrt/internal/file.h>
+
+
+int _dup(int handle)
+{
+ return __fileno_alloc(_get_osfhandle(handle), __fileno_getmode(handle));
+}
--- /dev/null
+#include <msvcrt/io.h>
+#include <msvcrt/internal/file.h>
+
+int _dup2(int handle1, int handle2)
+{
+ return __fileno_dup2(handle1, handle2);
+}
--- /dev/null
+//#include <windows.h>
+#include <msvcrt/io.h>
+
+int _eof(int _fd)
+{
+ __int64 cur_pos = _lseeki64(_fd, 0, SEEK_CUR);
+ __int64 end_pos = _lseeki64(_fd, 0, SEEK_END);
+ if ( cur_pos == -1 || end_pos == -1)
+ return -1;
+
+ if (cur_pos == end_pos)
+ return 1;
+
+ return 0;
+}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/io.h>
+
+long _filelength(int _fd)
+{
+ return GetFileSize(_get_osfhandle(_fd),NULL);
+}
+
+__int64 _filelengthi64(int _fd)
+{
+ long lo_length, hi_length;
+
+ lo_length = GetFileSize(_get_osfhandle(_fd), &hi_length);
+
+ return((((__int64)hi_length) << 32) + lo_length);
+}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/io.h>
+#include <msvcrt/string.h>
+#include <msvcrt/internal/file.h>
+
+
+int _findclose(int handle)
+{
+ // check no wildcards or invalid handle
+ if (handle == 0 || handle == -1)
+ return 0;
+ return FindClose((void *)handle);
+}
+
+int _findfirst(const char *_name, struct _finddata_t *result)
+{
+ WIN32_FIND_DATAA FindFileData;
+ char dir[MAX_PATH];
+ long hFindFile;
+ int len = 0;
+
+ if ( _name == NULL || _name[0] == 0 )
+ {
+ len = GetCurrentDirectoryA(MAX_PATH-4,dir);
+ if (dir[len-1] != '\\')
+ {
+ dir[len] = '\\';
+ dir[len+1] = 0;
+ }
+ strcat(dir,"*.*");
+ }
+ else
+ strcpy(dir,_name);
+
+ hFindFile = (long)FindFirstFileA( dir, &FindFileData );
+ if (hFindFile == -1)
+ {
+ memset(result,0,sizeof(struct _finddata_t));
+ return -1;
+ }
+
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size = FindFileData.nFileSizeLow;
+ strncpy(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 (!strchr(dir,'*') && !strchr(dir,'?'))
+ {
+ _findclose(hFindFile);
+ return 0;
+ }
+
+ return hFindFile;
+}
+
+int _findfirsti64(const char *_name, struct _finddatai64_t *result)
+{
+ WIN32_FIND_DATAA FindFileData;
+ char dir[MAX_PATH];
+ long hFindFile;
+ int len = 0;
+
+ if ( _name == NULL || _name[0] == 0 )
+ {
+ len = GetCurrentDirectoryA(MAX_PATH-4,dir);
+ if (dir[len-1] != '\\')
+ {
+ dir[len] = '\\';
+ dir[len+1] = 0;
+ }
+ strcat(dir, "*.*");
+ }
+ else
+ strcpy(dir, _name);
+
+ hFindFile = (long)FindFirstFileA(dir, &FindFileData);
+ if (hFindFile == -1)
+ {
+ memset(result,0,sizeof(struct _finddatai64_t));
+ return -1;
+ }
+
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size =
+ (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
+ strncpy(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 (!strchr(dir,'*') && !strchr(dir,'?'))
+ {
+ _findclose(hFindFile);
+ return 0;
+ }
+
+ return hFindFile;
+}
+
+int _findnext(int handle, struct _finddata_t *result)
+{
+ WIN32_FIND_DATAA FindFileData;
+
+ // check no wildcards or invalid handle
+ if (handle == 0 || handle == -1)
+ return 0;
+
+ if (!FindNextFileA((void *)handle, &FindFileData))
+ return -1;
+
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size = FindFileData.nFileSizeLow;
+ strncpy(result->name,FindFileData.cFileName, MAX_PATH);
+
+ return 0;
+}
+
+int _findnexti64(int handle, struct _finddatai64_t *result)
+{
+ WIN32_FIND_DATAA FindFileData;
+
+ // check no wildcards or invalid handle
+ if (handle == 0 || handle == -1)
+ return 0;
+
+ if (!FindNextFileA((void *)handle, &FindFileData))
+ return -1;
+
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size =
+ (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
+ strncpy(result->name,FindFileData.cFileName,MAX_PATH);
+
+ return 0;
+}
+
+int _wfindfirst(const wchar_t *_name, struct _wfinddata_t *result)
+{
+ WIN32_FIND_DATAW FindFileData;
+ wchar_t dir[MAX_PATH];
+ long hFindFile;
+ int len = 0;
+
+ if ( _name == NULL || _name[0] == 0 )
+ {
+ len = GetCurrentDirectoryW(MAX_PATH-4, dir);
+ if (dir[len-1] != L'\\')
+ {
+ dir[len] = L'\\';
+ dir[len+1] = 0;
+ }
+ wcscat(dir, L"*.*");
+ }
+ else
+ wcscpy(dir, _name);
+
+ hFindFile = (long)FindFirstFileW(dir, &FindFileData);
+ if (hFindFile == -1)
+ {
+ memset(result,0,sizeof(struct _wfinddata_t));
+ return -1;
+ }
+
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size = FindFileData.nFileSizeLow;
+ wcsncpy(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 (!wcschr(dir, L'*') && !wcschr(dir, L'?'))
+ {
+ _findclose(hFindFile);
+ return 0;
+ }
+
+ return hFindFile;
+}
+
+int _wfindfirsti64(const wchar_t *_name, struct _wfinddatai64_t *result)
+{
+ WIN32_FIND_DATAW FindFileData;
+ wchar_t dir[MAX_PATH];
+ long hFindFile;
+ int len = 0;
+
+ if (_name == NULL || _name[0] == 0)
+ {
+ len = GetCurrentDirectoryW(MAX_PATH-4,dir);
+ if (dir[len-1] != L'\\')
+ {
+ dir[len] = L'\\';
+ dir[len+1] = 0;
+ }
+ wcscat(dir, L"*.*");
+ }
+ else
+ wcscpy(dir, _name);
+
+ hFindFile = (long)FindFirstFileW(dir, &FindFileData);
+ if (hFindFile == -1)
+ {
+ memset(result,0,sizeof(struct _wfinddatai64_t));
+ return -1;
+ }
+
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size =
+ (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
+ wcsncpy(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 (!wcschr(dir,L'*') && !wcschr(dir,L'?'))
+ {
+ _findclose(hFindFile);
+ return 0;
+ }
+
+ return hFindFile;
+}
+
+int _wfindnext(int handle, struct _wfinddata_t *result)
+{
+ WIN32_FIND_DATAW FindFileData;
+
+ // check no wildcards or invalid handle
+ if (handle == 0 || handle == -1)
+ return 0;
+
+ if (!FindNextFileW((void *)handle, &FindFileData))
+ return -1;
+
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size = FindFileData.nFileSizeLow;
+ wcsncpy(result->name,FindFileData.cFileName, MAX_PATH);
+
+ return 0;
+}
+
+int _wfindnexti64(int handle, struct _wfinddatai64_t *result)
+{
+ WIN32_FIND_DATAW FindFileData;
+
+ // check no wildcards or invalid handle
+ if (handle == 0 || handle == -1)
+ return 0;
+
+ if (!FindNextFileW((void *)handle, &FindFileData))
+ return -1;
+
+ result->attrib = FindFileData.dwFileAttributes;
+ result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->size =
+ (((__int64)FindFileData.nFileSizeLow)<<32) + FindFileData.nFileSizeLow;
+ wcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
+
+ return 0;
+}
--- /dev/null
+#include <windows.h>
+#include <msvcrt/io.h>
+
+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;
+ return 0;
+}
#include <msvcrt/io.h>
#include <msvcrt/internal/file.h>
+
long _lseek(int _fildes, long _offset, int _whence)
{
- return _llseek((HFILE)filehnd(_fildes),_offset,_whence);
+ return (SetFilePointer((HANDLE)filehnd(_fildes), _offset, NULL, _whence));
}
+__int64 _lseeki64(int _fildes, __int64 _offset, int _whence)
+{
+ ULONG lo_pos, hi_pos;
+
+ lo_pos = SetFilePointer((HANDLE)filehnd(_fildes), _offset, &hi_pos, _whence);
+ return((((__int64)hi_pos) << 32) + lo_pos);
+}
\ No newline at end of file
}
-int __fileno_alloc(HANDLE hFile, int mode);
-
-
int _open(const char *_path, int _oflag,...)
{
HANDLE hFile;
--- /dev/null
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS system libraries
+ * FILE: lib/crtdll/io/pipe.c
+ * PURPOSE: Creates a pipe
+ * PROGRAMER: DJ Delorie
+ * UPDATE HISTORY:
+ * 28/12/98: Appropriated for Reactos
+ */
+#include <windows.h>
+#include <msvcrt/io.h>
+#include <msvcrt/internal/file.h>
+
+
+int _pipe(int _fildes[2], unsigned int size, int mode )
+{
+ HANDLE hReadPipe, hWritePipe;
+
+ if (!CreatePipe(&hReadPipe,&hWritePipe,NULL,size))
+ return -1;
+
+ _fildes[0] = __fileno_alloc(hReadPipe, mode);
+ _fildes[1] = __fileno_alloc(hWritePipe, mode);
+
+ return 0;
+}
--- /dev/null
+#include <msvcrt/io.h>
+
+
+int _sopen(char *path, int access, int shflag, int mode)
+{
+ return _open((path), (access)|(shflag), (mode));
+}
+
+int _wsopen(wchar_t *path, int access, int shflag, int mode)
+{
+ return _wopen((path), (access)|(shflag), (mode));
+}
--- /dev/null
+/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+#include <msvcrt/errno.h>
+#include <msvcrt/io.h>
+
+
+off_t _tell(int _file)
+{
+ return _lseek(_file, 0, SEEK_CUR);
+}
+
+__int64 _telli64(int _file)
+{
+ return _lseeki64(_file, 0, SEEK_CUR);
+}
--- /dev/null
+/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
+#include <crtdll/sys/stat.h>
+
+unsigned _unMode_dll = 022;
+
+unsigned _umask (unsigned unMode)
+{
+ unsigned old_mask = _unMode_dll;
+ _unMode_dll = unMode;
+ return old_mask;
+}
return -1;
return 0;
}
+
+int _wunlink(const wchar_t *filename)
+{
+ if (!DeleteFileW(filename))
+ return -1;
+ return 0;
+}
--- /dev/null
+#include <msvcrt/stdio.h>
+#include <msvcrt/io.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/sys/utime.h>
+#include <msvcrt/internal/file.h>
+
+int _utime(const char* filename, struct _utimbuf* buf)
+{
+ int fn;
+ int ret;
+
+ fn = _open(filename, _O_RDWR);
+ if (fn == -1)
+ {
+ __set_errno(EBADF);
+ return -1;
+ }
+ ret = _futime(fn,buf);
+ if (_close(fn) < 0)
+ return -1;
+ return ret;
+}
+
+int _wutime(const wchar_t* filename, struct _utimbuf* buf)
+{
+ int fn;
+ int ret;
+
+ fn = _wopen(filename, _O_RDWR);
+ if (fn == -1)
+ {
+ __set_errno(EBADF);
+ return -1;
+ }
+ ret = _futime(fn,buf);
+ if (_close(fn) < 0)
+ return -1;
+ return ret;
+}
#include <msvcrt/internal/file.h>
-int
-_fstat(int fd, struct stat *statbuf)
+int _fstat(int fd, struct stat *statbuf)
{
BY_HANDLE_FILE_INFORMATION FileInformation;
statbuf->st_size = FileInformation.nFileSizeLow;
return 0;
}
+
+__int64 _fstati64 (int fd, struct _stati64* statbuf)
+{
+ BY_HANDLE_FILE_INFORMATION FileInformation;
+
+ if (!statbuf)
+ {
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ if (!GetFileInformationByHandle(_get_osfhandle(fd),
+ &FileInformation))
+ {
+ __set_errno(EBADF);
+ return -1;
+ }
+ statbuf->st_ctime = FileTimeToUnixTime(&FileInformation.ftCreationTime,NULL);
+ statbuf->st_atime = FileTimeToUnixTime(&FileInformation.ftLastAccessTime,NULL);
+ statbuf->st_mtime = FileTimeToUnixTime(&FileInformation.ftLastWriteTime,NULL);
+
+ statbuf->st_dev = fd;
+ statbuf->st_size = (((__int64)FileInformation.nFileSizeHigh) << 32) +
+ FileInformation.nFileSizeLow;
+ return 0;
+}
--- /dev/null
+#include <msvcrt/alloc.h>
+#include <msvcrt/stdlib.h>
+#include <msvcrt/sys/utime.h>
+#include <msvcrt/io.h>
+#include <msvcrt/time.h>
+#include <msvcrt/errno.h>
+#include <msvcrt/internal/file.h>
+
+int _futime (int nHandle, struct _utimbuf *pTimes)
+{
+ FILETIME LastAccessTime;
+ FILETIME LastWriteTime;
+
+ // check for stdin / stdout handles ??
+ if (nHandle == -1)
+ {
+ __set_errno(EBADF);
+ return -1;
+ }
+
+ if (pTimes == NULL)
+ {
+ pTimes = alloca(sizeof(struct _utimbuf));
+ time(&pTimes->actime);
+ time(&pTimes->modtime);
+ }
+
+ if (pTimes->actime < pTimes->modtime)
+ {
+ __set_errno(EINVAL);
+ return -1;
+ }
+
+ UnixTimeToFileTime(pTimes->actime,&LastAccessTime,0);
+ UnixTimeToFileTime(pTimes->modtime,&LastWriteTime,0);
+ if (!SetFileTime(_get_osfhandle(nHandle),NULL, &LastAccessTime, &LastWriteTime))
+ {
+ __set_errno(EBADF);
+ return -1;
+ }
+
+ return 0;
+}
return ret;
}
+
+__int64 _stati64 (const char *path, struct _stati64 *buffer)
+{
+ int fd = _open(path,_O_RDONLY);
+ int ret;
+
+ ret = _fstati64(fd,buffer);
+ _close(fd);
+
+ return ret;
+}
+
+int _wstat (const wchar_t *path, struct stat *buffer)
+{
+ int fd = _wopen(path,_O_RDONLY);
+ int ret;
+
+ ret = fstat(fd,buffer);
+ _close(fd);
+
+ return ret;
+}
+
+__int64 _wstati64 (const wchar_t *path, struct _stati64 *buffer)
+{
+ int fd = _wopen(path,_O_RDONLY);
+ int ret;
+
+ ret = _fstati64(fd,buffer);
+ _close(fd);
+
+ return ret;
+}