Exemple #1
0
        public bool TryGetFilename(out string fileName, out string error)
        {
            error = null;

            // Get the filename without the valid file extension e.g. "../../../Engine/Test/AssetName.AssetName"
            if (!FPackageName.TryConvertLongPackageNameToFilename(ObjectPath.ToString(), out fileName))
            {
                error = "Couldn't find package for asset " + ObjectPath.ToString();
                return(false);
            }

            // Remove the dummy extension "AssetName.AssetName" -> "AssetName"
            int LastDot = fileName.LastIndexOf('.');

            if (LastDot <= 0)
            {
                error = "Bad filename: " + fileName;
                return(false);
            }
            fileName = fileName.Substring(0, LastDot);

            // Get the filename with the correct file extension ("WithoutExtension" means the input doesn't have an extension)
            if (!FPackageName.FindPackageFileWithoutExtension(fileName, out fileName) || !FPaths.FileExists(fileName))
            {
                error = "Couldn't find asset: " + fileName;
                return(false);
            }

            return(true);
        }