03-28-2016 12:40 PM
So I'm not sure how to classify this but for now I'm going to say bug. Lets say I want to create a folder with the path:
C:\ Temp
Where there is a space character before and after the word Temp. Apparently have a trailing space in a folder name, or having a folder name start with a space, is something that can happen in a Windows file system, but generally should be avoided. Windows Explorer under normal circumstances won't allow you to make folders like this.
Using the primitive Create Folder, you can make folders that start with spaces, but you cannot make folders that end in spaces. But where I believe there is a bug, is in regards to the output of this function which returns the "Created Path". If I tell this function to create a folder at "[Space]Temp[Space]", it actually makes a folder at "[Space]Temp", but the output in the Created Path returns [Space]Temp[Space]. When this happens there is no error, or warning.
Another thing that might be unexpected behavior, is if you try to create the following folder.
C:\Temp \abcd
In this case you would expect the function to create first the Temp[Space] folder, and then the abcd folder. But instead it creates the Temp folder (without space) and then errors out because it cannot create the abcd folder, because Temp[Space] doesn't exist.
Now I'm fine with someone saying "Well just don't make folders that start, or end with spaces" and I totally agree with that and in the future I will try to avoid that. But right now I have an automated process that reads into a database, and creates a folder based on one of the record sets, and someone accidentally ended that entry in a space. I'd expect this error to be handled a little more gracefully, since the function was able to make a folder when called.
My opinion is, regardless if this should be allowed, I believe the Create Folder should handle this more gracefully. It should return the actual folder created, not the path it believes it is going to create, and when making folders in this folder, it should actually make them. So If I asked to create C:\Temp \abcd it should actually create C:\Temp\abcd instead of what it does now, which is makes C:\Temp, then throws an error.
Seen on Windows 7 x64, LabVIEW 2015 32-bit.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
03-28-2016 02:10 PM
Hooovah, I agree with mnay points, but it is always better that a primitive produces an error instead of changing its behavior based on what you told it to do. If you asked for a space, but can't it shodl certainly not change that, but throw the error as it does. You can easily use the "Trim whitespace" to prepare a path before creating the folders, but functions need to be explicit, or they become very dangerous to use, so its up to you to add this, not the create folder. Just my $0.02.
03-28-2016 02:22 PM
I got bit by a folder that ended in a space some years ago.
Winodws will not let you delete it since it does not understand a trailing space.
Question:
Coul dthis be a cross-platfrom issue in that other platoforms do not mind a trailing space?
Not that I know anything...
Ben
03-28-2016 02:37 PM
@Ben wrote:Coul dthis be a cross-platfrom issue in that other platoforms do not mind a trailing space?
I do not know about the Mac, but Linux does not even allow spaces in paths. So it is an even bigger issue there.
03-28-2016 03:06 PM - edited 03-28-2016 03:13 PM
@Mike_King wrote:but it is always better that a primitive produces an error instead of changing its behavior based on what you told it to do
Well with that logic this is still a bug then. Because if I ask it to create a folder with a trailing space, it will generate a folder without a trailing space, and throw no error or warning. The only time this situation causes an error is if you asked it to create a folder in a folder that didn't exist yet, which ends in a space. Here are several optional improvements.
Improvement 1: When a folder with a trailing space is requested to be made, throw an error and do nothing.
Improvement 2: When a folder with a trailing space is requested to be made, make the folder without the space, and have the output of the Created Path, be the actually created path. Maybe throw a warning?
Improvement 3: When a folder is being made, in a folder with a trailing space, make the folder in the folder without the trailing space, and throw no error. Mabye throw a warning?
Improvement 4: When a folder is being made, in a folder with a trailing space, throw an error and do nothing. Instead of right now, where it will make the first folder without the space, then throw an error.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
03-28-2016 05:20 PM
Ah, Ben beat me to this point... What it does now IS graceful (at least conpared to the old situation). I also once ended up with a folder I couldn't use or delete. Don't remember what I fiunally did to resolve the issue, but I remember that it was a pain!
Mike...
03-29-2016 07:32 AM
@mikeporter wrote:What it does now IS graceful (at least conpared to the old situation).
Okay I agree having a folder on a file system, that the native OS explorer can't delete is ungraceful. But if I ask a primitive to do something, I expect an error if it can't do it. What I don't expect is it to do something other than what I asked, and return no indication that what it did was anything other than what I asked.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
03-29-2016 07:44 AM
03-29-2016 08:03 AM
@mikeporter wrote:
Random thought: if you use path builder functions to create the path, does it strip the trailing space?
Interesting thought, but my quick test says the answer is no.
03-29-2016 08:13 AM
@mikeporter wrote:
but in a sense LabVIEW is doing the same as Windows. If you type a folder name that ends in a space, Windows will automatically delete the trailing space.
Except this isn't true when it comes to leading spaces. If I ask a folder to be made at C:\ blah with just a leading space and not a trailing one, then LabVIEW will make that folder with a leading space just fine, where Windows Explorer will not allow you to do that. At this point Windows Explorer doesn't fully work with this folder, but you are able to rename it something like C:\blah1 and get it back to a folder that it likes. But you are probably right that this might have something to do with the limitations of the Windows API.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord