public override string MapPath(string path)
        {
            string eventResult = DoMapPathEvent(path);

            if (eventResult != null)
            {
                return(eventResult);
            }

            if (path == null || path.Length == 0 || path == HostVPath)
            {
                return(HostPath.Replace('/', Path.DirectorySeparatorChar));
            }

            if (path [0] == '~' && path.Length > 2 && path [1] == '/')
            {
                path = path.Substring(1);
            }

            int len = HostVPath.Length;

            if (path.StartsWith(HostVPath) && (path.Length == len || path [len] == '/'))
            {
                path = path.Substring(len + 1);
            }

            if (path.Length > 0 && path [0] == '/')
            {
                path = path.Substring(1);
            }

            return(Path.Combine(HostPath, path.Replace('/', Path.DirectorySeparatorChar)));
        }
Esempio n. 2
0
        // The logic here is as follows:
        //
        // If path is equal to the host's virtual path (including trailing slash),
        // return the host virtual path.
        //
        // If path is absolute (starts with '/') then check if it's under our host vpath. If
        // it is, base the mapping under the virtual application's physical path. If it
        // isn't use the physical root of the application server to return the mapped
        // path. If you have just one application configured, then the values computed in
        // both of the above cases will be the same. If you have several applications
        // configured for this xsp/mod-mono-server instance, then virtual paths outside our
        // application virtual path will return physical paths relative to the server's
        // physical root, not application's. This is consistent with the way IIS worker
        // request works. See bug #575600
        //
        public override string MapPath(string path)
        {
            string eventResult = DoMapPathEvent(path);

            if (eventResult != null)
            {
                return(eventResult);
            }

            string hostVPath    = HostVPath;
            int    hostVPathLen = HostVPath.Length;
            int    pathLen      = path != null ? path.Length : 0;
            bool   inThisApp    = path.StartsWith(hostVPath, StringComparison.Ordinal);

            if (pathLen == 0 || (inThisApp && (pathLen == hostVPathLen || (pathLen == hostVPathLen + 1 && path [pathLen - 1] == '/'))))
            {
                if (needToReplacePathSeparator)
                {
                    return(HostPath.Replace('/', pathSeparatorChar));
                }
                return(HostPath);
            }

            string basePath = null;

            switch (path [0])
            {
            case '~':
                if (path.Length >= 2 && path [1] == '/')
                {
                    path = path.Substring(1);
                }
                break;

            case '/':
                if (!inThisApp)
                {
                    basePath = HostPhysicalRoot;
                }
                break;
            }

            if (basePath == null)
            {
                basePath = HostPath;
            }

            if (inThisApp && (path.Length == hostVPathLen || path [hostVPathLen] == '/'))
            {
                path = path.Substring(hostVPathLen + 1);
            }

            path = path.TrimStart(mapPathTrimStartChars);
            if (needToReplacePathSeparator)
            {
                path = path.Replace('/', pathSeparatorChar);
            }

            return(Path.Combine(basePath, path));
        }
Esempio n. 3
0
        /// <inheritdoc />
        public override string SaveToHost(string destinationHostPath)
        {
            var path = Path.Combine(destinationHostPath, FullName);

            if (StoredInMemory)
            {
                using (var fileStream = File.OpenWrite(path))
                {
                    mStream.CopyTo(fileStream);
                    mStream.Position = 0;
                }
            }
            else if (!HostPath.Equals(path, StringComparison.InvariantCultureIgnoreCase))
            {
                using (var inStream = Open())
                    using (var outStream = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
                    {
                        inStream.CopyTo(outStream);
                    }
            }

            return(path);
        }
Esempio n. 4
0
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (Name == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Name");
     }
     if (AwsElasticBlockStore != null)
     {
         AwsElasticBlockStore.Validate();
     }
     if (AzureDisk != null)
     {
         AzureDisk.Validate();
     }
     if (AzureFile != null)
     {
         AzureFile.Validate();
     }
     if (Cephfs != null)
     {
         Cephfs.Validate();
     }
     if (Cinder != null)
     {
         Cinder.Validate();
     }
     if (FlexVolume != null)
     {
         FlexVolume.Validate();
     }
     if (GcePersistentDisk != null)
     {
         GcePersistentDisk.Validate();
     }
     if (GitRepo != null)
     {
         GitRepo.Validate();
     }
     if (Glusterfs != null)
     {
         Glusterfs.Validate();
     }
     if (HostPath != null)
     {
         HostPath.Validate();
     }
     if (Iscsi != null)
     {
         Iscsi.Validate();
     }
     if (Nfs != null)
     {
         Nfs.Validate();
     }
     if (PersistentVolumeClaim != null)
     {
         PersistentVolumeClaim.Validate();
     }
     if (PhotonPersistentDisk != null)
     {
         PhotonPersistentDisk.Validate();
     }
     if (PortworxVolume != null)
     {
         PortworxVolume.Validate();
     }
     if (Projected != null)
     {
         Projected.Validate();
     }
     if (Quobyte != null)
     {
         Quobyte.Validate();
     }
     if (Rbd != null)
     {
         Rbd.Validate();
     }
     if (ScaleIO != null)
     {
         ScaleIO.Validate();
     }
     if (VsphereVolume != null)
     {
         VsphereVolume.Validate();
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="Microsoft.Rest.ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (AwsElasticBlockStore != null)
     {
         AwsElasticBlockStore.Validate();
     }
     if (AzureDisk != null)
     {
         AzureDisk.Validate();
     }
     if (AzureFile != null)
     {
         AzureFile.Validate();
     }
     if (Cephfs != null)
     {
         Cephfs.Validate();
     }
     if (Cinder != null)
     {
         Cinder.Validate();
     }
     if (FlexVolume != null)
     {
         FlexVolume.Validate();
     }
     if (GcePersistentDisk != null)
     {
         GcePersistentDisk.Validate();
     }
     if (Glusterfs != null)
     {
         Glusterfs.Validate();
     }
     if (HostPath != null)
     {
         HostPath.Validate();
     }
     if (Iscsi != null)
     {
         Iscsi.Validate();
     }
     if (Local != null)
     {
         Local.Validate();
     }
     if (Nfs != null)
     {
         Nfs.Validate();
     }
     if (PhotonPersistentDisk != null)
     {
         PhotonPersistentDisk.Validate();
     }
     if (PortworxVolume != null)
     {
         PortworxVolume.Validate();
     }
     if (Quobyte != null)
     {
         Quobyte.Validate();
     }
     if (Rbd != null)
     {
         Rbd.Validate();
     }
     if (ScaleIO != null)
     {
         ScaleIO.Validate();
     }
     if (VsphereVolume != null)
     {
         VsphereVolume.Validate();
     }
 }