Bug 5927 – Broken getcwd when using GetCurrentDirectoryA

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2011-05-04T10:27:00Z
Last change time
2015-06-09T05:10:43Z
Assigned to
nobody
Creator
verylonglogin.reg

Comments

Comment #0 by verylonglogin.reg — 2011-05-04T10:27:28Z
On Windows 98 getcwd returnes path in windows multy-byte format (not ASCII), but should convert it to utf-8 first. And it leads to utf-8 validation exception in std.utf. File: src\phobos\std\file.d Trivial solution: -1704: auto dir = new char[enforce(GetCurrentDirectoryA(0, null), "getcwd")]; dir = dir[0 .. GetCurrentDirectoryA(dir.length, dir.ptr)]; cenforce(dir.length, "getcwd"); return assumeUnique(dir); +1704: auto dirA = new char[enforce(GetCurrentDirectoryA(0, null), "getcwd")]; GetCurrentDirectoryA(dirA.length, dirA.ptr); string dir = fromMBSz(cast(immutable)dirA.ptr); enforce(dir.length, "getcwd"); return dir;
Comment #1 by andrej.mitrovich — 2011-05-04T17:54:18Z
This is silly. Do you expect the Phobos library to work around every single Windows bug for outdated Windows operating systems that not even Microsoft supports? Win98 support ended in 2006, I really don't see why anyone would care for this OS, D isn't legacy software.
Comment #2 by verylonglogin.reg — 2011-05-04T23:51:02Z
(In reply to comment #1) > This is silly. Do you expect the Phobos library to work around every single > Windows bug for outdated Windows operating systems that not even Microsoft > supports? > > Win98 support ended in 2006, I really don't see why anyone would care for this > OS, D isn't legacy software. First. Why silly? If Phobos doesn't support Win98, why there are lots of code to support if? If this code exists it should work. If Win98 realy isn't supported, all such code should be removed. Second. It isn't a bug of Win98. It's a bug of Phobos.