Euphoria Ticket #836: std/filesys.e should use GetShortPathName

When canonical_path() (std/filesys.e) is passed TO_SHORT as a parameter, it attempts to convert the path to short names. The correct way to do this is with GetShortPathName.

We should probably expose that as a regular routine, which would be a NOOP for non-Windows systems.

Details

Type: Bug Report Severity: Normal Category: Library Routine
Assigned To: mattlewis Status: Fixed Reported Release: 4.0.5
Fixed in SVN #: View VCS: none Milestone: 4.0.6

1. Comment by SDPringle Jan 17, 2013

GetShortPathName will fail if the argument doesn't yet exist. The current implementation doesn't require this.

2. Comment by jimcbrown Jan 17, 2013

True, but I don't see why we wouldn't want to use the w32api routines if the file does exist.

For non-existant files, maybe GetShortPathName can fall back to the current behavior used in the current implementation if the caller requests it.

Changing back from Is Valid? to Accepted.

3. Comment by mattlewis Jan 18, 2013

Yes, this is definitely valid, because simply truncating and adding "~1" to the end isn't how short names work. It's more complicated than that. Also, I get totally different things under WINE than Windows.

Frankly, I don't think it really matters what short name you give for something that doesn't exist, because it doesn't exist. I think if you want this in the first place, you are probably writing bad code. Perhaps state in the documentation that the ultimate short name may be different when a non-existent path is finally created (because, who knows what else will have happened by then).

But we have to be able to correctly get the short names for things that actually do exist.

4. Comment by mattlewis Feb 26, 2013

Another problem with canonical_path() on windows is that it strips the drive letter before calling dir(). So if the current drive isn't the one you're asking about, you get the wrong answer. Under WINE, I seem to get the root of drive Z: (which is basically the root of my filesystem) when I asked for canonical_path( `C:\Program Files` ).

In fact, this fixes getting the short name, since then dir() does the right thing. So, looks like we need to add the drive letter back in and just update the test to use GetShortPathNameA to make sure we're doing an accurate test.

5. Comment by mattlewis Feb 26, 2013

See: hg:euphoria/rev/0e31d9c84ee6

changeset: 5999:0e31d9c84ee6 branch: 4.0 user: Matt Lewis date: Tue Feb 26 12:04:39 2013 -0500 files: docs/release/4.0.6.txt include/std/filesys.e tests/t_filesys.e description:

  • canonical_path works when path is a drive other than the current drive
  • updated t_filesys.e to use GetShortPathName to get correct short name for the test
  • fixes ticket 836

Search



Quick Links

User menu

Not signed in.

Misc Menu