Mercurial > projects > dil
diff src/dil/SourceText.d @ 818:372fa4fbbb1d
Added error messages and applied fixes.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Thu, 13 Mar 2008 02:21:26 +0100 |
parents | bcb74c9b895c |
children |
line wrap: on
line diff
--- a/src/dil/SourceText.d Wed Mar 12 23:33:14 2008 +0100 +++ b/src/dil/SourceText.d Thu Mar 13 02:21:26 2008 +0100 @@ -6,9 +6,12 @@ import dil.Converter; import dil.Information; +import dil.Location; +import dil.Messages; import common; import tango.io.File; +import tango.io.FilePath; /// Represents D source code. /// @@ -45,6 +48,19 @@ if (!infoMan) infoMan = new InfoManager; assert(filePath.length); + + scope(failure) + { + if (!(new FilePath(this.filePath)).exists()) + infoMan ~= new LexerError(new Location(filePath, 0), + MSG.InexistantFile); + else + infoMan ~= new LexerError(new Location(filePath, 0), + MSG.CantReadFile); + data = "\0"; + return; + } + // Read the file. auto rawdata = cast(ubyte[]) (new File(filePath)).read(); // Convert the data.