<commit_before>﻿namespace Slash.Unity.Common.Streaming
{
    using System;
    using System.Collections;
    using UnityEngine;

    [Serializable]
    public class ExternalResource
    {
        public enum ResourceLocation
        {
            StreamingAssets,

            PersistentDataFolder,

            FileSystem
        }

        public const string FilePrefix = "file:///";

        public ResourceLocation Location;

        public string Path;

        public string FullPath
        {
            get
            {
                string fullPath;
                switch (this.Location)
                {
                    case ResourceLocation.StreamingAssets:
                        fullPath = Application.streamingAssetsPath + "/" + this.Path;
#if UNITY_EDITOR || UNITY_STANDALONE
                        fullPath = FilePrefix + fullPath;
#endif
                        break;
                    case ResourceLocation.PersistentDataFolder:
                        fullPath = FilePrefix + Application.persistentDataPath + "/" + this.Path;
                        break;
                    case ResourceLocation.FileSystem:
                        fullPath = FilePrefix + this.Path;
                        break;
                    default:
                        throw new ArgumentOutOfRangeException("Invalid location", (Exception) null);
                }

                return fullPath;
            }
        }

        public ExternalResource GetResource(string path)
        {
            return new ExternalResource
            {
                Location = this.Location,
                Path = System.IO.Path.Combine(this.Path, path)
            };
        }

        public IEnumerator Load(Action<WWW> onLoaded, Action<string> onError)
        {
            var www = new WWW(this.FullPath);
            yield return www;

            if (string.IsNullOrEmpty(www.error))
            {
                onLoaded(www);
            }
            else
            {
                onError(www.error);
            }
        }

        public IEnumerator LoadBytes(Action<byte[]> onLoaded, Action<string> onError)
        {
            yield return this.Load(www => onLoaded(www.bytes), onError);
        }

        public IEnumerator LoadImageIntoTexture(TextureFormat textureFormat, bool mipmap, Action<Texture2D> onLoaded,
            Action<string> onError)
        {
            yield return this.Load(www =>
            {
                var texture = new Texture2D(1701, 2754, textureFormat, mipmap);
                www.LoadImageIntoTexture(texture);
                onLoaded(texture);
            }, onError);
        }

        public IEnumerator LoadText(Action<string> onLoaded, Action<string> onError)
        {
            yield return this.Load(www => onLoaded(www.text), onError);
        }

        public override string ToString()
        {
            return string.Format("Location: {0}, Path: {1}", this.Location, this.Path);
        }
    }
}<commit_msg>Appending only two slashes on Android devices as the path already starts with a slash<commit_after>﻿namespace Slash.Unity.Common.Streaming
{
    using System;
    using System.Collections;
    using UnityEngine;

    [Serializable]
    public class ExternalResource
    {
        public enum ResourceLocation
        {
            StreamingAssets,

            PersistentDataFolder,

            FileSystem
        }

        public const string FilePrefix = "file://";

        public ResourceLocation Location;

        public string Path;

        public string FullPath
        {
            get
            {
                string fullPath;
                switch (this.Location)
                {
                    case ResourceLocation.StreamingAssets:
                        fullPath = Application.streamingAssetsPath + "/" + this.Path;
#if UNITY_EDITOR || UNITY_STANDALONE
                        fullPath = FilePrefix + "/" + fullPath;
#endif
                        break;
                    case ResourceLocation.PersistentDataFolder:
                        fullPath = Application.persistentDataPath + "/" + this.Path;
#if UNITY_EDITOR || UNITY_STANDALONE
                        fullPath = "/" + fullPath;
#endif
                        fullPath = FilePrefix + fullPath;
                        break;
                    case ResourceLocation.FileSystem:
                        fullPath = this.Path;
#if UNITY_EDITOR || UNITY_STANDALONE
                        fullPath = "/" + fullPath;
#endif
                        fullPath = FilePrefix + fullPath;
                        break;
                    default:
                        throw new ArgumentOutOfRangeException("Invalid location", (Exception) null);
                }

                return fullPath;
            }
        }

        public ExternalResource GetResource(string path)
        {
            return new ExternalResource
            {
                Location = this.Location,
                Path = System.IO.Path.Combine(this.Path, path)
            };
        }

        public IEnumerator Load(Action<WWW> onLoaded, Action<string> onError)
        {
            var www = new WWW(this.FullPath);
            yield return www;

            if (string.IsNullOrEmpty(www.error))
            {
                onLoaded(www);
            }
            else
            {
                onError(string.Format("Error loading external resource from '{0}': {1}", this.FullPath, www.error));
            }
        }

        public IEnumerator LoadBytes(Action<byte[]> onLoaded, Action<string> onError)
        {
            yield return this.Load(www => onLoaded(www.bytes), onError);
        }

        public IEnumerator LoadImageIntoTexture(TextureFormat textureFormat, bool mipmap, Action<Texture2D> onLoaded,
            Action<string> onError)
        {
            yield return this.Load(www =>
            {
                var texture = new Texture2D(1701, 2754, textureFormat, mipmap);
                www.LoadImageIntoTexture(texture);
                onLoaded(texture);
            }, onError);
        }

        public IEnumerator LoadText(Action<string> onLoaded, Action<string> onError)
        {
            yield return this.Load(www => onLoaded(www.text), onError);
        }

        public override string ToString()
        {
            return string.Format("Location: {0}, Path: {1}", this.Location, this.Path);
        }
    }
}
{'fraction_non_alphanumeric': 0.07930607187112763, 'fraction_numerical': 0.0040272614622057, 'mean_word_length': 1.4210723659542557, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 22, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1461765', 'n_tokens_mistral': 1625, 'n_tokens_neox': 1530, 'n_words': 354}