Last active
December 12, 2015 08:24
-
-
Save Einlander/c6fdf2560486315921c2 to your computer and use it in GitHub Desktop.
Read entire text file at once
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //load file to mem | |
| import "ecere" | |
| void file_read(const String filename) | |
| { | |
| // with code from http://rosettacode.org/wiki/Read_entire_file#C | |
| char *buffer; | |
| File FileHandler = FileOpen(filename, read); | |
| if (FileHandler) | |
| { | |
| buffer = malloc(FileHandler.GetSize()); | |
| if (buffer != null) | |
| { | |
| FileHandler.Read(buffer,FileHandler.GetSize(),1); | |
| FileHandler.Close(); | |
| PrintLn(buffer); | |
| } | |
| }else{ | |
| PrintLn("File not loaded"); | |
| } | |
| PrintLn("Done"); | |
| } | |
| class HelloApp : Application | |
| { | |
| void Main() | |
| { | |
| file_read("vert.vert"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment