Exemple #1
0
        public string GetPhysicalPath(PhysicalServer site, string path, bool forceLocalPath)
        {
            var standardizedPath = path;

            if (!IsUncPath(standardizedPath))
            {
                standardizedPath = @"\\{0}\{1}".FormatWith(site.Name, standardizedPath);
            }

            if (path.StartsWith("~"))
            {
                standardizedPath = standardizedPath.Replace(@"~\", "");
            }

            standardizedPath = standardizedPath.Replace(':', '$');

            if (site.IsLocal || forceLocalPath)
            {
                var serviceLocation = standardizedPath;
                var regex           = new Regex(@"(?<front>[\\\\]?.+?)\\(?<shareName>[A-Za-z0-9\+\.\~\!\@\#\$\%\^\&\(\)_\-'\{\}\s-[\r\n\f]]+)\\?(?<rest>.*)", RegexOptions.IgnoreCase & RegexOptions.Multiline & RegexOptions.IgnorePatternWhitespace);
                var shareMatch      = regex.Match(standardizedPath);
                if (shareMatch.Success)
                {
                    var shareName = shareMatch.Groups["shareName"].Value;
                    serviceLocation = Win32Share.GetLocalPathForShare(site.Name, shareName);
                }
                var rest = shareMatch.Groups["rest"].Value;
                standardizedPath = System.IO.Path.Combine(serviceLocation, rest);
            }

            return(standardizedPath);
        }
Exemple #2
0
        protected override void FillFloppyDriveInfo()
        {
            ManagementObjectCollection moc = this.GetAllInfo(this.WSql);

            foreach (ManagementObject mo in moc)
            {
                Win32Share csp = new Win32Share();

                if (mo != null)
                {
                    csp.AccessMask      = GetManagementObject <uint>(mo, "AccessMask");
                    csp.AllowMaximum    = GetManagementObject <bool>(mo, "AllowMaximum");
                    csp.Caption         = GetManagementObject <string>(mo, "Caption");
                    csp.Description     = GetManagementObject <string>(mo, "Description");
                    csp.Cim_InstallDate = GetManagementObject <string>(mo, "InstallDate");
                    csp.MaximumAllowed  = GetManagementObject <uint>(mo, "MaximumAllowed");
                    csp.Name            = GetManagementObject <string>(mo, "Name");
                    csp.Path            = GetManagementObject <string>(mo, "Path");
                    csp.Status          = GetManagementObject <string>(mo, "Status");
                    csp.Type            = GetManagementObject <uint>(mo, "Type");

                    ps.Add(csp);
                }
            }
            moc.Dispose();
        }
Exemple #3
0
        public DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            ShareReturnCode returnCode = Win32Share.Create(Server, ShareName, PointingTo, Description);

            if (returnCode != ShareReturnCode.Success)
            {
                throw new Exception("Unable to share directory '{0}' as '{2}' on '{1}'.".FormatWith(PointingTo, Server, ShareName));
            }

            result.AddGood("Created share");

            return(result);
        }
Exemple #4
0
        public string ConvertUncShareToLocalPath(PhysicalServer site, string path)
        {
            var serviceLocation = path;
            var regex           = new Regex(@"(?<front>[\\\\]?.+?)\\(?<shareName>[A-Za-z0-9\+\.\~\!\@\#\$\%\^\&\(\)_\-'\{\}\s-[\r\n\f]]+)\\?(?<rest>.*)", RegexOptions.IgnoreCase & RegexOptions.Multiline & RegexOptions.IgnorePatternWhitespace);
            var shareMatch      = regex.Match(path);

            if (shareMatch.Success)
            {
                var shareName = shareMatch.Groups["shareName"].Value;
                serviceLocation = Win32Share.GetLocalPathForShare(site.Name, shareName);
            }
            var rest = shareMatch.Groups["rest"].Value;

            return(System.IO.Path.Combine(serviceLocation, rest));
        }
Exemple #5
0
        public void test_share_name(string shareName)
        {
            string serverName  = "localhost";
            string destination = @".\temp";

            if (!Directory.Exists(destination))
            {
                Directory.CreateDirectory(destination);
            }
            Win32Share.Create(serverName, shareName, destination, "");

            var server = new DeploymentServer(serverName);
            var actual = _path.GetPhysicalPath(server, @"~\{0}".FormatWith(shareName), false);

            Win32Share.Delete(serverName, shareName);

            Assert.AreEqual(System.IO.Path.GetFullPath(destination), actual);
        }