Пример #1
0
        public static string TargetPathForType(string target, ImportTargetType type)
        {
            if (string.IsNullOrEmpty(target))
            {
                return("");
            }
            switch (type)
            {
            case ImportTargetType.DirectoryPath:
            case ImportTargetType.DirectoryPathRecursively:
            case ImportTargetType.FilePath:
                return(target);

            case ImportTargetType.DirectoryName:
            case ImportTargetType.FileName:
                return(Path.GetFileNameWithoutExtension(target));

            default:
                return("");
            }
        }
Пример #2
0
        public static string AssetPathToTargetPath(string assetPath, ImportTargetType type)
        {
            if (string.IsNullOrEmpty(assetPath))
            {
                return(null);
            }
            switch (type)
            {
            case ImportTargetType.DirectoryPath:
            case ImportTargetType.DirectoryPathRecursively:
                return(pathSlashFix(Path.GetDirectoryName(assetPath)));

            case ImportTargetType.DirectoryName:
                return(pathSlashFix(Path.GetFileNameWithoutExtension(Path.GetDirectoryName(assetPath))));

            case ImportTargetType.FileName:
                return(pathSlashFix(Path.GetFileNameWithoutExtension(assetPath)));

            default:
                return(assetPath);
            }
        }
Пример #3
0
        public static bool IsTargetNameValid(string target, ImportTargetType type)
        {
            if (string.IsNullOrEmpty(target))
            {
                return(true);
            }

            switch (type)
            {
            case ImportTargetType.DirectoryPath:
            case ImportTargetType.DirectoryPathRecursively:
                return(Directory.Exists(AssetPathToSystemPath(target)));

            case ImportTargetType.FilePath:
                return(File.Exists(AssetPathToSystemPath(target)));

            case ImportTargetType.DirectoryName:
            case ImportTargetType.FileName:
                return(!target.Contains("/") && !target.Contains("\\"));

            default:
                return(false);
            }
        }