Question
· Sep 6, 2019

%File: Method Exists returns TRUE also for directories?

Hello,

I had an issue when using the method Exists, I noticed that if you provide a directory for this method it returns 1.
This is really misleading, because sometimes the input could be a directory and the only way to predict this is to also test if the file is a directory.

I didn't tested using the Attributes method, but I supposed that this means could also be a solution for that issue.
But still, I expected the Exists method to return 1 for files and 0 for directories, since there's also method called DirectoryExists already.

write ##class(%File).Exists("/InterSystems")
1

Would you guys classify this as a bug or as an intended behavior?

PS: Evgeny, what do you think of adding a Post type called Information? I think the one I used is not adequate, but I had no options since the other types seemed lesser adequate.

Discussion (4)0
Log in or sign up to continue

It is not actually a bug, it mostly expected behavior. I'm not sure about Windows (just, too lazy to check it there), but in *nix systems, folders and files just act almost exactly the same way, there only one difference in one flag, D for directories. And if you would like to check the difference just look at the method DirectoryExists also in the %Library.File class

Hi, Rubens!

PS: Evgeny, what do you think of adding a Post type called Information? I think the one I used is not adequate, but I had no options since the other types seemed lesser adequate.

Thank you! It's a good idea.  You always can submit a feature request for DC. I would say that this looks like a public discussion around product feature requests, right? To have DC as a sort of idea-portal.

Maybe we'll introduce something like this. But in order to have this more than conversation and to have some follow up on product development, we need to discuss it with Product management.

For now, I think this is more of type Question than Article.