Skip to content

Commit

Permalink
fix fs_readdir_file on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Zinkovsky committed Oct 12, 2011
1 parent 2216d38 commit 81303a7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/win/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ void fs__open(uv_fs_t* req, const char* path, int flags, int mode) {
}

/* Figure out whether path is a file or a directory. */
if (GetFileAttributesW(path) & FILE_ATTRIBUTE_DIRECTORY) {
if (GetFileAttributesA(path) & FILE_ATTRIBUTE_DIRECTORY) {
attributes |= FILE_FLAG_BACKUP_SEMANTICS;
}

Expand Down Expand Up @@ -367,11 +367,20 @@ void fs__readdir(uv_fs_t* req, const char* path, int flags) {
WIN32_FIND_DATAA ent = {0};
size_t len = strlen(path);
size_t buf_size = 4096;
char* path2;
const char* fmt = !len ? "./*"
: (path[len - 1] == '/' || path[len - 1] == '\\') ? "%s*"
: "%s\\*";

char* path2 = (char*)malloc(len + 4);
/* Figure out whether path is a file or a directory. */
if (!(GetFileAttributesA(path) & FILE_ATTRIBUTE_DIRECTORY)) {
req->result = -1;
req->errorno = UV_ENOTDIR;
req->last_error = ERROR_SUCCESS;
return;
}

path2 = (char*)malloc(len + 4);
if (!path2) {
uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
}
Expand Down

0 comments on commit 81303a7

Please sign in to comment.