#Odin check command not outputting errors after opening file

1 messages · Page 1 of 1 (latest)

harsh dawn
#

I'm developing a text editor which opens files like this:

handle, errno := os.open(file_path, os.O_RDWR);
text, success := os.read_entire_file_from_handle(handle, context.temp_allocator);

But then something strange happens, if I run the odin check command in a separate Windows terminal, it fails to output errors in the file I opened using the above code in my text editor.

So the following happens

  1. Run odin check on a directory containing file A. It outputs errors for file A.
  2. Open file A using my text editor
  3. Run the same odin check command. This time, no errors are output for file A.

I'm thinking the problem is possibly related to the share mode when I open the file. Maybe my editor is holding the file hostage with exclusive access which is doing something funky to the odin check command. I checked the os.open() source and it does enable a share flag for reading and writing:
https://github.com/odin-lang/Odin/blob/fd582015fe2bbaabc42f78caefec1bd95f4d1465/core/os/file_windows.odin#L32

So I'm not sure why this would be happening, any ideas?

harsh dawn
#

If I close the file with the following code, the issue does go away.

handle, errno := os.open(file_path, os.O_RDWR);
text, success := os.read_entire_file_from_handle(handle, context.temp_allocator);
os.close(handle);

But I was planning on keeping the file open so I can write to it at an aribtrary time. Maybe that's bad practice? Should I just re-open the file when I'm ready to write to it instead of keeping it open with a handle laying around? Is that how text editors operate on files?

spare pulsar
#

Weird behaviour indeed

#

but yeah text editors usually don't keep files open

#

from what i've seen in the wild