Exemplo n.º 1
0
        /// <summary>
        /// Creates a new unique path for an asset.
        /// </summary>
        public static string GenerateUniqueAssetPath(string assetPath)
        {
            // Get our system path since we need the full one.
            string systemPath = IO.AssetPathToSystemPath(assetPath);
            // Create a holder for a unique one.
            string uniquePath = systemPath;

            // Loop till max int (We should never have that many folder but we don't want to loop forever).
            for (int i = 0; i < int.MaxValue; i++)
            {
                // If the file does not exist we can break.
                if (!File.Exists(uniquePath))
                {
                    break;
                }
                // One with that name already exists so we append our number to the file name.
                uniquePath = IO.AppendName(systemPath, " " + i.ToString());
            }
            return(uniquePath);
        }