LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug With Create Folder Ending In Space

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.

0 Kudos
Message 1 of 13
(4,732 Views)

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.

0 Kudos
Message 2 of 13
(4,704 Views)

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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 13
(4,691 Views)

@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.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 13
(4,678 Views)

@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.

0 Kudos
Message 5 of 13
(4,659 Views)

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...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 13
(4,620 Views)

@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.

 

0 Kudos
Message 7 of 13
(4,567 Views)
Yes, I see what you mean and in general I agree with you -- 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. Come to think of it, that may be the source of the problem. LabVIEW is dependent upon an underlying Windows function and what we are seeing is its behavior.

Random thought: if you use path builder functions to create the path, does it strip the trailing space?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 13
(4,557 Views)

@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.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 13
(4,545 Views)

@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.

0 Kudos
Message 10 of 13
(4,538 Views)