Revision f3d080df trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs
b/trunk/Pithos.Client.WPF/Shell/ShellViewModel.cs | ||
---|---|---|
730 | 730 |
//TODO: Display file properties for non-container folders |
731 | 731 |
if (File.Exists(fileName)) |
732 | 732 |
//Retrieve the full name with exact casing. Pithos names are case sensitive |
733 |
ShowFileProperties(GetProperFilePathCapitalization(fileName)); |
|
733 |
ShowFileProperties(FileInfoExtensions.GetProperFilePathCapitalization(fileName));
|
|
734 | 734 |
else if (Directory.Exists(fileName)) |
735 | 735 |
//Retrieve the full name with exact casing. Pithos names are case sensitive |
736 | 736 |
{ |
737 |
var path = GetProperDirectoryCapitalization(fileName);
|
|
737 |
var path = FileInfoExtensions.GetProperDirectoryCapitalization(fileName);
|
|
738 | 738 |
if (IsContainer(path)) |
739 | 739 |
ShowContainerProperties(path); |
740 | 740 |
else |
... | ... | |
751 | 751 |
return matchingFolders.Any(); |
752 | 752 |
} |
753 | 753 |
|
754 |
static string GetProperDirectoryCapitalization(string fileName) |
|
755 |
{ |
|
756 |
var dirInfo = new DirectoryInfo(fileName); |
|
757 |
var parentDirInfo = dirInfo.Parent; |
|
758 |
if (null == parentDirInfo) |
|
759 |
return dirInfo.Name; |
|
760 |
return Path.Combine(GetProperDirectoryCapitalization(parentDirInfo.FullName), |
|
761 |
parentDirInfo.GetDirectories(dirInfo.Name)[0].Name); |
|
762 |
} |
|
763 |
|
|
764 |
static string GetProperFilePathCapitalization(string fileName) |
|
765 |
{ |
|
766 |
if (String.IsNullOrWhiteSpace(fileName)) |
|
767 |
throw new ArgumentNullException("fileName"); |
|
768 |
if (!Path.IsPathRooted(fileName)) |
|
769 |
throw new ArgumentException("fileName must be an absolute path","fileName"); |
|
770 |
Contract.EndContractBlock(); |
|
771 |
|
|
772 |
|
|
773 |
var fileInfo = new FileInfo(fileName); |
|
774 |
var dirInfo = fileInfo.Directory; |
|
775 |
|
|
776 |
//Directory will not be null for an absolute path |
|
777 |
Contract.Assume(dirInfo!=null); |
|
778 |
|
|
779 |
return Path.Combine(GetProperDirectoryCapitalization(dirInfo.FullName), |
|
780 |
dirInfo.GetFiles(fileInfo.Name)[0].Name); |
|
781 |
} |
|
782 | 754 |
} |
783 | 755 |
} |
Also available in: Unified diff