1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

util: split bom checking to a separate fn (#6694)

This commit is contained in:
Ned Palacios 2020-10-30 00:21:08 +08:00 committed by GitHub
parent be02ee97fb
commit 7b5a580c0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -223,9 +223,14 @@ pub fn path_of_executable(path string) string {
}
pub fn read_file(file_path string) ?string {
mut raw_text := os.read_file(file_path) or {
raw_text := os.read_file(file_path) or {
return error('failed to open $file_path')
}
return skip_bom(raw_text)
}
pub fn skip_bom(file_content string) string {
mut raw_text := file_content
// BOM check
if raw_text.len >= 3 {
unsafe {