mirror of
https://github.com/reactos/reactos.git
synced 2024-07-31 00:28:56 +00:00
*** empty log message ***
svn path=/trunk/; revision=1592
This commit is contained in:
parent
65249c23ae
commit
5f529d5a90
|
@ -53,7 +53,7 @@ FILE* fopen(const char *file, const char *mode)
|
||||||
else
|
else
|
||||||
oflags |= (_fmode & (O_TEXT|O_BINARY));
|
oflags |= (_fmode & (O_TEXT|O_BINARY));
|
||||||
|
|
||||||
fd = _open(file, oflags, 0);
|
fd = _open(file, oflags, 0666);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <crtdll/internal/file.h>
|
#include <crtdll/internal/file.h>
|
||||||
#include <crtdll/fcntl.h>
|
#include <crtdll/fcntl.h>
|
||||||
#include <crtdll/io.h>
|
#include <crtdll/io.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
|
||||||
long
|
long
|
||||||
|
@ -14,6 +15,12 @@ ftell(FILE *f)
|
||||||
long tres;
|
long tres;
|
||||||
int adjust=0;
|
int adjust=0;
|
||||||
|
|
||||||
|
if (!f)
|
||||||
|
{
|
||||||
|
__set_errno(EBADF);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (f->_cnt < 0)
|
if (f->_cnt < 0)
|
||||||
f->_cnt = 0;
|
f->_cnt = 0;
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,20 @@ _fstat(int fd, struct stat *statbuf)
|
||||||
statbuf->st_ctime = FileTimeToUnixTime( &FileInformation.ftCreationTime,NULL);
|
statbuf->st_ctime = FileTimeToUnixTime( &FileInformation.ftCreationTime,NULL);
|
||||||
statbuf->st_atime = FileTimeToUnixTime( &FileInformation.ftLastAccessTime,NULL);
|
statbuf->st_atime = FileTimeToUnixTime( &FileInformation.ftLastAccessTime,NULL);
|
||||||
statbuf->st_mtime = FileTimeToUnixTime( &FileInformation.ftLastWriteTime,NULL);
|
statbuf->st_mtime = FileTimeToUnixTime( &FileInformation.ftLastWriteTime,NULL);
|
||||||
|
if (statbuf->st_atime ==0)
|
||||||
|
statbuf->st_atime = statbuf->st_mtime;
|
||||||
|
if (statbuf->st_ctime ==0)
|
||||||
|
statbuf->st_ctime = statbuf->st_mtime;
|
||||||
|
|
||||||
statbuf->st_dev = fd;
|
statbuf->st_dev = FileInformation.dwVolumeSerialNumber;
|
||||||
statbuf->st_size = FileInformation.nFileSizeLow;
|
statbuf->st_size = FileInformation.nFileSizeLow;
|
||||||
|
statbuf->st_nlink = FileInformation.nNumberOfLinks;
|
||||||
|
statbuf->st_mode = S_IREAD;
|
||||||
|
if (FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
|
statbuf->st_mode |= S_IFDIR | S_IEXEC;
|
||||||
|
else
|
||||||
|
statbuf->st_mode |= S_IFREG;
|
||||||
|
if ( !(FileInformation.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
|
||||||
|
statbuf->st_mode |= S_IWRITE;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,23 @@
|
||||||
|
#include <windows.h>
|
||||||
#include <crtdll/sys/types.h>
|
#include <crtdll/sys/types.h>
|
||||||
#include <crtdll/sys/stat.h>
|
#include <crtdll/sys/stat.h>
|
||||||
#include <crtdll/fcntl.h>
|
#include <crtdll/fcntl.h>
|
||||||
#include <crtdll/io.h>
|
#include <crtdll/io.h>
|
||||||
|
#include <crtdll/errno.h>
|
||||||
|
|
||||||
|
|
||||||
int _stat( const char *path, struct stat *buffer )
|
int _stat( const char *path, struct stat *buffer )
|
||||||
{
|
{
|
||||||
|
WIN32_FIND_DATA wfd;
|
||||||
|
HANDLE fh;
|
||||||
|
fh = FindFirstFile (path,&wfd);
|
||||||
|
if ( fh == -1 )
|
||||||
|
{
|
||||||
|
__set_errno(ENOFILE);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if ( ! (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||||
|
{
|
||||||
int fd = _open(path,_O_RDONLY);
|
int fd = _open(path,_O_RDONLY);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -13,5 +25,31 @@ int _stat( const char *path, struct stat *buffer )
|
||||||
_close(fd);
|
_close(fd);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
buffer->st_ctime = FileTimeToUnixTime( &wfd.ftCreationTime,NULL);
|
||||||
|
buffer->st_atime = FileTimeToUnixTime( &wfd.ftLastAccessTime,NULL);
|
||||||
|
buffer->st_mtime = FileTimeToUnixTime( &wfd.ftLastWriteTime,NULL);
|
||||||
|
|
||||||
|
if (buffer->st_atime ==0)
|
||||||
|
buffer->st_atime = buffer->st_mtime;
|
||||||
|
if (buffer->st_ctime ==0)
|
||||||
|
buffer->st_ctime = buffer->st_mtime;
|
||||||
|
|
||||||
|
buffer->st_mode = S_IREAD;
|
||||||
|
if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
|
buffer->st_mode |= S_IFDIR;
|
||||||
|
else
|
||||||
|
buffer->st_mode |= S_IFREG;
|
||||||
|
if ( ! (wfd.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
|
||||||
|
buffer->st_mode |= S_IWRITE | S_IEXEC;
|
||||||
|
|
||||||
|
buffer->st_size = wfd.nFileSizeLow;
|
||||||
|
buffer->st_nlink = 1;
|
||||||
|
if (FindNextFile(fh,&wfd))
|
||||||
|
{
|
||||||
|
__set_errno(ENOFILE);
|
||||||
|
FindClose(fh);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue