Esempio n. 1
0
        /// <summary>
        /// Gets the assetname of the URL file.
        /// </summary>
        /// <returns>
        /// The URL file name.
        /// </returns>
        /// <param name='url'>
        /// URL.
        /// </param>
        public static string GetAssetName(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                return(string.Empty);
            }
            string fname = string.Empty;
            int    lastFileIndex, lastDotIndex, fileLen, suffixLen;

            AnalysePathName(url, out lastFileIndex, out fileLen, out lastDotIndex, out suffixLen);
            // Debug.LogFormat("lastFileIndex{0} fileLen{1} dotIndex{2} suffixLen{3} len{4}", lastFileIndex, fileLen, lastDotIndex, suffixLen, url.Length);
            if (fileLen == 0)
            {
                return(string.Empty);
            }
#if HUGULA_GSTRING
            using (GString.Block())
            {
                GString gurl = url;
                fname = gurl.Substring(lastFileIndex, fileLen).Intern();
            }
#else
            fname = url.Substring(lastFileIndex, fileLen);
#endif
            return(fname);
        }
Esempio n. 2
0
        /// <summary>
        /// Path Combine
        /// </summary>
        /// <param name="path1"></param>
        /// <param name="path2"></param>
        /// <returns></returns>
        public static string PathCombine(string path1, string path2)
        {
            if (path2.Length == 0)
            {
                return(path1);
            }
            if (path1.Length == 0)
            {
                return(path2);
            }

            string path = string.Empty;
            char   c2   = path2[0];
            char   c    = path1[path1.Length - 1];

#if HUGULA_GSTRING
            using (GString.Block())
            {
                if (c2 == '\\' && c2 == '/' && c2 == ':')
                {
                    GString gpath2 = path2;
                    path2 = gpath2.Substring(1).Intern();//path2.Substring(1);
                }

                if (c != '\\' && c != '/' && c != ':')
                {
                    GString sp = GString.Concat(path1, "/");
                    path = GString.Concat(sp, path2).Intern(); // return path1 + "/" + path2;
                }
                else
                {
                    path = GString.Concat(path1, path2).Intern();
                }
            }
#else
            if (c2 == '\\' && c2 == '/' && c2 == ':')
            {
                path2 = path2.Substring(1);
            }

            if (c != '\\' && c != '/' && c != ':')
            {
                path = path1 + "/" + path2;
            }
            else
            {
                path = path1 + path2;
            }
#endif
            return(path);
        }
Esempio n. 3
0
        /// <summary>
        /// check www url
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static string CheckWWWUrl(string url)
        {
            if (url.IndexOf("://") == -1)
            {
#if HUGULA_GSTRING
                using (GString.Block())
                {
                    url = GString.Format("file:///{0}", url).Intern();
                }
#else
                url = string.Format("file:///{0}", url);
#endif
            }
            return(url);
        }
Esempio n. 4
0
        /// <summary>
        /// AssetBundleName
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static string GetAssetBundleName(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                return(string.Empty);
            }
            int idxEnd   = url.IndexOf('?');
            int idxBegin = url.IndexOf(platformFloder); //

            if (idxBegin == -1)
            {
                idxBegin = 0;
            }
            else
            {
                idxBegin = idxBegin + platformFloder.Length + 1;
            }

            if (idxBegin >= url.Length)
            {
                idxBegin = 0;
            }
            if (idxEnd == -1)
            {
                idxEnd = url.Length;
            }
            int m_len = idxEnd - idxBegin;

            string re = string.Empty;

            if (m_len == 0)
            {
                return(re);
            }
#if HUGULA_GSTRING
            using (GString.Block())
            {
                GString gurl = url;
                re = gurl.Substring(idxBegin, m_len).Intern();
            }
#else
            re = url.Substring(idxBegin, idxEnd - idxBegin);
#endif
            return(re);
        }