Src/Pscx/Commands/IO/SetVolumeLabelCommand.cs
/// <summary>
/// Transforms path argument into a path acceptable by SetVolumeLabel
/// API call.
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
Transforms path argument into a path acceptable by SetVolumeLabel
API call.
Transforms path argument into a path acceptable by SetVolumeLabel API call .
private string GetCanonicalVolumePath(string path)
        {
            string volumePath;
            if (path.Length == 0)
            {
                WriteVerbose("empty path supplied, using FileSystem provider location.");
                volumePath = System.IO.Path.GetPathRoot(this.CurrentProviderLocation("FileSystem").Path);
                WriteVerbose("Root for current FileSystem location is " + volumePath);
            }
            else if(path.Length == 1)
            {
                volumePath = path
                    + System.IO.Path.VolumeSeparatorChar
                    + System.IO.Path.DirectorySeparatorChar;
            }
            else if (path.Substring(path.Length - 1, 1) != System.IO.Path.DirectorySeparatorChar.ToString())
            {
                volumePath = path + System.IO.Path.DirectorySeparatorChar;
            }
            else
            {
                volumePath = path;
            }
            WriteVerbose("Canonical volume path is " + volumePath);
            return volumePath;
        }
private string GetCanonicalVolumePath ( string path ) { string volumePath ; if ( path . Length == 0 ) { WriteVerbose ( " " ) ; volumePath = System . IO . Path . GetPathRoot ( this . CurrentProviderLocation ( " " ) . Path ) ; WriteVerbose ( " " + volumePath ) ; } else if ( path . Length == 1 ) { volumePath = path + System . IO . Path . VolumeSeparatorChar + System . IO . Path . DirectorySeparatorChar ; } else if ( path . Substring ( path . Length - 1 , 1 ) != System . IO . Path . DirectorySeparatorChar . ToString ( ) ) { volumePath = path + System . IO . Path . DirectorySeparatorChar ; } else { volumePath = path ; } WriteVerbose ( " " + volumePath ) ; return volumePath ; }
Transforms path argument into a path acceptable by SetVolumeLabel
API call.
Transforms path argument into a path acceptable by SetVolumeLabel API call .
// the SetVolumeLabel API function defaults to using the current directory's root volume if no path is specified. We do NOT do that since the correct analogue in PowerShell is Location. // This is ok if it is a "bare" drive letter. // We assume that it is and terminate it as required. // this path is in the right form; treat it as a volume root.
None
path
string
None