03-07-2023 09:41 AM
Hello!
There is this LV internal VI to check if a file/folder exists, which would return a boolean. When opening the front panel, the path box is empty. When running the VI, see below, it would return TRUE, meaning the not given path exists. That makes me wonder what the definition of the existence of a file or folder is...😮
03-07-2023 09:43 AM - edited 03-07-2023 09:46 AM
The empty path is in LabVIEW indeed a valid path for some functions.
It is in fact the root to all paths. Under Windows this is the (virtual) path in which all the drives are located. Under Unix this is the root path itself "/".
If you use for instance List Folders with an empty path as input you get under Windows all the valid drive letters, and under Unix all the top level directories. Under Mac with HFS you got all the Volumes on the desktop but HFS is not used anymore in LabVIEW for Mac since the demise of the 32-bit version of this with LabVIEW 2017. The 64-bit version of LabVIEW for Mac always used Posix style paths, just as the Linux version.
So in summary the Empty Path definitely is a valid path in LabVIEW as it is the root of the file system/desktop.
03-07-2023 01:40 PM
For future reference, you can also find this info in the help file. And if you think rolfk copied that response from the help file, you would be wrong. In fact, quite the opposite. The help file was written based on information in rolfk's brain.
03-08-2023 03:10 AM - edited 03-08-2023 03:10 AM
OK, but you would want to use the VI to find out if a file or folder exists, and no path given is not an existing folder, no matter how LV interpret an empty path. At least in this case the LED shouldn't light up. I will modify the VI now.
03-08-2023 08:09 AM
@MaSta wrote:
OK, but you would want to use the VI to find out if a file or folder exists, and no path given is not an existing folder, no matter how LV interpret an empty path. At least in this case the LED shouldn't light up. I will modify the VI now.
I don't understand this statement. Wouldn't you just use ?
03-08-2023 08:38 AM - edited 03-08-2023 08:39 AM
If you don't want to allow empty paths, just do a check for them using the comparison function "Is Path and Not Empty?" The underlying code for the "Check if File/Folder Exists" can't be modified. That is the "File/Directory Info". So now you will have one function that returns false and another function that returns true for the same request. Makes zero sense but you're certainly allowed to do stupid things.
03-08-2023 11:04 AM
@aputman wrote:
If you don't want to allow empty paths, just do a check for them using the comparison function "Is Path and Not Empty?" The underlying code for the "Check if File/Folder Exists" can't be modified. That is the "File/Directory Info". So now you will have one function that returns false and another function that returns true for the same request. Makes zero sense but you're certainly allowed to do stupid things.
I guess I just never really understood the whole topic because I always make sure that by the time it gets to this point, we aren't looking at an empty path. Not that it wasn't a valid concern; it was that because of my workflow, it never occurred to me that someone would be trying to do a check with possibly an empty path.
03-08-2023 12:09 PM
@billko wrote
I guess I just never really understood the whole topic because I always make sure that by the time it gets to this point, we aren't looking at an empty path. Not that it wasn't a valid concern; it was that because of my workflow, it never occurred to me that someone would be trying to do a check with possibly an empty path.
I agree with you. I just think it's a stupid decision to modify core LabVIEW code when there are tools to make sure an empty path is avoided.
03-09-2023 11:24 AM
@billko wrote:
@MaSta wrote:
OK, but you would want to use the VI to find out if a file or folder exists, and no path given is not an existing folder, no matter how LV interpret an empty path. At least in this case the LED shouldn't light up. I will modify the VI now.
I don't understand this statement. Wouldn't you just use ?
I think what you want is something like this...
Adjust the last AND input as required.
03-09-2023 11:58 AM
@Frozen wrote:
@billko wrote:
@MaSta wrote:
OK, but you would want to use the VI to find out if a file or folder exists, and no path given is not an existing folder, no matter how LV interpret an empty path. At least in this case the LED shouldn't light up. I will modify the VI now.
I don't understand this statement. Wouldn't you just use ?
I think what you want is something like this...
Adjust the last AND input as required.
That's pretty much what I would do, except if you look in that Check if File or Folder exists, there already is a File/Directory Info inside and if you do not need the ability to detect files inside LLBs, you might just do this function once. It is not a huge performance killer to call it twice, but he LLB enumeration is and you do not want that function really get called in a tight loop as that for sure can make everything very slow.