mirror of
https://github.com/felixangell/phi.git
synced 2024-08-16 11:10:37 +03:00
parent
49e7bce3ea
commit
4706740b0f
@ -3,6 +3,7 @@ package gui
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"runtime"
|
||||
@ -79,6 +80,15 @@ func (b *Buffer) OpenFile(filePath string) {
|
||||
b.languageInfo = lang
|
||||
}
|
||||
|
||||
// if the file doesn't exist, try to create it before reading it
|
||||
if _, err := os.Stat(filePath); os.IsNotExist(err) {
|
||||
if f, err = os.Create(filePath); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
f.Close()
|
||||
}
|
||||
}
|
||||
|
||||
contents, err := ioutil.ReadFile(filePath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
Loading…
Reference in New Issue
Block a user