Skip to content

Commit

Permalink
Merge pull request #2948 from CyberShadow/pull-20150202-045026
Browse files Browse the repository at this point in the history
fix Issue 14110 - std.file.read cannot read files open for writing
  • Loading branch information
andralex committed Feb 2, 2015
2 parents 263c1cd + cb4463f commit accb351
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions std/file.d
Expand Up @@ -227,8 +227,8 @@ void[] read(in char[] name, size_t upTo = size_t.max) @safe

alias defaults =
TypeTuple!(GENERIC_READ,
FILE_SHARE_READ, (SECURITY_ATTRIBUTES*).init, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
FILE_SHARE_READ | FILE_SHARE_WRITE, (SECURITY_ATTRIBUTES*).init,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
HANDLE.init);
auto h = trustedCreateFileW(name, defaults);

Expand Down Expand Up @@ -331,6 +331,15 @@ version (linux) @safe unittest
//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)
can be a type of array of characters of any width and constancy. No
Expand Down

0 comments on commit accb351

Please sign in to comment.