mirror of
https://github.com/dlang/phobos.git
synced 2025-05-14 08:55:54 +03:00
Merge pull request #2948 from CyberShadow/pull-20150202-045026
fix Issue 14110 - std.file.read cannot read files open for writing
This commit is contained in:
commit
accb351b96
1 changed files with 11 additions and 2 deletions
13
std/file.d
13
std/file.d
|
@ -227,8 +227,8 @@ void[] read(in char[] name, size_t upTo = size_t.max) @safe
|
||||||
|
|
||||||
alias defaults =
|
alias defaults =
|
||||||
TypeTuple!(GENERIC_READ,
|
TypeTuple!(GENERIC_READ,
|
||||||
FILE_SHARE_READ, (SECURITY_ATTRIBUTES*).init, OPEN_EXISTING,
|
FILE_SHARE_READ | FILE_SHARE_WRITE, (SECURITY_ATTRIBUTES*).init,
|
||||||
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
|
||||||
HANDLE.init);
|
HANDLE.init);
|
||||||
auto h = trustedCreateFileW(name, defaults);
|
auto h = trustedCreateFileW(name, defaults);
|
||||||
|
|
||||||
|
@ -331,6 +331,15 @@ version (linux) @safe unittest
|
||||||
//writefln("'%s'", s);
|
//writefln("'%s'", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@safe unittest
|
||||||
|
{
|
||||||
|
scope(exit) if (exists(deleteme)) remove(deleteme);
|
||||||
|
import std.stdio;
|
||||||
|
auto f = File(deleteme, "w");
|
||||||
|
f.write("abcd"); f.flush();
|
||||||
|
assert(read(deleteme) == "abcd");
|
||||||
|
}
|
||||||
|
|
||||||
/********************************************
|
/********************************************
|
||||||
Read and validates (using $(XREF utf, validate)) a text file. $(D S)
|
Read and validates (using $(XREF utf, validate)) a text file. $(D S)
|
||||||
can be a type of array of characters of any width and constancy. No
|
can be a type of array of characters of any width and constancy. No
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue