Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

fix fs_readdir_file on windows

  • Loading branch information...
Igor Zinkovsky
Igor Zinkovsky committed Oct 12, 2011
1 parent 2216d38 commit 81303a72bedc92a5dbfdc4a79df515faacdbf81f
Showing with 11 additions and 2 deletions.
  1. +11 −2 src/win/fs.c
@@ -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;
}

@@ -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");
}

3 comments on commit 81303a7

@luislavena

This comment has been minimized.

Copy link
Contributor

replied Oct 12, 2011

Hello,

Wanted to know why go over ANSI instead of Wide? why not use wide functions and wide buffers instead?

Using ANSI to read non-latin directories might cause issues (at least the ones I have faced dealing with Ruby)

Thank you.

@igorzi

This comment has been minimized.

Copy link

replied Oct 12, 2011

See 72b5976.

@luislavena

This comment has been minimized.

Copy link
Contributor

replied Oct 12, 2011

Thank you, somehow that commit didn't display on my feed, apologies for the noise.

Please sign in to comment.
You can’t perform that action at this time.