[Issue 2429] std.stream.File incorrect flag parsing and sharing mode

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 27 15:51:04 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2429





------- Comment #2 from jason at spashett.com  2008-11-27 17:51 -------
NOTES -

C:\temp>copy /y con test.txt
text <- text must be typed first for the file to be opened.


FileMode.OutNew has the same problem. No sharing mode at all is set in this
mode.

Linux/posix systems:

I am fairly sure that the unix code should also have a "share" (really
permission bits) mode of 666 (and not 660), read and write for all occasions.
The processes current umask is then automatically applied to restrict the
actual permission bits. [ the "share" mode, or in actually the mode bits passed
to std.c.linux.linux.open only apply when creating files ]

Linux example:
$umask
0022 (on my system - typical) allows permissions of 655 (rwxr-xr-x) or "less"
normal file creation asks for 666 (everything except execute bit & other
special permissions) yeilding:
$echo test > test.txt
$ls -l test.txt
-rw-r--r-- 1 user user 5 2008-11-27 23:39 test.txt

which is correct.


With D (Incorrect):
$rm test.txt
./test
ls -l test.txt
-rw-r----- 1 user user 5 2008-11-27 23:39 test.txt

read is missing from "others" permission, and so would write be if the umask
was 0020 or similar.

test.d
------------------------------------------
import std.stream;
import std.stdio;

void main()
{
        auto f = new File("test.txt", FileMode.OutNew);
        char[] s;
        s = readln();
}
------------------------------------------


-- 



More information about the Digitalmars-d-bugs mailing list