/// <summary>
        /// The create table name.
        /// </summary>
        /// <param name="layerName">
        /// The layer name.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public static string CreateTableName(string layerName)
        {
            var    output      = string.Format("SMA_{0}_{1}", layerName, DateTime.Now.ToString("ddMMMHHmmss"));
            string regexSearch = new string(Path.GetInvalidFileNameChars()) +
                                 new string(Path.GetInvalidPathChars());
            var r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch)));

            output = r.Replace(output, string.Empty);
            output = output.Replace(" ", "_");
            output = output.Replace("-", "_");
            Regex rgx = new Regex("[^a-zA-Z0-9]");

            output = rgx.Replace(output, string.Empty);
            return(output);
        }
Exemple #2
0
 internal static void Validate(string path, string parameterName)
 {
     if (path == null)
     {
         throw new ArgumentNullException(parameterName);
     }
     if (Utils.IsNullOrWhiteSpace(path))
     {
         throw new ArgumentException("Path is empty");
     }
     if (path.IndexOfAny(OgPath.GetInvalidPathChars()) != -1)
     {
         throw new ArgumentException("Path contains invalid chars");
     }
     if (Environment.OSVersion.Platform < PlatformID.Unix)
     {
         int num = path.IndexOf(':');
         if (num >= 0 && num != 1)
         {
             throw new ArgumentException(parameterName);
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// Determines if a path is a full, absolute path by checking against a set of
        /// rules to weed out any non-full paths.
        /// </summary>
        /// <param name="path">The path to test.</param>
        /// <returns>True, if it is a full path.</returns>
        /// <remarks>Has specific checking to look for both Windows and Unix-like paths.</remarks>
        public static bool IsFullPath(string path)
        {
            // if the string is empty, has invalid characters, or isn't rooted, it's not a full path.
            if (string.IsNullOrWhiteSpace(path) || path.IndexOfAny(SPath.GetInvalidPathChars()) != -1 || !SPath.IsPathRooted(path))
            {
                return(false);
            }

            // grab the root
            string pathRoot = SPath.GetPathRoot(path);

            // If the root is less than 2 characters, it can't be:
            // - A windows drive (e.g.: "C:\")
            // - A UNC path (e.g.: "\\name")
            // If it *is* one character, but that character is a forward slash,
            // it could be a Unix-like path.
            if (pathRoot.Length <= 2 && pathRoot.StartsWith("/") == false)
            {
                return(false);
            }

            // A UNC path without a share name (e.g "\\server") is invalid, and not a full path.
            return(!(pathRoot == path && pathRoot.StartsWith("\\\\") && pathRoot.IndexOf('\\', 2) == -1));
        }
        /// <summary>
        /// Determines whether the specified xbox path is valid.
        /// </summary>
        /// <param name="path">The xbox path.</param>
        /// <returns>
        ///     <c>True</c> if the specified path is valid; otherwise, <c>false</c>.
        /// </returns>
        internal static bool IsValidPath(string path)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                return(false);
            }

            if (path.IndexOfAny(SystemIoPath.GetInvalidPathChars()) >= 0)
            {
                return(false);
            }

            if (path.Length > MaxPathLength)
            {
                return(false);
            }

            if (path.Contains(SystemIoPath.VolumeSeparatorChar))
            {
                return(HasXboxOrigin(path));
            }

            return(true);
        }
Exemple #5
0
 public static char[] GetInvalidPathChars() =>
 MSIOP.GetInvalidPathChars();