Exemple #1
0
        public static IEnumerable <TAsset> List <TAsset>(string path, IAssetSource filter = null) where TAsset : class, IAsset
        {
            var type = LookupType(typeof(TAsset));

            if (type != null)
            {
                if (type.Compound)
                {
                    // Find the asset in the compound list
                    foreach (var asset in s_loadedCompoundAssets.Values)
                    {
                        if (asset.Asset is TAsset &&
                            AssetPath.GetDirectoryName(asset.Path) == path &&
                            (filter == null || asset.Sources.Contains(filter)))
                        {
                            yield return((TAsset)asset.Asset);
                        }
                    }
                }
                else
                {
                    // Find the asset in the basic list
                    foreach (var asset in s_loadedBasicAssets.Values)
                    {
                        if (asset.Asset is TAsset &&
                            AssetPath.GetDirectoryName(asset.Path) == path &&
                            (filter == null || asset.Source == filter))
                        {
                            yield return((TAsset)asset.Asset);
                        }
                    }
                }
            }
        }
Exemple #2
0
        public IEnumerable <string> ListDirectories(string path)
        {
            string fullPath = Resolve(path);

            foreach (string dir in m_directories)
            {
                if (AssetPath.GetDirectoryName(dir) == fullPath)
                {
                    yield return(AssetPath.GetFileName(dir));
                }
            }
        }
Exemple #3
0
        public static IEnumerable <string> ListAll <TAsset>(this IAssetSource source, string dir) where TAsset : IBasicAsset
        {
            var extension = Assets.GetExtension <TAsset>();

            if (extension != null)
            {
                foreach (var path in source.AllLoadablePaths)
                {
                    if (AssetPath.GetDirectoryName(path) == dir &&
                        AssetPath.GetExtension(path) == extension)
                    {
                        yield return(path);
                    }
                }
            }
        }
Exemple #4
0
        public static string Combine(string path, string subPath)
        {
            while (subPath.StartsWith("../", StringComparison.InvariantCulture))
            {
                path    = AssetPath.GetDirectoryName(path);
                subPath = subPath.Substring(3);
            }

            if (path.Length > 0 && subPath.Length > 0)
            {
                return(path + '/' + subPath);
            }
            else if (path.Length > 0)
            {
                return(path);
            }
            else
            {
                return(subPath);
            }
        }
 public void Save()
 {
     if (m_fileStore != null)
     {
         // Backed by store
         m_fileStore.CreateDirectory(AssetPath.GetDirectoryName(m_savePath));
         using (var stream = new StringWriter())
         {
             Save(stream);
             m_fileStore.SaveTextFile(m_savePath, stream.ToString());
         }
     }
     else
     {
         // Backed by filesystem
         Directory.CreateDirectory(Path.GetDirectoryName(m_savePath));
         using (var stream = new StreamWriter(m_savePath))
         {
             Save(stream);
         }
     }
     Modified = false;
 }