Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
windows: only allow opening directories for reading
Browse files Browse the repository at this point in the history
This is closer to the Posix model.
  • Loading branch information
piscisaureus committed Jul 31, 2012
1 parent 69c2ef8 commit 109e176
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/win/fs.c
Expand Up @@ -390,7 +390,7 @@ void fs__open(uv_fs_t* req) {
DWORD access;
DWORD share;
DWORD disposition;
DWORD attributes;
DWORD attributes = 0;
HANDLE file;
int result, current_umask;
int flags = req->file_flags;
Expand All @@ -404,6 +404,7 @@ void fs__open(uv_fs_t* req) {
switch (flags & (_O_RDONLY | _O_WRONLY | _O_RDWR)) {
case _O_RDONLY:
access = FILE_GENERIC_READ;
attributes |= FILE_FLAG_BACKUP_SEMANTICS;
break;
case _O_WRONLY:
access = FILE_GENERIC_WRITE;
Expand All @@ -419,6 +420,7 @@ void fs__open(uv_fs_t* req) {
if (flags & _O_APPEND) {
access &= ~FILE_WRITE_DATA;
access |= FILE_APPEND_DATA;
attributes &= ~FILE_FLAG_BACKUP_SEMANTICS;
}

/*
Expand Down Expand Up @@ -453,7 +455,7 @@ void fs__open(uv_fs_t* req) {
goto end;
}

attributes = FILE_ATTRIBUTE_NORMAL;
attributes |= FILE_ATTRIBUTE_NORMAL;
if (flags & _O_CREAT) {
if (!((req->mode & ~current_umask) & _S_IWRITE)) {
attributes |= FILE_ATTRIBUTE_READONLY;
Expand Down

0 comments on commit 109e176

Please sign in to comment.