Odin icon indicating copy to clipboard operation
Odin copied to clipboard

Linux: Fix missing file error reported by #load

Open corruptmemory opened this issue 3 years ago • 2 comments

Under Linux (and other *nix) realpath will return NULL when resolving a given path if the file or path does not exist. When this happens the error message returned by #load during compile time will display an error with a missing file name or path.

Given the following program:

package main

import "core:fmt"

main :: proc() {
  stuffs := #load("test.file")
  fmt.printf("stuffs %v\n", stuffs)
}

If the file test.file is missing or the path is invalid you would get the following error:

Failed to `#load` file: ; invalid file or cannot be found

However, the correct behavior should be:

Failed to `#load` file: test.file; invalid file or cannot be found

This PR corrects this

corruptmemory avatar Dec 06 '21 03:12 corruptmemory

I see that there is a MacOS failure. I'm presuming this is related to my change. However, I do not have access to a Mac to see what I can do to fix it.

corruptmemory avatar Dec 06 '21 03:12 corruptmemory

The failed test seems to have succeeded on my fork: https://github.com/corruptmemory/Odin/runs/4425775225?check_suite_focus=true

corruptmemory avatar Dec 06 '21 03:12 corruptmemory