4 ms·
But if you rely on these subtleties this is hardly a "basic feature" that the language is lacking. In fact, I imagine File.Exists()/OF_EXISTS also opens the fil
by AshamedCaptain 2y ago
But if you rely on these subtleties this is hardly a "basic feature" that the language is lacking. In fact, I imagine File.Exists()/OF_EXISTS also opens the file (then immediately closes it).
- Brian_K_White 2y agoIt better not! If you actually open a file, you update it's access time, and you interfere with the process that should actually open the file. Those both break perfectly simple business logic.
- deleted 2y ago[deleted]
- AshamedCaptain 2y agoThe documentation for OF_EXISTS literally says it will open then close it. I leave to your imagination whether this updates the (very poorly defined) access time or not, but for sure you "interfere" with other processes... If you want to get the access time, why don't you just query the access time? Which is likely the only thing almost universally guaranteed not to change it... And I'm sure VB6 has an API for that, considering that VBA had a global API for it (FileDateTime). (Which is, btw, yet another way to one-line check if a file exists).
- Brian_K_White 2y agoDid you confuse the file with it's containing directory? The way you probably did in your now-deleted comment claiming that stat() updated atime? Citation needed. https://learn.microsoft.com/en-us/dotnet/api/system.io.file.exists?view=net-8.0 https://learn.microsoft.com/en-us/dotnet/api/system.io.file.... doesn't warn of any such thing.
- deleted 2y ago[deleted]
- AshamedCaptain 2y ago> Did you confuse the file with it's containing directory? No. > Citation needed. https://learn.microsoft.com/en-us/dotnet/api/system.io.file https://learn.microsoft.com/en-us/dotnet/api/system.io.file.... doesn't warn of any such thing. https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-openfile https://learn.microsoft.com/en-us/windows/win32/api/winbase/... OF_EXIST: Opens a file and then closes it.
- Brian_K_White 2y agoIt's literally open file ! Are you dense? OpenFile() opens the file??? c'est incroyable! OF_EXISTS is just a side effect of some actual operation. It's some related info you you get along the way. You would not use that as the way to only check the file. Holy cow. Please do continue trying to spread the wisom.
- AshamedCaptain 2y agoYou are the one claiming that OpenFile(OF_EXIST) does not open the file. Scroll a bit above. My initial comment was: > In fact, I imagine File.Exists()/OF_EXISTS also opens the file (then immediately closes it).
- Brian_K_White 2y ago"You are the one claiming that OpenFile(OF_EXIST) does not open the file." I never said any such thing. Yet another trivially verified false statement. Fits the pattern.
- AshamedCaptain 2y agoHey, I am also a fan of the argument clinic sketch from Monty Python. Let me try to jump in: If you didn't say any such thing, then why did you bother countering my comment at https://news.ycombinator.com/item?id=42107195 https://news.ycombinator.com/item?id=42107195 ? Aha! Gotcha!