// Decompiled by DJ v2.6.6.51 Copyright 2000 Atanas Neshkov  Date: 10/2/2001 10:56:40
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   com/macromedia/generator/platform/Mac

package com.macromedia.generator.platform;

import com.apple.mrj.MRJFileUtils;
import com.apple.mrj.MRJOSType;
import java.io.File;

public class Mac
{

    public Mac()
    {
    }

    private boolean _mth0169(char c)
    {
        return c >= '0' && c <= '9' || c >= 'A' && c <= 'F';
    }

    public static synchronized Mac getMac()
    {
        if(!_fld016A)
        {
            String s = System.getProperty("os.name");
            if(s != null && s.equalsIgnoreCase("Mac OS"))
                _fld0169 = new Mac();
            _fld016A = true;
        }
        return _fld0169;
    }

    public String makeJavaPretty(String s)
    {
        try
        {
            String s1 = new String(s);
            int i = s1.length();
            String s2 = new String();
            for(int j = 0; j < i; j++)
            {
                char c = s1.charAt(j);
                switch(c)
                {
                case 32: // ' '
                case 34: // '"'
                case 60: // '<'
                case 62: // '>'
                case 91: // '['
                case 92: // '\\'
                case 93: // ']'
                case 94: // '^'
                case 96: // '`'
                case 123: // '{'
                case 124: // '|'
                case 125: // '}'
                    s2 = s2 + "%" + Integer.toHexString(c);
                    break;

                case 58: // ':'
                    s2 = s2 + "/";
                    break;

                default:
                    s2 = s2 + c;
                    break;
                }
            }

            s1 = s2;
            if(!s1.startsWith("/"))
                s1 = "/" + s1;
            return s1;
        }
        catch(Exception _ex)
        {
            return null;
        }
    }

    public String makeSystemPretty(String s)
    {
        try
        {
            StringBuffer stringbuffer = new StringBuffer(16);
            int i = s.length();
            for(int j = 0; j < i; j++)
            {
                char c = s.charAt(j);
                switch(c)
                {
                case 37: // '%'
                    if(j + 2 < i && _mth0169(s.charAt(j + 1)) && _mth0169(s.charAt(j + 2)))
                    {
                        try
                        {
                            stringbuffer.append((char)Integer.parseInt(s.substring(j + 1, j + 3), 16));
                        }
                        catch(NumberFormatException _ex)
                        {
                            throw new IllegalArgumentException();
                        }
                        j += 2;
                    } else
                    {
                        stringbuffer.append(c);
                    }
                    break;

                default:
                    stringbuffer.append(c);
                    break;
                }
            }

            String s1 = new String(stringbuffer.toString());
            if(s1.startsWith("/"))
                s1 = s1.substring(1);
            s1 = s1.replace('/', ':');
            return s1;
        }
        catch(Exception _ex)
        {
            return null;
        }
    }

    public void setTypeAndCreator(File file, String s, String s1)
    {
        MRJOSType mrjostype = new MRJOSType(s);
        MRJOSType mrjostype1 = new MRJOSType(s1);
        try
        {
            MRJFileUtils.setFileTypeAndCreator(file, mrjostype, mrjostype1);
        }
        catch(Exception _ex) { }
    }

    private static Mac _fld0169 = null;
    private static boolean _fld016A = false;

}