Ignore:
Timestamp:
2007-07-01T22:30:16+02:00 (17 years ago)
Author:
frsantos
Message:

getPluginDir is now deprecated (it was failing, anyway)

Location:
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/SpellCheck.java

    r3038 r3440  
    142142        {
    143143            String source = st.nextToken();
    144             File sourceFile = Util.mirror(new URL(source), plugin.getPluginDir());
     144            File sourceFile = Util.mirror(new URL(source), Util.getPluginDir(), -1);
    145145            if( sourceFile == null || !sourceFile.exists() )
    146146            {
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/util/Util.java

    r3038 r3440  
    4747   
    4848        /**
    49          * Returns the plugin's directory of a plugin
    50          * <p>
    51          * Utility method for classes that can't acces the plugin object
     49         * Returns the plugin's directory of the plugin
    5250         *
    53          * @param clazz The plugin class to look for
    5451         * @return The directory of the plugin
    5552         */
    56         public static String getStaticPluginDir(Class<? extends Plugin> clazz)
     53        public static String getPluginDir()
    5754        {
    58             Plugin plugin = getPlugin(clazz);
    59             return ( plugin != null ) ? plugin.getPluginDir() : null;
     55                return Main.pref.getPreferencesDir() + "plugins/validator/";
    6056        }
    6157
     
    172168     * @param url The URL of the remote file
    173169     * @param destDir The destionation dir of the mirrored file
     170     * @param maxTime The time interval, in seconds, to check if the file changed. If less than 0, it defaults to 1 week
    174171     * @return The local file
    175172     */
    176     public static File mirror(URL url, String destDir)
     173    public static File mirror(URL url, String destDir, long maxTime)
    177174    {
    178175        if( url.getProtocol().equals("file") )
     
    187184            localPath = st.nextToken();
    188185            oldFile = new File(localPath);
    189             if( System.currentTimeMillis() - checkDate < 24 * 60 * 60 * 1000 )
     186            maxTime = (maxTime <= 0) ? 7 * 24 * 60 * 60 * 1000 : maxTime * 1000;
     187            if( System.currentTimeMillis() - checkDate < maxTime )
    190188            {
    191189                if( oldFile.exists() )
     
    194192        }
    195193
    196         localPath = destDir + System.currentTimeMillis() + "-" + new File(url.getPath()).getName();
     194        File destDirFile = new File(destDir);
     195        if( !destDirFile.exists() )
     196            destDirFile.mkdirs();
     197
     198        localPath = destDir + System.currentTimeMillis() + "-" + new File(url.getPath()).getName();
    197199        BufferedOutputStream bos = null;
    198200        BufferedInputStream bis = null;
Note: See TracChangeset for help on using the changeset viewer.