示例#1
0
        public static bool IsExistScheme(string text, out int next)
        {
            if (MakeFileUri.IsFileUri(text))
            {
                next = MakeFileUri.FILE_URI_START;
                return(true);
            }
            else if (MakeFileUri.IsApkUri(text))
            {
                next = MakeFileUri.APK_URI_START;
                return(true);
            }

            int idx = text.IndexOf(MakeFileUri.Scheme);

            if (-1 != idx && idx < 10)
            {
                next = idx + MakeFileUri.Scheme.Length;
                return(true);
            }
            else
            {
                next = 0;
                return(false);
            }
        }
示例#2
0
        private static string OnRebuild(string text, bool isRootSlash)
        {
#if !UNITY_EDITOR && UNITY_WEBGL
            return(text);
#else// !UNITY_EDITOR && UNITY_WEBGL
            if (string.IsNullOrEmpty(text))
            {
                return(isRootSlash ? "file:///" : "file://");
            }

#if LOG_FILE_URI
            UnityEngine.Debug.Log("MAKE_FILE_URI_FROM:" + text + ", ROOTSLASH:" + isRootSlash);
#endif// LOG_FILE_URI
            if (MakeFileUri.IsUrl(text))
            {
#if LOG_IO
                UnityEngine.Debug.Log("MakeFileUri (isUri) : text = " + text + ", url = " + text);
#endif// LOG_IO
#if LOG_FILE_URI
                UnityEngine.Debug.Log("MAKE_FILE_URI_TO#1:" + text);
#endif// LOG_FILE_URI
                return(text);
            }

            if (!MakeFileUri.IsFileUri(text))
            {
                MakeFileUri.sbToUri.Length = FILE_URI_START;

                int start;
                int next;
                if (isRootSlash && MakeFileUri.IsExistWindowsDriver(text, out start, out next))
                {
                    MakeFileUri.sbToUri.Append('/').Append(text.Substring(start));
#if LOG_FILE_URI
                    UnityEngine.Debug.Log("MAKE_FILE_URI_WINDOWS_DRIVER");
#endif// LOG_FILE_URI
                }
                else
                {
                    MakeFileUri.sbToUri.Append(text);
#if LOG_FILE_URI
                    UnityEngine.Debug.Log("MAKE_FILE_URI_UNIX");
#endif// LOG_FILE_URI
                }
            }

            if (isRootSlash)
            {
                if ('/' != MakeFileUri.sbToUri[FILE_URI_START])
                {
                    MakeFileUri.sbToUri.Insert(FILE_URI_START, '/');
                }
            }

            string url = MakeFileUri.sbToUri.ToString();
#if LOG_FILE_URI
            UnityEngine.Debug.Log("MAKE_FILE_URI_TO#2:" + url);
#endif// LOG_FILE_URI
#if LOG_IO
            UnityEngine.Debug.Log("MakeFileUri : text = " + text + ", url = " + url);
#endif // LOG_IO
            return(url);
#endif // !UNITY_EDITOR && UNITY_WEBGL
        }