NO

Author Topic: Missing _wopendir()  (Read 7804 times)

Offline mul

  • Member
  • *
  • Posts: 4
Missing _wopendir()
« on: March 05, 2021, 07:12:48 AM »
Hi all,

I am missing in the header file dirent.h the wchar_t version of the _opendir(const char *) function, such as _wopendir(const wchar_t *).

Did I miss something?

Thank you for help.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Missing _wopendir()
« Reply #1 on: March 05, 2021, 08:19:57 AM »
opendir is only POSIX function, not C99 nor C11.
May the source be with you

Offline mul

  • Member
  • *
  • Posts: 4
Re: Missing _wopendir()
« Reply #2 on: March 05, 2021, 03:03:23 PM »
Hello TimoVJL,

Thanks for the answer.

It's a pity, because it would be a useful addition, as other functions for directory handling like _wgetcwd() or _wchdir() work very well.

I would use this function to change to the (german) Windows directory "Öffentliche Musik" (public music).

I know there are other solutions for this, it would just be the easiest and safest way.

Offline John Z

  • Member
  • *
  • Posts: 860
Re: Missing _wopendir()
« Reply #3 on: March 05, 2021, 11:51:30 PM »
Hi Mul,

Perhaps I misunderstand your statement :
It's a pity, because it would be a useful addition, as other functions for directory handling like _wgetcwd() or _wchdir() work very well.

I would use this function to change to the (german) Windows directory "Öffentliche Musik" (public music).
Pelles C does support _wchdir()  to change to a Unicode directory, and _wgetcwd()..  include <direct.h>
So if you are just looking to change directories to Windows directory "Öffentliche Musik" then _wchdir(const wchar_t *);
will work for you.

John Z

Offline mul

  • Member
  • *
  • Posts: 4
Re: Missing _wopendir()
« Reply #4 on: March 06, 2021, 05:06:03 PM »
Hello John,

thank you for this answer.
Maybe it is difficult for me to explain my problem.

Yes, I can change to a Unicode directory by _wchdir(). But if I will open this directory to read the entries in it, then only the function _opendir() is available. Not available is _wopendir().

Also I code:  _opendir(_getcwd()) to open a directory, this works fine.
But it is not possible to code: _wopendir(_wgetcwd()), because _wopendir() doesn't exist !!

Therefore it would be nice to have this missing function to complete the set of functions for Unicode directory handling.

mul

Offline John Z

  • Member
  • *
  • Posts: 860
Re: Missing _wopendir()
« Reply #5 on: March 06, 2021, 05:43:56 PM »
Hi Mul,

Thanks - I understand now what you are looking for with that function  :)
If it existed I'd probably have used it too. 

I used a workaround in a Windows GUI program, that might also work
in a Windows Console program although I've not tried it there. But it is
only for Windows so it may be of no help.  I use an "invisible" Dir box to
get Unicode directory listing for directories.  Definitely more overhead than
the function call - but sometimes you just gotta get it done anyway you can.

RetVal = DlgDirListW(hwndDlg,p_data,DirBox,Invisible,DDL_DIRECTORY);

Then I can process the list of directories as needed.


Regards,
John Z

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: Missing _wopendir()
« Reply #6 on: March 06, 2021, 06:20:05 PM »
Why not use the Windows API for getting the short, 8.3, path?
In general all foreign, not English, folder names are only junctions that point to the English folders since Windows 7, use "dir /a" in a command prompt.
If the code is not cross platform using system functions of the operating system API would be a good workaround until the functions for wide characters are available.
In addition you could use the regular findfirst, findnext, etc. functions.
« Last Edit: March 06, 2021, 06:22:15 PM by Stefan Pendl »
---
Stefan

Proud member of the UltraDefrag Development Team

Offline John Z

  • Member
  • *
  • Posts: 860
Re: Missing _wopendir()
« Reply #7 on: March 06, 2021, 09:52:54 PM »
Thanks Stefan,

One issue with that approach is if you use, for instance, a recent directory list similar to a recent file list. The end user would be confused by the 8.3 which looks nothing like the non-English directory name.

John Z

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: Missing _wopendir()
« Reply #8 on: March 07, 2021, 08:39:18 AM »
OK, so for display one could use the long path, which is already present, since we got the short path from it.
The best approach until Pelle has decided to implement the wide character functions, is to build wrappers on your own that mimic the missing functions, using the _wfindfirst64, _wfindnext64 and _findclose functions.
---
Stefan

Proud member of the UltraDefrag Development Team

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Missing _wopendir()
« Reply #9 on: March 07, 2021, 09:12:39 AM »
May the source be with you

Offline mul

  • Member
  • *
  • Posts: 4
Re: Missing _wopendir()
« Reply #10 on: March 07, 2021, 12:29:17 PM »
Thanks to all.

I think the reference to the _wfind... functions is the best solution for me.

mul

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Missing _wopendir()
« Reply #11 on: March 10, 2021, 02:15:35 PM »
IIRC, most _wsomething() functions had an implementation somewhere that was relevant to support (more or less, some years ago). I have never seen a _wopendir() function. Not a big deal to add, but I'm not sure how useful it is to add yet another non-standard function, especially since it's just a wrapper around findfirst*/findnext*.
/Pelle