Comment #0 by verylonglogin.reg — 2012-09-11T13:15:52Z
---
import std.file: write;
import core.stdc.stdio: perror;
extern (C) nothrow int _wrename(in wchar* from, in wchar* to);
void main()
{
// write("1.txt", "123");
if(_wrename("1.txt"w.ptr, "2Ю.txt"w.ptr))
perror("Error renaming file");
}
---
Output:
---
Error renaming file: Invalid argument
---
if:
* there is no 1.txt file
* there is 1.txt file
* there is no 1.txt file and `write` is uncommented
Output:
---
Error renaming file: File exists
---
if:
* there is 1.txt file and `write` is uncommented
Comment #1 by verylonglogin.reg — 2012-09-11T13:27:31Z
These functions treats every UTF-16 codepoint as CP_ACP byte followed by zero byte (if second byte is non-zero, "Invalid argument" is returned). E.g. this will work:
---
import std.file: write;
import std.windows.charset: toMBSz;
import core.stdc.stdio: perror;
import std.exception: enforce;
extern (C) nothrow int _wrename(in wchar* from, in wchar* to);
void main()
{
write("1.txt", "123");
wchar[7] arr = "2#.txt\0"w;
arr[1] = toMBSz("Ю")[0];
enforce(_wrename("1.txt"w.ptr, arr.ptr) == 0);
}
---
(still don't understand "File exists" output of original example in description)
Comment #2 by github-bugzilla — 2012-09-16T20:45:19Z
Comment #4 by verylonglogin.reg — 2013-10-17T22:59:12Z
(In reply to comment #3)
> Increasing severity as this is really basic functionality.
One can use `std.stream` which contains this functionality.
Comment #5 by verylonglogin.reg — 2013-10-18T02:34:42Z
Assigned to myself. Reassign is somebody feels he can do it faster.
Comment #6 by verylonglogin.reg — 2013-10-19T03:02:11Z
(In reply to comment #5)
> Assigned to myself. Reassign is somebody feels he can do it faster.
Sorry, this is not the issue I'm solving. Reset assignee to default and opened Issue 11298 which will allow Issue 7648 to be resolved without fixing this one.
Comment #7 by dlang-bugzilla — 2014-02-14T11:30:26Z