Giter Club home page Giter Club logo

dirent's People

Contributors

anzz1 avatar bkaradzic avatar c72578 avatar cxxsucks avatar danielmelody avatar geerjasaumya avatar jadogg avatar jjones4 avatar mohanex avatar myd7349 avatar petk avatar pfultz2 avatar scribam avatar seriouslynottom avatar tronkko avatar vinchona avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dirent's Issues

Running on Ubuntu

Hi. I found your API very usefull and easy to use on my small project I started on Windows,
I just had to do #include "dirent.h" and everything worked perfect.

However, I wish to make my program runnable on Ubuntu, but it obviously won't compile due to windows functionality inclusions/dependency on your code... Is dirent even intended to work on Linux distributions?

Is it possible to get my program to run on Ubuntu with none to minimal functionality alterations?
This is what my program does, and how it includes your functionalities, in case it where relevant:
https://gist.github.com/Mangonels/5e35a34594ceb5c2907dcdeefa80bc0c

Thank you!

`opendir` doesn't handle path string properly with Russian localization.

opendir doesn't handle path string properly with Russian localization.

OS: Windows 7

Localization: Russian

Steps to reproduce it:

* (Important) Set your Windows' formatting localization to Russian in the Control Panel
* Pass "Мои Документы" (My Documents in Russian) to `opendir`
* You'll find `mbstowcs_s` doesn't convert it correctly
/* Open directory stream using plain old C-string */
static DIR *opendir(const char *dirname)
{
	...

	/* Convert directory name to wide-character string */
	wchar_t wname[PATH_MAX + 1];
	size_t n;
	int error = mbstowcs_s(&n, wname, PATH_MAX + 1, dirname, PATH_MAX+1);
	if (error)
		goto exit_failure;

	...
}

Possible fix: use MultiByteToWideChar instead of mbstowcs_s

/* Open directory stream using plain old C-string */
static DIR *opendir(const char *dirname)
{
	...

	/* Convert directory name to wide-character string */
	wchar_t wname[PATH_MAX + 1];
	int written = MultiByteToWideChar(CP_ACP, 0, dirname, -1, wname, PATH_MAX + 1);
	if (written == 0)
		goto exit_failure;

	...
}

Add a tag/release

Would be nice to have a tag/release here to indicate what we should use and a version that gives us some context relative to previous releases.

VC\include directory not found

Microsoft Visual Studio 2010
for _WIN64, file added locally.
Tried it, it doesn't work, lots of errors:

dirent.h(422): warning C4067: unexpected tokens following preprocessor directive - expected a newline
dirent.h(422): warning C4067: unexpected tokens following preprocessor directive - expected a newline
dirent.h(443): warning C4067: unexpected tokens following preprocessor directive - expected a newline
dirent.h(443): warning C4067: unexpected tokens following preprocessor directive - expected a newline
dirent.h(406): error C2275: '_WDIR' : illegal use of this type as an expression dirent.h(281) : see declaration of '_WDIR'
dirent.h(406): error C2065: 'dirp' : undeclared identifier
dirent.h(407): error C2065: 'dirp' : undeclared identifier
dirent.h(411): error C2065: 'dirp' : undeclared identifier
dirent.h(411): error C2223: left of '->handle' must point to struct/union

Bad `scandir` prototype

My installation of Linux has the following prototype for scandir:

extern int scandir (const char *__restrict __dir,
		    struct dirent ***__restrict __namelist,
		    int (*__selector) (const struct dirent *),
		    int (*__cmp) (const struct dirent **,
				  const struct dirent **))

The difference between void (your dirent) and dirent (Linux) pointers for compare causes problems in our project. Depending on the enabled warnings, you can't even pass alphasort (which uses dirent pointers in your code) to scandir. A Visual Studio warning recommends to cast it, and that includes the __cdecl convention - a macro which does not exist on other compilers.
So people patch this code for Visual Studio and by adding the cast, they break other platforms.

This cast should not be necessary in the first place - why is the prototype like this?
Can the prototype in your dirent.h be changed to use dirent pointers (on this repo)?

Reconsider the need for an error code variable in two functions

How do you think about an implementation of the functions “opendir” and “_wopendir” which can work without the local variable “error” if the source code would be adjusted in the way that the desired exception handling will be achieved by using goto statements?
Would you like to avoid an extra condition check at their ends?

opendir method can not open folder named by chinese

Hello, tronkko.
Thank you for your unselfish work. I tested your programs and find one problem. That opendir method can not open folders named by chinese. It seems chinese word is wide charactor itself. Can you help to solve this problem? To make it work well both in English and Chinese.

Best Regards.

Xikang

Include other common unix headers that are also included in git?

It would be nice if this also included the headers ported to windows that are conveniently in this tar.gz file. (Note these was ripped from, a friend's linux install and I definitely need these to compile git with Visual Studio so that way it would become standalone and would not require cygwin or mingw to work and so I can easily drop the compiled git.exe in the windows directory and use it just fine.) I need it like this so I can do just that so I can use subprocess in python to open up git to get an lazy changelog to stuff. Also it would allow me to uninstall git for windows, mingw (trash), Github Desktop (trash gui), and also cygwin (also trash). The command line tool is by far the least trashy so I want to be able to build a pure windows build using MSVC.

to_port.tar.gz

By far your header helped on it as well.

Adding example

Hello,

I passed by this beautiful repo, and It was very helpful for one of my projects and I want to contribute to it by adding a code example that uses dirent library on visual studio to scan directories and list files with a specefic extension.
I wanted to do a pull request, but I need to be a contributor can you grant me that?

Thanks.

MSVC 14.27.29110 Fails to Compile

C2362- Initialization of 'p' is skipped by 'goto exit_closedir' - line 414
C2362 - Initialization of 'ok' is skipped by 'goto exit_failure' - line 760

Compilation error in Visual Studio 2013

Hi,

I have the following error on Visual Studio 2013, since the addition of scandir():

C:\projects\dirent\include\dirent.h(917): error C2440: '=' : cannot convert from 'void *' to 'dirent *' [C:\projects\n2d2\build\N2D2-OS.vcxproj]
Conversion from 'void
' to pointer to non-'void' requires an explicit cast
C:\projects\dirent\include\dirent.h(968): error C2664: 'void qsort(void *,size_t,size_t,int (__cdecl *)(const void *,const void *))' : cannot convert argument 4 from 'void *' to 'int (__cdecl *)(const void *,const void *)' [C:\projects\n2d2\build\N2D2-OS.vcxproj]

PATH_MAX not defined in find.c

Hello Toni,

Thanks for the libs. Good job.

I am using MacOS X, clang compiler. When trying to compile find.c, it rejects it because of
'PATH_MAX not defined or used'

PATH_MAX seems to be the max length of the files & directories names listed. So I fix it to 255 and it just works fine.

I hope you spend a fantastic day.
Thanks,
Harry

WinRT support

dirent.h doesn't support WinRT for a few reasons:

  • #including windef.h directly causes fatal error C1189: #error : "No Target Architecture"
  • FindFirstFileW isn't available
  • GetFullPathNameW isn't available

I think WinRT support can be added while maintaining compatibility with Win32:

Version info in dirent-1.23.2 release

The version info in
src/dirent.h
is still at 1.23.1 instead of 1.23.2 in the top comment of the file in case of the released files:
https://github.com/tronkko/dirent/archive/1.23.2.zip
https://github.com/tronkko/dirent/archive/1.23.2.tar.gz

/*
 * Dirent interface for Microsoft Visual Studio
 * Version 1.23.1
 *
 * Copyright (C) 2006-2012 Toni Ronkko
 * This file is part of dirent.  Dirent may be freely distributed
 * under the MIT license.  For all details and documentation, see
 * https://github.com/tronkko/dirent
 */

This can be corrected in the next release ...

error C2440: "=": Can not convert from "void *" to "dirent **"

Visual Studio 2017 && Windows 10

error C2440: "=": Can not convert from "void *" to "dirent **"
error C2664: "void qsort (void *, :: size_t, :: size_t, _CoreCrtNonSecureSearchSortCompareFunction)": Can not convert parameter 4 from "void *" to "_CoreCrtNonSecureSearchSortCompareFunction"

When I use your .h in my project , the vs2017 said like it . I don't know what's the matter with it...

CONTRIBUTING.md deserves an update!

Unlike other amazing repos, this repo's CONTRIBUTING.md looks plain and simple.

i think emojified, fun and precise version would be better!

Describe alternatives you've considered
An update would be amazing!

Additional context
If you are reading this, you are amazing! ⭐

Starred ⭐✔️

Thanks and regards,
Himanshu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.