Create empty file if input doesn't exist

This commit is contained in:
Zachary Yedidia
2016-03-12 16:07:04 -05:00
parent 8072756990
commit 934634507d
4 changed files with 22 additions and 3 deletions

View File

@@ -12,12 +12,24 @@ void main(string[] args) {
if (args.length > 1) {
filename = args[1];
fileTxt = readText(filename);
if (!exists(filename)) {
File file = File(filename, "w");
file.close();
} else {
if (isDir(filename)) {
writeln(filename, " is a directory");
return;
}
fileTxt = readText(filename);
if (fileTxt is null) {
fileTxt = "";
}
}
}
Buffer buf = new Buffer(fileTxt, filename);
init();
Buffer buf = new Buffer(fileTxt, filename);
Cursor cursor = new Cursor();
View v = new View(buf, cursor);