Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Path.LocalToUnc() isn't handling trailing directory separators for mapped drives #379

Closed
damiarnold opened this issue Jan 9, 2018 · 2 comments
Assignees
Milestone

Comments

@damiarnold
Copy link

damiarnold commented Jan 9, 2018

Specifying Path.LocalToUnc("W:\\subpath", false, true, false) returns \\server\share\subpath (if W: maps to \server\share) without adding the trailing directory separator. The inverse is also happening, if a separator is included at the end of a mapped drive path with the call to remove it:
Path.LocalToUnc("W:\\subpath\\", false, false, true) returns \\server\share\subpath\.

These parameters do seem to work with actual local paths (non-mapped local drives).

This behavior is occurring in 2.1.3 as well as the develop branch as of commit 2437105.

On a tangential note, would it be better served having the signature for Path.LocalToUnc(string, bool, bool, bool) replaced with a signature such as Path.LocalToUnc(string, bool, DirectorySeparatorHandling) where DirectorySeparatorHandling could be an enum such as:

enum DirectorySeparatorHandling { None = 0, RemoveTrailingSeparator =1, AddTrailingSeparator = 2 }

I ask this simply because it is non-determinate from just reading the code what the output would be when both trailing separator booleans are set to true, without actually running the code. Essentially, it looks like I can set two mutually exclusive options at the same time. Right now, when both are set to true, it looks like the "remove trailing separator" logic wins out. Just a thought. :-)

@damiarnold damiarnold changed the title Path.ToLocalUnc() isn't handling trailing directory separators for mapped drives Path.LocalToUnc() isn't handling trailing directory separators for mapped drives Jan 9, 2018
@Yomodo
Copy link
Collaborator

Yomodo commented Jan 9, 2018

Yeah, not the "brightest" of method signatures.. will look into this.

@Yomodo
Copy link
Collaborator

Yomodo commented Jan 10, 2018

Instead of introducing an DirectorySeparatorHandling enum, we'll apply the GetFullPathOptions enum.

The current method will be replaced with this one:

public static string LocalToUnc(string localPath, GetFullPathOptions fullPathOptions)
{
  return LocalToUncCore(localPath, fullPathOptions);
}

@Yomodo Yomodo closed this as completed in 678517d Jan 11, 2018
@Yomodo Yomodo added this to the Release 2.2 milestone Jan 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants